Reputation: 1069
I have a react native project I'm building with xcode. There are two targets I build for, one for staging, and one for production. And I'm managing some variables in xcode, using the 'User-Defined' section under 'Build Settings' on my various build targets.
My question is... how do I access this data from within my js in my react native app?
Upvotes: 4
Views: 1102
Reputation: 13396
Add a new entry to your Info.plist with $(YOUR_USER_DEFINED_VALUE)
as its value. This will be replaced with the targets configured value during the build.
In AppDelegate
NSDictionary* info = [[NSBundle mainBundle] infoDictionary];
NSDictionary *initialProps = @{@"yourValue" : [info valueForKey:@"NAME_IN_PLIST"]};
...
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"AppName"
initialProperties:initialProps
launchOptions:launchOptions];
Upvotes: 1