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

[??] iOS does not build when using latest XCode #159

Closed
chrisgbaker opened this issue Sep 23, 2019 · 15 comments
Closed

[??] iOS does not build when using latest XCode #159

chrisgbaker opened this issue Sep 23, 2019 · 15 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@chrisgbaker
Copy link

Steps to Reproduce

  • Install the latest version of XCode
  • run create-react-native-module MyModule --generate-example
  • cd react-native-my-module
  • npm i (or yarn)
  • Open the project via XCode (via the .xcodeproj file)
  • Clean the build folder
  • Target a simulator, and run a build. (Not sure if targeting a simulator would matter, but just so I'm not leaving anything out)

Expected

  • The project can build

Actual

  • The project fails to build, as it cannot find a reference to <React/RCTBridgeModule.h>

The odd part about this is that step two listed above worked, and had made several local projects until about 2-3pm today. Now, when a new project is scaffolded, there are zero connected/linked Frameworks, and the build for the module instantly fails. However, Android builds just fine. This was also tried on two different macbook pros, running 10.14.6 On the machine that had not globally installed create-react-native-module until after this issue arose, iOS builds have never worked. This feels too strange given that iOS13 was released today, but I'm not certain it's related, considering I'm not trying to run the example on a device, but simply build the main, generated module. Also, FWIW, the generated example project will build.

Let me know if I can provide any more information! And thanks for the work you've done! When this was working this morning, it definitely saved a lot of time in getting a native module spun up.

@brodycj brodycj added help wanted Extra attention is needed info-needed labels Sep 24, 2019
@brodycj
Copy link
Owner

brodycj commented Sep 24, 2019

Here is what I generally do:

  • run create-react-native-module --generate-example my-module (I generally use nonsense names for "my-module"), which would result in node_modules already installed by Yarn in the generated example project
  • cd react-native-my-module/example
  • open the .xcworkspace in the ios subdirectory of the example project and run from Xcode
  • or do react-native run-ios which will build and run the example on an iOS simulator

I think there are some differences, major is installing node_modules in example subdirectory or not.

I would like to try some more cases out to better understand issues like this, cannot make any promises right now due to some other priorities. The react-native build system seems to be quite a bit sensitive, argh!

@chrisgbaker
Copy link
Author

So after doing a clean install this morning of XCode, and insuring I was using the latest react-native via updating both react-native-cli@latest and react-native@latest this is working again. Feel free to close the issue if you want. I'm not sure what is different, but it's fine for now, ha.

@brodycj brodycj self-assigned this Sep 24, 2019
@brodycj brodycj removed help wanted Extra attention is needed info-needed labels Sep 24, 2019
@brodycj
Copy link
Owner

brodycj commented Sep 24, 2019

Thanks @chrisgbaker for the confirmation. I would like to do some more testing myself and maybe get this documented before closing.

@jordanboaz
Copy link

I am having the same issue. I have spent a whole day trying to figure out what is it.

I will be doing the same as you: reinstalling XCode and see what I can get.

@brodycj brodycj changed the title iOS does not build when using latest XCode [??] iOS does not build when using latest XCode Sep 26, 2019
@brodycj brodycj added bug Something isn't working help wanted Extra attention is needed labels Sep 26, 2019
@brodycj brodycj pinned this issue Sep 26, 2019
@brodycj
Copy link
Owner

brodycj commented Sep 26, 2019

This issue is now pinned as a bug for further investigation, with help wanted. I cannot promise when I can investigate due to some other commitments and priorities. Thanks guys for the input so far.

@willhoney7
Copy link

I am having the same issue but sadly don't have any more reproduction details to share.

Using xcode 11. I created a module using create-react-native-module my-module and then followed the readme steps to add it manually.

@willhoney7
Copy link

I've figured out a fix! Wix's guide here is where I saw it: https://medium.com/wix-engineering/creating-a-native-module-in-react-native-93bab0123e46

You need to add node_modules/react-native/React.xcodeproject to the "Link Binary with Libraries" section in the build phases of the react-native-module you've created.

(I'm not sure the code fix for this library, but this is how to fix it as a user)

Screen Shot 2019-10-04 at 1 36 06 PM

@usrbowe
Copy link

usrbowe commented Oct 9, 2019

@Tibfib I don't think this fix works anymore as latest RN 0.61.2 removed the React.xcodeproj.
https://facebook.github.io/react-native/blog/#breaking-changes

@brodybits It would be good to upgrade to latest RN version for template, which introduces this bug and preventing from building the app


Tried to build other native modules for RN (community one) and all failed in XCode 11.2. So I guess standalone building is broken, because when included in my RN app it works.


I finally find a solution, had to upgrade some 3rd party libs to use podspec and cleanup Xcode project of search_headers and linked xcodeproj in Libraries. Write it down in more details here: facebook/react-native#26678 (comment)

@brodycj
Copy link
Owner

brodycj commented Oct 16, 2019

Thanks to all for your comments and continued patience.

I generally do not support manual installation and would consider this to be a temporary workaround solution.

It would be good to upgrade to latest RN version for template

That is already tracked in a checklist in #93, with some other linked issues. The major blocker is to fix the generated iOS example, as discussed in #99.

Unfortunately my mac is still not back from repair.

@ottoo
Copy link

ottoo commented Oct 29, 2019

I've had these header search path issues with other react-native packages as well such as here apptentive/apptentive-react-native#78.

The reason for the breaking is that since RN 0.60 (or 0.61), they changed the paths of the headers in in the react-native repository and affecting also the /Pods folder if using CocoaPods.

They used to be under React, but now they are under separate packages in node_modules/react-native and Pods, for example under Pods/Headers/Public/React-Core. For the above mentioned package the solution was to add a header path point to the new folder. Though I am atm in process of fixing another package and cannot seem to get it to work..

@renenielsendk
Copy link

Any timeline on a fix or smth?

@demchenkoalex
Copy link

demchenkoalex commented Nov 17, 2019

Hi everyone,

I have encountered the same issue not only here, but in a bunch of different RN libraries also. I needed a template for the library written in TypeScript with a working example, so I created one from scratch, which is successfully working with the latest RN version (0.61.4 atm).

To link the iOS project to the example I did two things:

  1. In the library's iOS project I have added this HEADER_SEARCH_PATHS
"$(inherited)",
"$(SRCROOT)/../example/ios/Pods/Headers/Public/React-Core",
"$(SRCROOT)/../../../ios/Pods/Headers/Public/React-Core",

where $(SRCROOT)/../example/ios/Pods/Headers/Public/React-Core pointing to the example's React headers so Xcode can see imports like #import <React/RCTBridgeModule.h> (ofc you need to do pod install in the example)
and $(SRCROOT)/../../../ios/Pods/Headers/Public/React-Core will be used to search for the React headers when somebody installs your library from npm.

  1. For the example project I used classic manual linking see this comment above or RN documentation and additionally I have added $(SRCROOT)/../../ios to the example's iOS project HEADER_SEARCH_PATHS so the example will see your library's headers.

I guess this solution will not work below 0.61.2, but in my case, I wanted to support only the latest version.

You can check the whole implementation here https://github.com/demchenkoalex/react-native-module-template.

@brodycj
Copy link
Owner

brodycj commented Nov 21, 2019

I will still probably need some more time to sort this out. A couple ideas I have right now:

@taylorkline
Copy link

taylorkline commented Jan 23, 2020

The following may work for you:

From the module's folder, run yarn (or npm i) to populate node_modules/.

xed ios/ to open up the iOS directory in XCode.

Now we want to change the scheme from the default selection of MyModuleName to React. Product -> Scheme -> React. You should be able to build without error at this point.

I also added this very same solution to this StackOverflow issue about "'React/RCTBridgeModule.h' file not found" messages from XCode.

This solution does not involve modifying any files. My git status shows no changed files after modifying the scheme in XCode.

@brodycj
Copy link
Owner

brodycj commented Feb 13, 2020

I have updated this utility to work with React Native 0.61 and have tested the generated example on iOS in the following scenarios:

  • from the command line, using react-native run-ios
  • from updated Xcode, by opening ios/example.xcworkspace in the generated example

I am now closing this issue. In case of any further problems a new issue would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

9 participants