react-native: Cannot build react-native project with Xcode 9 server
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
yes
Environment
Environment: OS: macOS High Sierra 10.13.1 Node: 9.2.0 Yarn: Not Found npm: 5.5.1 Watchman: Not Found Xcode: Xcode 9.1 Build version 9B55 Android Studio: 2.3 AI-162.4069837
Packages: (wanted => installed) react: ^16.1.1 => 16.1.1 react-native: github:facebook/react-native#master => 1000.0.0
Steps to Reproduce
- Create a new project with react-native init
- Open the project in Xcode and verify that it will build locally.
- Setup a build bot on an Xcode server for the project and manually start an integration.
Expected Behavior
The project will build the same as it did locally.
Actual Behavior
The project fails with the following:
AppDelegate.m:12:9: fatal error: 'React/RCTBundleURLProvider.h' file not found
#import <React/RCTBundleURLProvider.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reproducible Demo
Any vanilla project created with react-native init will do.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (11 by maintainers)
@myusuf3 I haven’t written anything up on how to do it, but I’ve actually personally moved to using GoCD + fastlane instead of Xcode Server and it’s been working decently well. The big gotcha’s are
RCT_NO_LAUNCH_PACKAGER=yes
so metro server doesn’t start (but it will still bundle the resources), and making sure Facebook’s TeamID is removed from the React Xcode project files. I submitted a PR that appears to be slated for 0.58 that fixes the TeamID issue.If you can get fastlane to build under these two conditions it’s pretty easy to set up GoCD’s build environment to run fastlane.
The biggest caveat is when the app-specific password for your App Store Connect account expires and your build seemingly breaks for no reason. As a build server isn’t interactive fastlane will just hang forever; or at least I killed it before it reached any sort of time out (and it had been sitting in this state for very many minutes).
Maybe when I have some breathing room I’ll put something together on how I finally got automated builds to work with React Native ;D
@garethiv Funny you should ask; I actually got my project building last night. Here’s how:
The first thing you should know is about the un/under-documented environment variable
RCT_NO_LAUNCH_PACKAGER
which will disable metro bundler from launching when your project is built. You can set it to anything; if it exists then react won’t launch the bundler. If you’re curious, the setting is in theStart Packager
build phase of theReact
target inLibraries/React.xcodeproj
The next thing that is needed in order to get the bundler to work properly is to add node to the path before the script is called. The only reliable way I found to do this is to modify the
Bundle React Native code and images
build phase of your product’s target to append an environment variable to the end of path if that environment variable exists.Then when you create your bot you can set your environment variables:
Lastly add a pre-integration script for your bot. Something to keep in mind is that the default folder you get dropped in is the folder your repository is checked out into. So the first thing you need to do is to
cd
into the name git clone will create, indicated in the screenshot as<repo-name>
. Then perform npm install and anything else you need to do. Note: although I am using cocoapods for some libraries here, cocoapods does not build or link React Native as it will clash with the existingReact.xcodeproj
insideLibraries
.Hopefully facebook/react-native-website#370 will clear some of this stuff up.
P.S. I should also mention #16881. In your pre-build script you might want to grep and remove facebook’s team id from the
react-native
project or xcode might yell at you. I’ve actually just forked the repo and removed the team id from my master branch so I don’t have to grep on every new computer/server I setup.May be switch to cocoapods will behave better 😉