You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Project Config] Development / Release / Other? #2246
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?
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.
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 :)
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
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.
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.
Reacted by Rafael Mendiola, Mitch Crowe, Hagen Hübel and Inga Jonsdottir
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.
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.
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
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.
Reacted by Yifan Zhu, Felipe Torres (fforres) and Michael Ford
ghost added a commit that references this issue on May 6, 2016
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.
Reacted by Joe Tannenbaum, Lauri Lehmijoki, Sirui Li, Jonathan Dierckens, Felipe Torres (fforres), Alvin Lao and Eric Schulte
Activity
gre commentedon Aug 6, 2015
this is a first step: #2101 but I think having multiple "target" would be great
bleonard commentedon Aug 9, 2015
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.
[-]Project Config: Development / Release / Other?[/-][+][Project Config] Development / Release / Other?[/+]brentvatne commentedon Aug 9, 2015
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 :)
bleonard commentedon Aug 9, 2015
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
xcodebuildjohn-griffin commentedon Aug 10, 2015
I hit this when creating new targets. The names don't match to
DebugorReleaseso despite settingRCT_DEBUGit does not get used.bleonard commentedon Aug 12, 2015
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.
pewallin commentedon Sep 4, 2015
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.
aphillipo commentedon Oct 5, 2015
Yes there should be better control over this stuff and config files by default. How do i pass targets/build settings to JS effectively?
bleonard commentedon Oct 19, 2015
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.
jmreidy commentedon Nov 19, 2015
+1 for multiple targets, allowing per-environment configurations. Right now builds fail with anything other than DEBUG and RELEASE targets.
Zensaburou commentedon Feb 24, 2016
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
debuggradle build inbuild.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.JonnyBurger commentedon Mar 5, 2016
Some people here might find it useful to know that there is a
global.__DEV__variable exposed to the Javascript bundle which can betrueorfalse. It is dependent on a parameter you pass to the JS bundle URL: Either&dev=trueor&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.
jeffbowen commentedon May 5, 2016
Check out my Stack Overflow answer. If you are using custom configurations beyond the standard
DebugandReleaseones, such asStaging, and you're using Cocoapods, you need to specify in the Podfile that theStagingconfiguration is adebugconfiguration, not areleaseconfiguration. If unspecified, Cocoapods assumes other configurations arereleaseconfigurations.At the top of your Podfile add this line:
xcodeproj 'MyProject', 'Staging' => :debugIf you're using Cocoapods 1.0, replace
xcodeprojwithproject.To actually update the settings:
rm -rf Pods/pod installNow your
Stagingconfiguration will behave like theDebugconfiguration as theDEBUG=1preprocessor macro will be set on the Pods project (which is whatRCT_DEVis 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
DebugandRelease.Explain custom configuration debugging gotcha
Explain custom configuration debugging gotcha
Explain custom configuration debugging gotcha
philipshurpik commentedon Aug 13, 2016
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.