Skip to content

react-native bundle configs #14400

Description

@tabrindle

Description

This is a react-native bundle and react-native packager issue.

Currently there is no way of modifying the configurations passed to react-native bundle when building for iOS and Android. You are locked into the configs either the Debug/Release build config and build type respectively pass. Also, unlike what many recent posts about this might suggest about this issue, it seems you cannot just call react-native bundle ahead of the build with your params and have the native build pick that bundle up.

Reproduction Steps and Sample Code

Configs for bundling in an iOS build are essentially hardcoded in ./node_modules/react-native/packager/react-native-xcode.sh to scheme configuration set in Xcode. If you set the build type to debug, you have then set dev to true, and there is no way of making a debug build, signed with developer certs with an offline bundle. The same is true for the opposite. I have not yet found a way around this without changing react-native-xcode.sh or the bundle React Native build phase in Xcode.

Configs for Android are slightly easier to change if necessary, as ./android/app/build.gradle has the project.ext.react property list that can be configured. By setting bundleInDebug to true, we can create an unsigned debug release with the bundle embedded. The problem is this requires changing the build.gradle each time, or doing something like this:

if ( project.hasProperty("bundleInDebug") ) {
    project.ext.react = [
        bundleInDebug: true
    ]
}

and via Fastlane:

  gradle(
      task: "assemble",
      build_type: "Debug",
      project_dir: "android",
      properties: {
        "bundleInDebug" => true
      }
  )

or directly in gradle:

$PROJECT/android/gradlew assembleDebug -p android -PbundleInDebug=true

An example use case for this is internal alpha builds - where other developers or QA need a development build for debug access, not signed for release/appstore, and cannot be dependent upon a development server running. Hockeyapp is frequently used for this - distribution of these kinds of builds internally.

For beta builds that are a bit more open, the current configurations work fine and as intended for Testflight and Playstore beta.

Solution

There are a few possible solutions here, and I would be willing to make a PR for both better documentation and a new process, but would like input on what that process should be. This is clearly an issue, and I would like to see either how others have worked around it or solved it in the recent updates.

Solution 1:
We move the location of jsbundle to a predictable location (not derived data) allowing users to make a bundle however they choose ahead of the native build, and configure the native build to skip that particular build phase/step if that file is already present. We would also have to clean that folder at the end of a build. I believe this would be the easiest solution, but possibly the most breaking change.

Solution 2:
Keep the current order/flow of the native builds calling the bundle - Modify react-native-xcode.sh to allow for overriding properties passed in through xcargs and modify react.gradle to more easily accept property overrides from gradle. (this may already be possible through a better solution than above, as my understanding of groovy & gradle is not the best)

Solution 3:
Some combination of the above

Solution 4:
Tell me what I missed, because this isn't actually an issue, and close, and perhaps I should drink more coffee in the morning before submitting issues on GitHub.

Additional Information

  • React Native version: 0.44
  • Platform: iOS+Android
  • Development Operating System: MacOS 10.12.4
  • Dev tools: Xcode 8.3.2

Activity

  1. hramos commented on Aug 16, 2017

    @hramos
    Contributor

    Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

    If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

    • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
    • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
    • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

    If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

  2. MrLoh commented on Jan 19, 2018

    @MrLoh

    I also just ran into this issue. I got symlinks working with the metro client, by passing in a custom config as suggested in react/metro#1. But the bundler doesn't pick up the config file. The only current solution is to edit the react-native-xcode.sh file inside the react-native node module, but that is obviously not a great solution. Simply being able to pass an environment variable to the config via xcode would already help a lot. @hramos could you reopen, I would consider doing a pull request to implement passing the config location in some config, if there is an agreement how to do it.

  3. wprater commented on Feb 7, 2018

    @wprater

    The config location now seems to be passed, but Im still not seeing my options parsed by the bundler. Are you @MrLoh

  4. SoHotSoup commented on Feb 28, 2018

    @SoHotSoup

    Hey guys, @wprater and @MrLoh did you manage to overcome this? I have the same problem...

  5. MrLoh commented on Mar 1, 2018

    @MrLoh

    No, I had to modify that file manually. Otherwise the command line works fine

    Sent with GitHawk

  6. MrLoh commented on May 7, 2018

    @MrLoh

    @wprater @SoHotSoup I got it working in the meantime.

    In Xcode you can assign an environment variable in the build phase Bundle React Native code and images by adding the line export BUNDLE_CONFIG=./metro.config.js to the script:

    screen shot 2018-05-07 at 00 08 18

    In Android you just have to include bundleConfig: "./metro.config.js" in the project.ext.react field of your android/app/build.gradle:

    screen shot 2018-05-07 at 11 51 12

  7. locked as resolved and limited conversation to collaborators on Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions