react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Can't find ”RCTAssert.h” while compiling after freshly generated project on v0.10.0

Open bouk opened this issue 11 years ago • 22 comments

It seems there's an error in v0.10.0 that causes application generated with react-native init to not be compilable immediately. The fix is to open <AppName>.xcodeproj/project.pbxproj and find and replace any mention of "$(SRCROOT)/node_modules/react-native/React/**" with "$(SRCROOT)/../node_modules/react-native/React/**" (note the ..)

bouk avatar Aug 27 '15 01:08 bouk

Seem like you don't have node_modules installed under project directory. Run npm install inside you project folder.

"$(SRCROOT)/node_modules/react-native/React/**" seem fine to me if you have node_modules installed correctly under your project dir.

chirag04 avatar Aug 27 '15 01:08 chirag04

I am facing the same issue, and npm install doesn't do anything for me since 'react-native' was already installed.

Looking through the file, it seems that there are some path inconsistencies in the <AppName>.xcodeproj/project.pbxproj file as mentioned by the poster.

license2e avatar Aug 27 '15 01:08 license2e

And changing the paths as suggested fixes the issue..

license2e avatar Aug 27 '15 01:08 license2e

I think this is the file and it has the correct paths - https://github.com/facebook/react-native/blob/f0dd9fb358efb94fba4dd2ba74fb4910bd929056/local-cli/generator-ios/templates/xcodeproj/project.pbxproj.

nakulpathak3 avatar Aug 27 '15 01:08 nakulpathak3

Yeah, I was just looking at that, I am going to try generate a new react-native app and see if it has the correct paths.. Is there a generator step that changes that anywhere?

license2e avatar Aug 27 '15 01:08 license2e

Nope, same issue.. looking to see if that template is being manipulated somewhere downstream in terms of the SRCROOT path..

license2e avatar Aug 27 '15 01:08 license2e

I just generated a new project and seems like this is only a problem with tests. If i remove the testing code then the build works fine.

cc @ide

chirag04 avatar Aug 27 '15 02:08 chirag04

Can someone submit a PR to fix this? I'm about to take off on a flight right now and can take a look and publics 0.10.1 when I land in a few hours.

ide avatar Aug 27 '15 03:08 ide

I had the same problem. After trying a bit I just copied all the React/Base/ files into my iOS/appTests/. That solved the problem for me!

Let me know if that helps!

besarthoxhaj avatar Aug 27 '15 11:08 besarthoxhaj

The problem for me was that the Test Target had an incorrect Header Search Path. This can be fixed by going into xcode, selected the Test Target, going to build Settings, going into the section "Search Paths".

Inside this "Search Paths" section, there is a "Header Search Paths" attribute, select it and make sure there is a search path: $(SRCROOT)/../node_modules/react-native/React set to Recursive. MAKE SURE THE ".." is present after $(SRCROOT) or it will be looking in the wrong directory. MAKE SURE YOU'RE LOOKING IN THE TEST TARGET, NAMED {YOURAPP}Tests

screen shot 2015-08-27 at 9 41 44 am

brenmcnamara avatar Aug 27 '15 16:08 brenmcnamara

@brenmcnamara's fix worked for me

sghiassy avatar Aug 27 '15 18:08 sghiassy

This seems to have been introduced in 0.10 (e9f69bc2e4bff3aaff2f77268087c362916d3756), but fixed in 0.11rc with the move to yeoman (f83675d1915b5e77638c117c82f8641cea367ffe). Seems like we might want to fix this on the 0.10-stable branch and release 0.10.1, yes?

philikon avatar Aug 27 '15 23:08 philikon

Yes, that sounds good. @philikon are you able to test whether the yeoman commit fixes things?

ide avatar Aug 27 '15 23:08 ide

@ide yes, I just confirmed that it's fixed in master/0.11. But OMFGWTFSIGH we changed the format of the project again, this time from iOS/ to ios/ cc @a2 @foghina @mkonicek

philikon avatar Aug 28 '15 00:08 philikon

hey guys, how do i update to 0.11? i just got the same issue with correct search path set.. removing test code kind of solves this issue. but don't think that should be the solution. so, how do i fix it?

ghosTedBuddy avatar Aug 28 '15 05:08 ghosTedBuddy

Can confirm this happens on a completely fresh install—I installed react native for the first time ever, followed the instructions on Getting Started precisely and ran into this. And like @inselmensch the correct path (as proposed as a solution above) has already been set.

LukasBombach avatar Aug 28 '15 09:08 LukasBombach

I can also confirm it works on 0.11, and @philikon's fix looks good.

For anyone else stuck on this, @brenmcnamara's walkthrough for the Header Search Paths is the way to go.

j-mutter avatar Aug 28 '15 14:08 j-mutter

react-native 0.10.1 is now on npm with @philikon's diff. Let us know if things are working for you.

ide avatar Aug 28 '15 20:08 ide

@yorkie you may have a stale npm cache or be reading from a mirror. The npm repo has 0.10.1:

$ npm v react-native time | grep '0\.10\.1'
  '0.10.1': '2015-08-28T19:59:24.605Z' }

ide avatar Aug 29 '15 17:08 ide

@brenmcnamara Thank you, your solution help me to fix this. I do not know why in year 2018, this problem still occur :( so sad

LuongTruong avatar Jun 20 '18 10:06 LuongTruong