I know it might be very basic question. But I am very new and got a codebase with only android support. I need to add iOS for it. Please help me
As you're aiming to build a cross-platform app, React Native provides two ways to organize the code and seperate it by platform: platform module or platform-specific file extensions.
As you already have an Android app, I assume it has more complexity so you might want to split the code out into separate files.
You say you have an Android app but i don't thing that at any point you specified that the app should only build for Android (you can review in the package and the project configuration). So, the following command should be enough:
react-native run-ios
If you created your react native app from a template (e.g. using npx react-native init ProjectName), it already provides an ios and android folder, so it already supports it. If the file is not there, you could follow the instructions that #Rajan shared above to recreate the ios folder.
If your problem is running the iOS application using npm run ios, and its failing to build or the javascript throws an error, the quickest thing to try is cd ios, then pod install. If this does not work, it might be because you have additional dependencies you have installed, which require specific instructions and configuration to be done in the ios folder. This is library dependent, if needed, will be explained in depth in the README.md of the library. For example, react-native-firebase has a lot of steps, and is different to the android configuration.
Sometimes it is helpful to modify these configurations in XCode instead of editing the files manually (e.g. plist, xml, xproj). You can open xcode quickly using xed ios when in the root project folder.
Note: As usual, remember to have the libraries available in the node_modules folder, npm install.
In the future, you might choose to run different javascript code based on the platform (platform-specific code). React native allows that by using file.android.js and file.ios.js. However, your IDE is likely to struggle with the 2 files, and won't be as helpful compared to file.js. Alternatively, you can import Platform and conditionally check at runtime, what your platform is.
If you used Expo, you don't have access to the native code, but will already support iOS.
my question might be a little bit silly or ambiguous since I am fairly new to react native.
I'm trying to use the following repository for my react-native project https://github.com/smekalka/react-native-universal-pedometer. I have noticed that the repo is implemented in .java with platform folder unlike the regular .js or .ts files I used to see. Is this repository considered native module as react native doc describe?
Or in general how I can tell the whatever lib I am using is a native module.
The project is previously tested are under the support of expo-cli. I experienced the error null is not n object while using this repo. If so, I am probably going to eject the expo-cli and rewrite my code so I can use and even create own native-module for full control, some core implementations that written in other languages or expo-cli does not support.
Yes, the android and ios directories in the repository contain the 'native' code used to implement the platform-specific hooks that the Javascript will be able to pick up. Expo is not able to use these native modules or native code so your assumption is correct; you will need to eject your app in order to use this module.
If your app is below version 0.60 of React Native, after installing the module you will need to run react-native link react-native-universal-pedometer to link the native code to the Javascript runtime. If you're above 0.60, it will link automatically when installed.
I have made a custom wrapper in android for react-native. When I am using react-native link to install dependancy in android for my Project, it is not doing any changes neither showing any errors. I have followed this document https://www.botreetechnologies.com/blog/how-to-build-a-react-native-android-bridge for same but I have to make changes in android files manually for my Module and package. Do I need to add build.gradle too in android directory? or any other file if I have missed. This is my file structure for bridge.
This is how I am importing my local package in another React Native package's package.json
I build my own library for react-native and I want to make it available to the public. However, my library have some native implementation.
I want to use make the linking through react-native link avaialable, but I don't know how to start.
I have been looking on the RPNM project but I can't figure how to add it.
Today I basically have to do everything manually. Adding the compile dependencies on the build.gradle files.
How to automate my library linking using react-native link?
I need to use a third-party SDK which must be added as aar or android project library.
I tried to unzip the aar and copy the /lib and /res files to my titanium android module project, but it didn't work.
the error looks like this:
The developer of the SDK tell me check out a link which is FATAL EXCEPTION: java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout
I don't know how to solve it, hope someone could help me, thanks
Because Titanium is a Javascript cross platform tool to build native apps, you will need to write a wrapper to get a native functionality to work.
You can check out the documentation how to this on the Appcelerator website.
Unfortunately you can't just drop in a native component.