Skip to content
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

Cannot build react-native project with Xcode 9 server #16850

Closed
Rojuinex opened this issue Nov 16, 2017 · 19 comments
Closed

Cannot build react-native project with Xcode 9 server #16850

Rojuinex opened this issue Nov 16, 2017 · 19 comments
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@Rojuinex
Copy link
Contributor

Rojuinex commented Nov 16, 2017

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.

@RenderCoder
Copy link

I have the same problem for xcodebuild command. But Xcode 9 run build success.

@povloid
Copy link

povloid commented Nov 19, 2017

I have to and XCode run and build successfully. After first buil the red message dissapiar

@Rojuinex
Copy link
Contributor Author

Surprisingly I can build with xcodebuild just fine. This lead me to create a custom make build target to run xcodebuild to see if that got it to work. It did not. For some reason running on ccode build server causes it not to reference the React project for includes. I do have some ideas and will post when I’ve tried them out.

@Rojuinex
Copy link
Contributor Author

Nothing I have tried has worked. It cannot resolve the React/ dependencies. Looking at the project structure, I don't see any headers under a "React" folder. They all seem to be in sub folders. I'm not sure what the major difference is between running on a build server vs running in the editor but I really don't want to have to trigger builds manually. Sort of breaks CI.

@myusuf3
Copy link
Contributor

myusuf3 commented Nov 27, 2017

i am running into the same scenario. Would love to chat, maybe we can debug this. I have everything else working but the react native dependency cannot be found.

@Rojuinex
Copy link
Contributor Author

Rojuinex commented Nov 28, 2017

Yeah that is also what I am seeing. I can't figure out why. I'd love to chat :) hit me up at my username at gmail dot com

@TStrauch
Copy link

Have you found a way around this?

@Rojuinex
Copy link
Contributor Author

@TStrauch Not yet. Still digging around. I feel like it probably has to do with this new parallel build stuff in Xcode. I've notice it doesn't seem to save to the project file. This might not be the issue, but I've seen similar errors when parallel builds are turned on.

@vovkasm
Copy link
Contributor

vovkasm commented Jan 16, 2018

May be switch to cocoapods will behave better ;-)

@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Mar 9, 2018
@eyecats
Copy link

eyecats commented May 22, 2018

I'm also running into this issue where my CI XCode Server bot cannot resolve the React dependencies and fails at the first header file found in AppDelegate.m. Building/Archiving manually with the same scheme works perfectly. Anyone find a solution to this?

@myusuf3
Copy link
Contributor

myusuf3 commented May 23, 2018

I have kind of given up on this I spent half a day with no one having any progress. I would love to see what people come up with. I am sure the ci builds for react native have some solutions.

@Rojuinex
Copy link
Contributor Author

To be honest, I've found that if you manually link react native, following the add to an existing project steps, the metro garbage doesn't run and you can get it to a point where I think, haven't tested, it would build with an integration system. Honestly at this point I'm finishing up the projects that I have in react native and going back to programming in pure native code. I just can't rely on react native as a viable solution at this point.

@ga-reth
Copy link

ga-reth commented Jul 5, 2018

+1
Any progress on solving this issue?

Begun appearing for me today and cannot get rid of it. Tried all suggestions here https://github.com/facebook/react-native/issues/12077 but no luck. react-native init new project, build in XCode and error persists.

@Rojuinex
Copy link
Contributor Author

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

@stale
Copy link

stale bot commented Oct 3, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 3, 2018
@myusuf3
Copy link
Contributor

myusuf3 commented Oct 3, 2018

so @Rojuinex did you write up anything on how to get this setup or links to help get it going. I gave up but would love to have this work.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 3, 2018
@Rojuinex
Copy link
Contributor Author

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

@stale
Copy link

stale bot commented Jan 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 2, 2019
@stale
Copy link

stale bot commented Jan 20, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jan 20, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

9 participants