New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bleonard opened this Issue Aug 6, 2015 · 14 comments

Comments

Projects
None yet
@bleonard
Contributor

bleonard commented Aug 6, 2015

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?

@gre

This comment has been minimized.

Show comment
Hide comment
@gre

gre Aug 6, 2015

Contributor

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

Contributor

gre commented Aug 6, 2015

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

@bleonard

This comment has been minimized.

Show comment
Hide comment
@bleonard

bleonard Aug 9, 2015

Contributor

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;
  }
Contributor

bleonard commented 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.

  NSDictionary *passed = [[NSProcessInfo processInfo] environment];
  NSString *override = [passed valueForKey:@"OVERRIDE_ENV"];
  if (override) {
    envName = override;
  }

@brentvatne brentvatne changed the title from Project Config: Development / Release / Other? to [Project Config] Development / Release / Other? Aug 9, 2015

@brentvatne

This comment has been minimized.

Show comment
Hide comment
@brentvatne

brentvatne Aug 9, 2015

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 :)

Collaborator

brentvatne commented 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 :)

@brentvatne brentvatne closed this Aug 9, 2015

@bleonard

This comment has been minimized.

Show comment
Hide comment
@bleonard

bleonard Aug 9, 2015

Contributor

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

Contributor

bleonard commented 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 xcodebuild

@john-griffin

This comment has been minimized.

Show comment
Hide comment
@john-griffin

john-griffin Aug 10, 2015

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.

john-griffin commented Aug 10, 2015

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.

@bleonard

This comment has been minimized.

Show comment
Hide comment
@bleonard

bleonard Aug 12, 2015

Contributor

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.

Contributor

bleonard commented 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

This comment has been minimized.

Show comment
Hide comment
@pewallin

pewallin 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.

pewallin commented 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

This comment has been minimized.

Show comment
Hide comment
@aphillipo

aphillipo 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?

aphillipo commented 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

This comment has been minimized.

Show comment
Hide comment
@bleonard

bleonard Oct 19, 2015

Contributor

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.

Contributor

bleonard commented 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

This comment has been minimized.

Show comment
Hide comment
@jmreidy

jmreidy Nov 19, 2015

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

jmreidy commented Nov 19, 2015

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

@Zensaburou

This comment has been minimized.

Show comment
Hide comment
@Zensaburou

Zensaburou 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 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.

Zensaburou commented 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 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.

@JonnyBurger

This comment has been minimized.

Show comment
Hide comment
@JonnyBurger

JonnyBurger 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 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.

JonnyBurger commented 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 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.

@jeffbowen

This comment has been minimized.

Show comment
Hide comment
@jeffbowen

jeffbowen May 5, 2016

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.

Contributor

jeffbowen commented May 5, 2016

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.

ghost pushed a commit that referenced this issue May 6, 2016

Explain custom configuration debugging gotcha
Summary:
Debugging tools won't work if you're using a custom configuration and Cocoapods and didn't specify the configuration to be a `debug` configuration using the `xcodeproj` setting in your Podfile. When integrating React Native into an existing Xcode project, this is a common situation to encounter.

See #2246 (comment)
Closes #7407

Differential Revision: D3268032

fb-gh-sync-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355
fbshipit-source-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355

ptmt added a commit to ptmt/react-native that referenced this issue May 9, 2016

Explain custom configuration debugging gotcha
Summary:
Debugging tools won't work if you're using a custom configuration and Cocoapods and didn't specify the configuration to be a `debug` configuration using the `xcodeproj` setting in your Podfile. When integrating React Native into an existing Xcode project, this is a common situation to encounter.

See facebook#2246 (comment)
Closes facebook#7407

Differential Revision: D3268032

fb-gh-sync-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355
fbshipit-source-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355

zebulgar added a commit to nightingale/react-native that referenced this issue Jun 18, 2016

Explain custom configuration debugging gotcha
Summary:
Debugging tools won't work if you're using a custom configuration and Cocoapods and didn't specify the configuration to be a `debug` configuration using the `xcodeproj` setting in your Podfile. When integrating React Native into an existing Xcode project, this is a common situation to encounter.

See facebook#2246 (comment)
Closes facebook#7407

Differential Revision: D3268032

fb-gh-sync-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355
fbshipit-source-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355
@philipshurpik

This comment has been minimized.

Show comment
Hide comment
@philipshurpik

philipshurpik 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.

philipshurpik commented 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.

samerce added a commit to iodine/react-native that referenced this issue Aug 23, 2016

Explain custom configuration debugging gotcha
Summary:
Debugging tools won't work if you're using a custom configuration and Cocoapods and didn't specify the configuration to be a `debug` configuration using the `xcodeproj` setting in your Podfile. When integrating React Native into an existing Xcode project, this is a common situation to encounter.

See facebook#2246 (comment)
Closes facebook#7407

Differential Revision: D3268032

fb-gh-sync-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355
fbshipit-source-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355

mpretty-cyro pushed a commit to HomePass/react-native that referenced this issue Aug 25, 2016

Explain custom configuration debugging gotcha
Summary:
Debugging tools won't work if you're using a custom configuration and Cocoapods and didn't specify the configuration to be a `debug` configuration using the `xcodeproj` setting in your Podfile. When integrating React Native into an existing Xcode project, this is a common situation to encounter.

See facebook#2246 (comment)
Closes facebook#7407

Differential Revision: D3268032

fb-gh-sync-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355
fbshipit-source-id: f46c4a1f927128fd34c2f8ce4be4c275468f2355

@facebook facebook locked as resolved and limited conversation to collaborators Jul 22, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.