I am following along the official documentation, copy and pasting the code provided there:
https://facebook.github.io/react-native/docs/0.56/native-components-ios
But I am still running into this error
does anyone know what the docs are missing to get this working?
This is happens because native module not compiled yet, simply execute react-native run-ios in terminal while in project directory.
Note: For latest node version use: npx react-native run-ios
RNTMapManager.m must be created within the XCode project, the docs do not specify that. Open the XCode project and click File -> New -> File and create a new Cocoa Touch Class called "RNTMapManager". Then place the objective-c code within RNTMapManager.m. Rebuild the application and it should work!
To be able to use native components make sure your project was ejected (expo eject)
Once ejected open for example iOS project with XCode and create/add file from Xcode. This way it will update all the dependencies.
Rebuild the project
Related
my react-native project builds and run from npx react-native run-ios and also it runs from xcode. now i am almost done with what i want to do and wanted to publish a version for test flight on app store but i cant archive the product which is how i used to do before. it fails right away with some swift error. in this work i added a dummy swift file and xcode also added bridge file as part of it. here is the error i get:
Been there,
make sure all the three pod, project and target have the same IOS Deployment Target.
I would like to know if it's necessary to rebuild react native project after installing and linking libraries that includes native codes.
Yes, as react-native-link updates some native files that are under the ios/android folder, that won't be checked during a reload/hot-reload/live-reload. All those files aren't checked in your jsBundle and are compiled during a run-android or run-ios.
Of course, if you added a new dependecy to the project and linked it, and you haven't used it anywhere in your code yet, you don't need it. If you are using that dependecy, your project instance will, most likely, die.
if your react native version is below 0.60 then you have to run react-native-link after you install any react-native module. However after react-native version 0.60 and above, this is done automatically using the new "autolinking" feature added.
Read the changelog here:
https://facebook.github.io/react-native/blog/2019/07/03/version-60
However you still need to rebuild your project after you install a native module but you dont need to run the react-native-link command anymore after installing every library after react-native#0.60 and above. Just type react-native run-android
I use create-react-native-app, and I wonder how I can get a .ipa file to run in my iPhone from it? I see the command npm run eject, but I do not know what to do next. And for some reason, I cannot use exp in the command line.
Is there a detail instructions to solve my problem? thanks
npm run eject will not create a IPA file for you. It will just create project files for iOS and Android which you can run on their respective IDE's. i.e Xcode and Android Studio.
Here is a good document which you can use to build iOS without ejecting it : https://docs.expo.io/versions/latest/guides/building-standalone-apps.html
If you choose to eject then, open Xcode project from the iOS folder -> change the bundle id. and follow along this https://wiki.genexus.com/commwiki/servlet/wiki?34616,HowTo%3A+Create+an+.ipa+file+from+XCode,
I xcode:
Change scheme destination to generic ios device
Go to Product - Archive
Go to Window - Organizer
Select the archive you want, click export
There you should be able to choose method and destination.
I'm new to React-Native and I'm trying to figure out how to run the project on iOS. I know this error means I need to add the library .xcodeproj to XCode, but where is this file located? I'm using react-navigation and I installed it with yarn and after I have run the command react-native link
Thanks for your help!
Seems like you have a previous installation of react-native-navigation, which uses native code.
First you need to unlink this library:
react-native unlink react-native-navigation
Note: You need to have the source code of the react-native-navigation package in order to unlink. If you already removed from you package.json, you need to install again to unlink.
After unlink, you can remove the react-native-navigation and just move forward using the react-navigation library, which does not need to link native code.
Just to add to #Rafael's answer, I previously added React-Native-Navigation and yes it was still linked in the Link Binaries With Libraries, so I deleted it, here's a picture showing which library to remove
For those who are using react-native-navigation and still got this issue consider
updating IOS Target Deployment to version 11 in Xcode Build Settings
from
https://github.com/wix/react-native-navigation/issues/6734#issuecomment-720735261
I am working on a project already exists native base and I want to add expo to easily test my application.
The easiest way to do this is to make a new Expo project and copy over all the JavaScript from your existing project.
There isn't a way to react-native link expo or anything like that right now. There might be in the future but even then that wouldn't enable the easy sharing that you want. To get that you need to just use the binary code included with Expo (which can do most things you want to do).
Here is more info: https://docs.expo.io/versions/latest/introduction/faq.html#how-do-i-get-my-existing-react-native-project-running-with-expo
Expo can now be added to an existing project, run the following command for automatic installation:
npx install-expo-modules#latest
If the command fails, you can refer to the docs for manual installation instructions.