-
Notifications
You must be signed in to change notification settings - Fork 659
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
Not working with RN 0.60.4 #365
Comments
You are using react-native-config from npmjs, try to use this librairy directly from github |
I ended up using this specific commit and then I didn't need the post-install scripts mentioned in other issues |
@Elvinra that worked for me!! Another fix, if you install with npmjs, then post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-config'
phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
phase.shell_script = "cd ../../"\
" && RNC_ROOT=./node_modules/react-native-config/"\
" && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
" && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"
target.build_phases << phase
target.build_phases.move(phase,0)
end
end
end
|
@Elvinra we can also work but clean and rebulding issues causes back again Nevermind, just found out that this repo is updated but not published to npm. Then you can run pod install without issue. Still I don't understand why the npm version is not updated anymore. |
Credit goes to @bockc here prscX/react-native-toasty#12 (comment) |
I need help! I've try @dineshmm23's solution but I'm still getting this error: ruby: No such file or directory -- ./node_modules/react-native-config//ios/ReactNativeConfig/BuildDotenvConfig.ruby (LoadError) Command PhaseScriptExecution failed with a nonzero exit code |
@fariasmark Are you missing the script? What version of The error that you reported is not the same as the original issue so you may want to open your own issue |
@fariasmark just follow these steps:
then go to post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-config'
phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
phase.shell_script = "cd ../../"\
" && RNC_ROOT=./node_modules/react-native-config/"\
" && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
" && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"
target.build_phases << phase
target.build_phases.move(phase,0)
end
end
end then run now run |
@fariasmark Try replacing |
Here is the guide for some poor soul javascript dev like me out there:
On the side note, the |
@s123121 I've done everything that you said. What does your
Not sure if i'm following the instruction correctly for when I want my configs in info.plist |
I'm also having some trouble with getting RN0.60.4 to work with this library. I get an error in the preprocessing Info.plist
It seems like there's so many different fixes each for different versions and if people have multiple envs. Can we get some way of version controlling each solution and have an updated example. (it's currently at RN50). Perhaps just having a proper example for each version will alleviate all the issues popping up because this library doesn't work with this version. |
@s123121 thank you alot |
@ninjz you are correct remember that choose your target for Provide build settings form |
@rexhuynh Thanks so much that seemed to solve my issue |
@rexhuynh you save my day |
Thanks. It works |
What I'm doing for RN 0.60.4 (Upgraded from 0.59.9) is basically
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-config'
phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
phase.shell_script = "cd ../../"\
" && RNC_ROOT=./node_modules/react-native-config/"\
" && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
" && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb"
target.build_phases << phase
target.build_phases.move(phase,0)
end
end
end
But I'm getting this now, anyone knows why?
|
@kdenz if remove script from Podfile it tun with |
@Mlobaievskyi That's so wierd lol
|
Found solution
|
Can't seem to get this running either. Followed various options from above and none have worked. Got the same error as @kdenz when I tried his one. I'll see if I can get it going with a react-native init and see if I can figure out what's going on from there. |
This behavior seems to be extremely inconsistent. Everything was working fine for me. Then I deleted the build folder, tried to build again, and this error came back. Then I unlinked the library And everything stated working again. Podfile does have the solution provided by @ravimaurya-nickelfox . |
What worked for me now on 0.60.4, inspired by @Mlobaievskyi and @s123121 -
and the line Then I was getting |
THIS WORKS!!!!!!!!!!!! |
Do not trust the latest README.
|
This has worked for me correctly |
Can we have a new release from |
I've changed the below configs in "Build Settings" of project
and it worked |
@mehdihz npm version? |
@ravimaurya-nickelfox You're the best ! :D |
Sorry for late answer. My npm version: |
I was beating my head at this for the better part of a day. Everything worked fine with little to no intervention on react 0.57 for me, moving to 0.60+ was a ball! In any case what I needed was the following:
react-native-config did 1 and 2 for me, but for 3, I needed to use react-native-dotenv. Now my issue could be that these both read/write to /tmp/envfile but in essence this should not be an issue because you basically only want one .env.XYZ file to be consumed on any one build. For 1, I needed only to import the Config variable and use as needed. Between builds I need to rebuild since this is passed through the binary. For 2, I needed to do some acrobatics and to stand on my head a bit. Basically the documentation seems to have changed and you no longer should be using the prefix __RN_CONFIG_VARNAME but instead $(VARNAME) only. Here also you need to make sure that your xcconfig file references the tmp.xcconfig file which should be generated by an early build phase step that you have to create
When I ran this command in terminal alone I noticed that it generated an empty tmp.xcconfig which was simply because I had not created a /tmp/envfile. Now my scheme build pre-action does this:
So it's not that the build doesn't have a /tmp/envfile to work with...at this point I figured it must have been deleted somewhere in the series of scripts running. Reviewing the build logs when I had issues with vars not making it into the package, I noticed a subtle message: *** Missing .env file **** In the same log I noted that a previous run of BuildXCConfig.rb had no issues. Reviewing BuildXCConfig I realized that the last step deletes the /tmp/envfile...which of course was the crux of the problem, at least for my specific issue, I've create a pull request here for this: #404 The additional step needed for 2 to work properly is to make sure that your Project->Info->Configurations configured file (for me Pods-Project-Prod.xcconfig) calls
at the top. Note this gets stamped any time you do a pod install so we'd need a post_install step to put it back in. For 3 I still can't find a very clean way of doing this for xcode. At present you need the scheme build pre-action to create the /tmp/dotenv file, but to pass ENVFILE to the bundler, I basically had to modify the node_modules/react-native/scripts/node-binary.sh and add the export there:
In React < 0.60 I could add this bit to the React.xproj packager build phase, however with React > 0.60 the logic of the scripts have changed. Edit As per the note above here is a post install to configure the xcconfig file
Edit 2 you can add the packager ENVFILE option to the node launch script using a post install in your package.json:
and
|
post_install do |installer| After running, it can be used by using acts-native run-ios, but after deleting ipa, the edit config is empty |
Clear xcode cache with shift + option + cmd + k |
I just upgraded my React Native version to 0.61.4 and react-native-config ^0.12.0. @kdenz solution worked for me. |
I had to replace that last line with:
|
Thank you! @tmaly1980 |
FYI on RN 0.61.2: In addition to #365 (comment) when using |
For me, the problem was that ProjectTests target had the Preprocessor Prefix File set the same as the project, and it should be empty. Otherwise, It worked only with the steps in the documentation. react-native 0.60.5 |
Is there a solution without having to add code to Podfile ? |
If you are using Pods just add (without
|
I got .env value in AppDelegate.m "react-native": "0.61.5" can anyone help me. (Please share steps) Thanks |
I was getting the "ld: library not found for -lReactNativeConfig" error after switching over to CocoaPods. I removed ReactNativeConfig from the Libraries folder, but forgot to clean up "Link Binary with Libraries" under Build Phases. |
The error is the shell script is referencing a wrong path with the wrong filename I had to edit 2 files:
|
I'm using react-native-config 1.4.1 and was running into the empty object problem on ios so I added a new run script within Build Phases and got the config correctly populated as expected: Update: cd "$SRCROOT/../"
RNC_ROOT_DIR=$(pwd)
cd -
echo "Setting env for configuration: ${CONFIGURATION} with root dir: ${RNC_ROOT_DIR}"
if [ "${CONFIGURATION}" = "Release" ]; then
echo "$RNC_ROOT_DIR/.env.production" > /tmp/envfile
"$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.rb" "$RNC_ROOT_DIR/.env.production" "$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig"
else
echo "$RNC_ROOT_DIR/.env.development" > /tmp/envfile
"$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig/BuildDotenvConfig.rb" "$RNC_ROOT_DIR/.env.development" "$RNC_ROOT_DIR/node_modules/react-native-config/ios/ReactNativeConfig"
fi Create a new run script and paste the above in there. Update your .env files within the script above accordingly. I'm using In order to change between debug and release builds you can go to "Edit schemes" for your target: And select between the 2 builds: The next build and run of your app should contain the contents between your various env files. |
this should be /open |
Thanks!! |
The library is not working with
RN 0.60.4
, automatic linking is not working. If I try to link manually, it throws errors. Onpod install
it produces error'GeneratedDotEnv.m' file not found
.Any help? 🆘
The text was updated successfully, but these errors were encountered: