DEV Community

terrierscript
terrierscript

Posted on • Edited on

4 2

Generate staging app.json for Expo like flavor

This article is depreacted
In Latest Expo version can dynamic config app.config.js

see: https://docs.expo.io/workflow/configuration/#dynamic-configuration-with-appconfigjs




In some case, we need change app.json variable for staging channel (like bundleIdentifer, icon , etc...)

But expo hasn't flavor function.
I try to generate app.json per publish.

build app.json

First, we write JSON override config.

app-staging-override.json

{
  "expo": {
    "slug":"my-application-staging"
      "ios": {
    "bundleIdentifier": "com.foo.baz.staging"
      }
    }
  }
}

Next we write app.json generator script.

bin/generate-staging-app-json.js

const merge = require("deepmerge")
const baseAppJson = require("../app.json")
const override = require("../app-staging-override.json")
const merged = merge.all([baseAppJson, override])
console.log(JSON.stringify(merged, null, 2))

This script is so simple. this merge app.json and ../app-staging-override.json and output stdout.

Finally, append prebuild script on package.json.

"scripts:"{
  "prebuild:ios:staging": "node bin/generate-staging-app-json.js > app.staging.generated.json",
  "build:ios:staging": "expo build:ios --config app.staging.generated.json --type archive --release-channel=YOUR_STAGING_CHANNEL "
}

Sentry mobile image

App store rankings love fast apps - mobile vitals can help you get there

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay