Skip to content

[Project Config] Development / Release / Other? #2246

Closed

Description

@bleonard

For a variety of reasons, I'm trying to make additional configs in XCode. For example one is local against a local server and the other is against a staging server (or other configs).

I am having trouble getting these both to be able to be in debug mode (Command + R etc). In fact the only way to get Debug mode is to call my config the string "Debug" - I believe this is because that is the name of the one in the React xcode project.

I tried setting a variety of variables like RCT_DEBUG, RCT_DEV, and other ones from that config, but it did not work and I'm worried I'm going to miss something.

The same thing would be true for "Release" - I'd prefer to have a "staging" one and a"production" one and then I'd be really worried I'd be missing the right stuff for a real release.

In the end, I really just need to be able to build the project in a repeatable way (not changing the code) that can set a simple string as the "environment" as well as have control over the release / debug features of React.

This use case must be fairly common. Is there a better way to handle it or an example of a way to reliably control subproject dependencies?

Activity

  1. gre commented on Aug 6, 2015

    @gre
    Contributor

    this is a first step: #2101 but I think having multiple "target" would be great

  2. bleonard commented on Aug 9, 2015

    @bleonard
    ContributorAuthor

    I found that I could pass environment variables in the "Run" section of "Edit Scheme"
    Then I'm using this to allow a "staging" env even though I'm in running the "debug" config.

      NSDictionary *passed = [[NSProcessInfo processInfo] environment];
      NSString *override = [passed valueForKey:@"OVERRIDE_ENV"];
      if (override) {
        envName = override;
      }
    
  3. changed the title [-]Project Config: Development / Release / Other?[/-] [+][Project Config] Development / Release / Other?[/+] on Aug 9, 2015
  4. brentvatne commented on Aug 9, 2015

    @brentvatne
    Collaborator

    This issue hasn't come up for a lot of people yet it seems - if you would like to try your hand at submitting a pull request to add it to the core we can move the discussion there :) Otherwise let's archive this and bring it back if others find themselves with the same requirement where the change you kindly shared above isn't enough :)

  5. bleonard commented on Aug 9, 2015

    @bleonard
    ContributorAuthor

    OK. That's fine now that I have a workaround. How is facebook handling different configs or are there really only two? "Move fast and staging === production" ? :) or is there no local server? or maybe you do it all on the command line. I found I could pass extra stuff through xcodebuild

  6. john-griffin commented on Aug 10, 2015

    @john-griffin

    I hit this when creating new targets. The names don't match to Debug or Release so despite setting RCT_DEBUG it does not get used.

  7. bleonard commented on Aug 12, 2015

    @bleonard
    ContributorAuthor

    Hmm, it seems my workaround only works only on launch from Xcode. If you load it onto the phone, it doesn't send that flag on relaunch. More or less back to square one on this one, then.

  8. pewallin commented on Sep 4, 2015

    @pewallin

    We have the exact same scenario. And the workaround detailed is not really a solution either. I believe that building multiple apps with slight differences from the same codebase will be a quite common scenario? @brentvatne I suggest re-opening this issue. The problem is that calling the configuration "Debug" is the only way to get the dev tools working now.

  9. aphillipo commented on Oct 5, 2015

    @aphillipo

    Yes there should be better control over this stuff and config files by default. How do i pass targets/build settings to JS effectively?

  10. bleonard commented on Oct 19, 2015

    @bleonard
    ContributorAuthor

    I wrote up this blog post on the approaches we are taking with this issue: http://tech.taskrabbit.com/blog/2015/10/18/building-react-native-apps/

    Hope it's helpful to someone that lands here.

  11. jmreidy commented on Nov 19, 2015

    @jmreidy

    +1 for multiple targets, allowing per-environment configurations. Right now builds fail with anything other than DEBUG and RELEASE targets.

  12. Zensaburou commented on Feb 24, 2016

    @Zensaburou

    I'm targeting an Android release rather than iOS, but it'd be useful to have config variables to point the 'debug' APK at my staging API server rather than my production one.

    Currently the best way to do this seems to be editing the debug gradle build in build.gradle, however assuming we release this to iOS clients as well it would be nice to have a unified place to define such environment variables.

  13. JonnyBurger commented on Mar 5, 2016

    @JonnyBurger
    Contributor

    Some people here might find it useful to know that there is a global.__DEV__ variable exposed to the Javascript bundle which can be true or false. It is dependent on a parameter you pass to the JS bundle URL: Either &dev=true or &dev=false.

    Of course this is neither documented nor official, so your apps might break if you use this and it gets changed in a future release. Be careful.

  14. jeffbowen commented on May 5, 2016

    @jeffbowen
    Contributor

    Check out my Stack Overflow answer. If you are using custom configurations beyond the standard Debug and Release ones, such as Staging, and you're using Cocoapods, you need to specify in the Podfile that the Staging configuration is a debug configuration, not a release configuration. If unspecified, Cocoapods assumes other configurations are release configurations.

    At the top of your Podfile add this line:
    xcodeproj 'MyProject', 'Staging' => :debug

    If you're using Cocoapods 1.0, replace xcodeproj with project.

    To actually update the settings:

    rm -rf Pods/
    pod install

    Now your Staging configuration will behave like the Debug configuration as the DEBUG=1 preprocessor macro will be set on the Pods project (which is what RCT_DEV is based off of).

    It would be nice if a note about this could be put in the React Native documentation as it is common for iOS devs to have more configurations than just Debug and Release.

  15. ghost added a commit that references this issue on May 6, 2016
  16. philipshurpik commented on Aug 13, 2016

    @philipshurpik

    If you want to add new Staging configuration you can add line:
    "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)",
    in LIBRARY_SEARCH_PATHS for your new configuration in project.pbxproj file

    Just to remember - sometimes need to close and open XCode to see this changes.

    And build will be successful!

    That happens because build command put libraries into /Build/Products/Release-iphonesimulator/ folder
    And for your new configuration it searches libs into /Build/Products/Staging-iphonesimulator/ folder
    So can't find them and we need to declare library search path manually to point to release folder.

  17. locked as resolved and limited conversation to collaborators on Jul 22, 2018
  18. added
    Resolution: Locked
    on Jul 22, 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

    Resolution: Locked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions