React-native Xcode build fails -> 'RCTAssert.h file not found' - react-native

I did exactly the steps which are described here in the React-native getting started guide:
https://facebook.github.io/react-native/docs/getting-started.html
When I open the Project and build it, the build fails:
RCTAssert.h file not found' in MyProjectNameTests.m .
What am I missing?
Here are the steps from the getting started guide:
Requirements
OS X - This repo only contains the iOS (7+) implementation right now,
and Xcode only runs on Mac.
Xcode 6.3 or higher is recommended.
Homebrew is the recommended way to install io.js, watchman, and flow.
Install io.js 1.0 or newer. io.js is the modern version of Node.
Install nvm with its setup instructions here. Then run nvm install
iojs-v2 && nvm alias default iojs-v2, which installs the latest
compatible version of io.js and sets up your terminal so that typing
node runs io.js. With nvm you can install multiple versions of Node
and io.js and easily switch between them.
New to npm?
brew install watchman. We recommend installing watchman, otherwise
you might hit a node file watching bug.
brew install flow. If you want to use flow. We recommend
periodically running brew update && brew upgrade to keep your
programs up-to-date.
Quick Start
npm install -g react-native-cli
react-native init AwesomeProject
In the newly created folder AwesomeProject/
Open AwesomeProject. xcodeproj and hit run in Xcode. Open index.ios.js
in your text editor of choice and edit some lines. Hit cmd+R in your
iOS simulator to reload the app and see your change!

The test application can't find the header because it's not in the header search path.
In the left hand file list, hit the top left "folder" icon, then select your application at top left. In this case "AwesomeProject".
To the right of that, where the application icon appears, hold down to change to AwesomeProjectTests.
On the right side, click on the 'Build settings' tab.
Then scroll down to Header Search Paths and change "$(SRCROOT)/node_modules/react-native/React" to "$(SRCROOT)/../node_modules/react-native/React".
The app should now compile.

I got the same issue as daniel but I already have the right path in xcode ...
0.10.0 is my version

It's an issue in 0.10.0, and it has been fixed just now.
You need to re-generate your project. Refer to this PR: https://github.com/facebook/react-native/pull/2474

seeing same issue here and it seems react-native is latest on 0.10.0, i was using 0.8.0 and was running fine. May be to disable the test target for now?

Before testing any option from the above mentioned solutions, just clean your xCode and build the app again. That helped me

I had the same issue (I just had changed my apple ID password). I needed to redo the code signing configuration.

This happened to me on a React Native project.
I rolled back my code to a version that I knew built successfully and still got this error. How is this even possible? There's two hours of my life I'll never get back. I write this here on the chance I save you from the same fate.
In my case when I jump from my IDE in which I code my react-native project over to Xcode I open it from Spotlight.
At this point it is so easy to click the wrong icon on the right hand side. I accidentally clicked on the Xcodeproj file instead of the Xcworkspace. Easy to do, once it loads everything looks exactly the same, I was none the wiser.
The only indication that something had gone wrong was the build errors. Worse this error looks like a dependency management issue sending you down completely the wrong path in a resolution attempt.
This is not just a React Native specific issue, but something all Cocoapod users need to remember.

ADD the React Path to Podfile
platform :ios, '9.0'
target 'YourProject' do
...
pod 'React', :path => '../node_modules/react-native'
end
target 'RNFirebaseTests' do
...
pod 'React', :path => '../node_modules/react-native'
end

Related

How to install react-native cli packages with "pod install" vs "linking manually"

I am new to react native. I uses the Cli version. I installed some packages e.g. react-navigation. After the installation I open the ios folder and run pod install. It works fine, but with react-native-vector-icons I have to link it manually like this: react-native link react-native-vector-icons. And I don't have to run pod install. But what if I want to install additional packages after that like sqlite? For this package i have to run pod install. Do I have to reinstall the vector icons after every other package installation? I am new to react-native and I don't now much about "pod install", "linking" and so on. So please give me a bit more details on how to work with adding new packages with this special task.
Many thanks
Jens
Since react-native 0.60 linking is no longer required since it is managed by react-native itself, remember that react-native is something like a "controller" in javascript that sends commands to native code in iOS and Android, pod install is the way you install the iOS native components required by your react-native libraries, something like npm install but for iOS.
react-native-vector-icons has its own iOS libraries, so it requires to run pod install(you should run a pod install everytime you add a new library, eventually you'll understand when you need to run it and when not). There's no harm in running several times pod install so don't worry about it. Also for react-native-vector-icons if I'm not mistaken, you also have to modify info.plist in order to have all the typographies available (This is the "hard" part about this library, it has additional typographies that should be embeded in your project)

How fix react-native global.BlobBuilder error?

I have reloaded my mac and get that error:
After dismissed that:
react#16.3.2
react-native#0.55.4
babel-preset-react-native#4.0.0
package.json
Can you tell me what can I do and what is this error?
Ok that was long road to fix this issue, short long story:
Unlink all packages, uninstall pods, upgrade react-native by react-native-git-upgrade and rn-diff, check major changes in other rn-packages, use new pods for rn > 0.47, link packages and install pods.
If you get stuck with .xcodeproj or your xcode crash when you open project - reset your .xcodeproj by rn-diff (or clear project) and start again.
use kin for lint xcode project
I think that issue was because i missed new pods

cannot create iOS folder on my react native app

I am asking this question for the third time and I don't get it why no one even tries to help on this, is this question not well explained? If you can ask for more information I can give!
I am having trouble created iOS folder inside my react native app(detached) as when I created the app I created it from windows machine and iOS folder didn't come when I wrote: exp detach
Now that I have got a macOS, how can I get to create iOS folder so I can use that to build from xCode. I tried react-native upgrade, this is telling me that I have some version conflicts, so I don't want to upgrade it actually, I just want to have iOS folder on my react native.
What would be the best solution in here?
Interestingly I tried exp detach over my detached app and it created iOS, it's working! hopefully this will help anyone!
Please follow the below steps:
Step I: Ensure below installable are installed
Java Sdk Android Studio
Xcode (in case of OSX)
HomeBrew (in case of OSX to install node)
Node/NPM (Node runs Javascript outside the browser. NPM is used for installing and managing Dependencies. Node and NPM come
together)
Those are some essential installs that you will need in your Project
**Step II: **
For windows/OSX you need to run the following commands in your command prompt/command line:
This is the important part for running a react native project:
**Step II: **
npm install -g react-native-cli
Then you can use this cli to start a new project like this:
**Step III: **
react-native init
Hope this helped you, please vote..

React Native IOS Build CFBundleIdentifier Does not Exist

I have create sample React Native project and following the tutorial as per react native website.
I have try to run the application IOS simulator, its throwing error as below ,
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Install\ Third\ Party /Users/Test/Documents/REACTJS/SampleReactNative/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/SampleReactNative.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/SampleReactNative.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
my environment setup information,
node version v9.8.0 npm version 5.6.0 react-native-cli: 2.0.1
react-native: 0.54.2 xcode 9.2
Please help us to resolve the issues.
I have the same problem right after init:
react-native init myapp
cd myapp
react-native run-ios
..although run-android was fine.
Not a solution but a workaround for the moment, maybe be to init using a lower version of RN:
react-native init myapp --version react-native#0.51.0
That builds okay.
Similar in an existing project, install an older version of RN.
Other versions before 0.54.2 might work but I haven't tried.
(edited 2018/4/2)
Found my solution from this link: https://github.com/facebook/react-native/issues/18238
RN 0.54 requires types available since iOS 11. So you have to upgrade your xcode and set minimum iOS version in your app to 11
In short, upgraded OSX & Xcode to the latest. (As of today, OSX 10.13.4 Xcode & 9.3)
This may happen because of some library files not found.You need to follow some steps That I have done and it is worked perfectly for me.
1.) go to Xcode project -> Target -> select build Phase -> Go to target dependies -> Click on + -> add "react" and press add.
2.) Xcode > Product -> scheme > manage sceme -> click on + button -> targetName(React) -> Okay -> make shared of this by select checkbox under shared column.
3.) Clean your project and try to build, If it is getting some error like "glog/logging.h file not found" or "cofig.h file not found" in Xcode and "CFBundleIdentifier not exist" then do not worry. You are just one step far. This is may occurs if you are missing config.h file, For this you need to update config.h file. For this
4.) follow below steps
a.) close your Xcode
b.) Open terminal with the project (Or you can directly left click your project and drag your folder to closed terminal, [It will automatically take the path from your that corresponding folder])
c.) write command
cd node_modules/react-native/third-party/glog-0.3.4/
d.) Run the configure scripted file by the command
./configure
e.) now close terminal and go to terminal with your project root path. now try final run your iOS project by
react-native run-ios
For XCODE 10.0,
I did two things
1) check out this answer
which basically says
Go to File -> Project settings
Click the Advanced button
Select "Custom" and select "Relative to Workspace" in the pull down
Change "Build/Products" to "build/Build/Products"
2) If (1) doesn't work for you then open your project from xcode
go to project navigator and select your project name --> go to info --> use debug for command-lines builds.
do this
3) go to terminal and react-native run-ios
Run the command:
react-native upgrade
react-native run-ios
or:
react-native run-android
Try to add CFBundleIdentifier in the Info.plist as:
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
I experienced this issue due to the xcode 12 upgrade, and I solved my problem by upgrading my rn by using this command:
react-native upgrade
then go to podfile change your:
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
to:
pod 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"
Do you have CFBundleIdentifier in your Info.plist?
If not than add it for eg. com.ios.learning
Usually, this error comes up due to inconsistent versions (either of react-native, OS or XCode). I had the same issue with react-native v0.57.0 on MacOS Sierra and XCode v9.x.
All I had to do was to upgrade to High Sierra and then XCode to v10.0.
Otherwise, you'd have to use an older version of react-native either by downgrading it
or by initialising a project with an older version
react-native init test --version react-native#0.x.x
In my case, just delete the build directory, Pods directory, node_modules directory and running yarn install, pod install and npx react-native run-ios solves the issue.
React Native is trying to install your app on a different app name for some reason. What you can do is in Xcode --> build settings --> packaging --> change the product name to the one given in the path which the simulator is trying to install.
Look at this: https://amala-gopal.medium.com/entry-cfbundleidentifier-does-not-exist-6098b90516f6
npm uninstall react-native
delete ios and android folder
then run :
npm install react-native
react-native upgrade

Best way to upgrade react-native project

I have a question about upgrading react-native version.
We have some choices to upgrade but I don't know differences.
1) react-native upgrade
2) react-native-git-upgrade
3) npm install react-native#latest --save then react-native run-android or react-native run-ios
I used third way for my project because I need to maintain my files in the android folder like MainActivity.java, MainApplication.java, AndroidManifest etc.
could you please describe differences between these ways?
TL;DR
First, you should check out the latest options for upgrading from facebook.
If none of those work for you:
Increase version of react-native in your package.json
run npm install (or yarn if you're using that)
run react-native upgrade or possibly react-native upgrade --legacy
Explanation
Here I address each of the upgrade options you asked about.
1) npm install react-native#latest --save then react-native
run-android or react-native run-ios
As you probably know, the run-* commands here don't perform any type of upgrade.
Meanwhile, npm install --save <library>#<version> is just the command to put a library into your package.json, or update the version of an existing library. This is how you would upgrade the version of any typical library in your package.json. If that's all there was to upgrading RN, there would be no fuss amongst the community about the difficulty of upgrading. There's much more work to do.
If this is the only step you take in upgrading, the new version of react-native will be downloaded to node_modules, but it should fail and complain about many things:
react dependency needs to be upgraded as well
Files under your ios and android directories will not be in the state which the latest react-native expects. For example, if you upgrade from react-native 0.52 to 0.59, you will have gradle 2 while your react-native library expects gradle 4.
Your other dependencies might not work with your newer version of RN. For example, here is a warning from npm install after I did my upgrade:
npm WARN react-native-markdown-renderer#3.2.8 requires a peer of react-native#^0.50.4 but none is installed. You must install peer dependencies yourself.
As you can see, I need to upgrade native-markdown-renderer as well, since it requires RN 0.50 but I've upgraded to 0.59. Some libraries might work in this mismatched state, but that is your risk to take.
2) react-native-git-upgrade
From what I understand, the RN team had too many problems with this product and no longer want us using it. I'm guessing this is why it doesn't work at all for most of us.
3) react-native upgrade
This will update the version of react-native in your package.json, but then also bring you through a set of guided CLI prompt as it modifies the files in your ios and android directories. But how will this guide handle conflicts between the new incoming files and your existing files? You likely have some changes in there you want to keep.
Newer versions of react-native upgrade are said to allow you to perform a diff and merge, but I haven't seen that. When I ran it, it intended to clobber my entire old file with a new one, and it showed me the path on my local file system to the "new" version that would overwrite my old one. So I used my own diffing tool to just diff between the new incoming file and my existing file. If you lack a diff tool, I use p4Merge. So, as you go through the CLI guide, just do a diff between your existing file and the path to the new file it gives you, and do that one by one, adding necessary new lines to your files. If you made some changes, answer "no" to the prompt so that you can keep your old file (with the modifications you just made). If you don't have anything worth keeping in the file, answer "yes" and let the guide simply overwrite and clobber your old file.
When this command is complete, your ios and android directories will be updated. For example, gradle will be upraded from Gradle 2 to Gradle 4.
You may hit the bug I did, which causes this command to keep upgrading you to an OLDER version rather than the latest. In this case, you need to instead run: react-native upgrade --legacy
If it's a smaller project just create a new react native project using 'npx react-native init yourprojectname --version X.XX.Xt' and then copy the source folder of your older project into the new project. Then try running it in android or ios using 'npx react-native run-android' or 'npx react-native run-ios'. If there are any runtime errors but no build errors, then update the npm packages accordingly. Note: This is applicable for small projects because larger projects may contain many 3rd party dependencies. :)
I tried react-native-git-upgrade and then deleted node_modules and then npm install
it works for me!
https://facebook.github.io/react-native/docs/upgrading
The upgrade approaches mentioned in the other answers do work in many cases, but I have experienced many other cases where there are too many errors.
From my experience, in these cases the best approach is to create a new project in the new version, and copy the source files to the new project.