question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot build react-native project with Xcode 9 server

See original GitHub issue

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

  1. Create a new project with react-native init
  2. Open the project in Xcode and verify that it will build locally.
  3. 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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Rojuinexcommented, Oct 4, 2018

@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

1reaction
Rojuinexcommented, Jul 5, 2018

@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 the Start Packager build phase of the React target in Libraries/React.xcodeproj

screen shot 2018-07-05 at 09 55 25

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.

screen shot 2018-07-05 at 10 00 02

Then when you create your bot you can set your environment variables:

screen shot 2018-07-05 at 09 51 34

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 existing React.xcodeproj inside Libraries.

screen shot 2018-07-05 at 10 01 21

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native project (Could not connect to Development server)
You can try: react-native start --port=8088 . Then run react-native run-ios --port=8088 in a different Terminal window to get the iOS app ......
Read more >
Troubleshooting - React Native
You will also need to update your applications to load the JavaScript bundle from the new port. If running on device from Xcode,...
Read more >
Xcode for React Native developers: Tutorial and best practices
Walk through some of the best practices to help you get started using Xcode, an IDE and code editor created by Apple.
Read more >
React-Native project (Could not connect to Development server)
Run yarn start in your project root, then open http://localhost:8081/debugger-ui and see if the page loads. If the page doesn't load, then your...
Read more >
Error in building ReactNative videoSDK sample code (IOS ...
error Failed to install the app. Make sure you have the Android development environment set up: Setting up the development environment · React...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found