React Native: What file is responsible for the build of an app? - react-native

I'm currently working on a project for work that will require me to play around with the way in which react-naive apps build and I'm wondering what file/files are actually responsible for the building of an app?

As far as I know, React Native using Gradle build tool for building android apps. You can find an executable file named gradlew inside of android directory. For iOS, I'm not so sure, but I think RN use xcodebuild command line tool.

Related

how to add ios support for existing React Native application with only Android support?

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.

Why is that we cannot install native libraries on Expo? (that requires linking)

I am a newbie and learned react-native expo. I am curious why we can't use any native library with Expo.
For example, if I want to use filesystem on expo I just cant use it, I know expo has it's own file system but I want to use another library but that library requires linking so it is not working in expo. Why is that?
I have tried everything.
This is the library that I want to use ==> https://github.com/itinance/react-native-fs
It requires command : react-native link react-native-fs
How do I do it?
You first have to understand the difference between react-native cli & expo
Please read this documentation to understand the difference
React Native expo uses their own servers to compile your javascript into java and return APK file as a complete APP, and that is the reason you do not need android SDKs or android studio environment on your PC when you are using expo
but when you are using react-native cli you do need the android studio environment such as SDKs, because when you are using cli , it compiles the code using that android studio sdk/environment that you made in your PC that is why you do not need a third party server like expo do.
and thats the reason you get android files right in your react-native project and due to which you can add native modules to it.
However you also have the option to use expo-eject, You can read more about expo-eject in this documentation
Thank You!, Have a great day & welcome to stackoverflow community!.

Difference between react-native-init and create-react-native-app

What is the Difference between react-native-init and create-react-native-app.
I'm new to react native.
I've used both command to create new project, with react-native-init I get a project with IOS & android project folder & with create-react-native-app I get a new project that doesn't has those folders. Which one i should use ?
When we use create-react-native-app it will builds a project template based on Expo, a third-party toolkit which allows you to write cross-platform React Native applications using only JavaScript, and provides a smoother workflow for getting the app running on a real device. In addition, Expo provides access to tons of native APIs, for which you'd normally need libraries or custom native code and
When we use react-native-init it will creates a plain React Native app template, with native iOS and Android projects you can modify. The downside of this approach is that you'll need to set up the native iOS and Android build chains on your computer, and it's significantly more cumbersome to get started developing and deploying your app.

Init IOS project with pods using react-native init command

Is there any way to create the IOS project with pods using react-native init command?
Currently there is different installation instruction for react native libraries.
Example: Some of them install using react-native link command while other requires to setup using cocoapods. Missing both will leads to lots of compilation errors.
Could anyone suggest what is best way to create project using react-native.
Thanks
On the official react native documentation, there are 2 ways to start up your project, which is using 'CRNA' or 'Build With Native Code'.
For CRNA, it is the fastest and easiest way to start up your project.
It really easy to run your React Native app on a physical device without setting up a development environment. If you want to run your app on the iOS Simulator or an Android Virtual Device, please refer to the instructions for building projects with native code to learn how to install Xcode and set up your Android development environment.
The react native link is used if you want to link your library through the terminal. But in some cases, there are several problem occurred related to library compatibility. I rather suggest use pods or manually link your library through XCode.
Pods is a dependency manager for native code that we use on our native code project. It will automatically generate and link the library.
If you want to have pods on your ios project. After you install cocoapods, you could follow these steps :
1. Open terminal and direct to your project (cd YOUR_PROJECT/ios
2. pod init
3. And then Podfile will be generated within the ios project.
And from now on, you should use YOUR_PROJECT.xcworkspace if you want to manage the project. Thats because Pods should be placed and included same with your project but '.xcodeproj' does not include your Pods.

Can i build and compile react native via terminal?

Is there any way to compile and build my REACT native application via PHP code, there is the opportunity?
Thanks in advance!
React-Native application is just an XCode project, so you can use existing CLI tools like xcodebuild or xctool.