React-Native - Best Way to Send App to iPhone for Testing - ios

I've read through the documentation and I've ejected my app. This creates the /ios folder I need with all of the xCode files. I opened the file with xCode.
I used an unedited bootstrapped version made using create-react-native-app and then immediately ran the npm run eject program.
When I open the files with xCode, I can properly assign the team. I go ahead and click build to send the project to my attached iPhone. It spends time building, opens the metro bundler in a terminal window, but eventually fails. It says it is missing the main.jsbundle file.
Does anyone have experience with this kind of workflow? Most examples show active development using expo or a platform specific device simulator. I would like to know how to send the application for testing on a real device quickly.

Check Your Build Configuration are you making a Release buid or debug
build. To check got to Products > Schemes > Edit Schemes > Run
Run this command before making a Release Build to create
mainBundle.js
react-native bundle --entry-file index.ios.js --platform ios --dev
false --bundle-output ios/main.jsbundle --assets-dest ios
For debug configuration Xcode will automatically handle bundling

Related

IOS Release Build Failed: Could not find the expected embedded asset at-rules.json. Check that expo-updates is installed correctly

My React Native app works fine in iOS debug mode. But, when I tried to run the app in release mode from xCode, the build is failed. However, in android, it works fine in both debug and release mode.
File /Xcode/DerivedData/myapp-ewjafyqwkgvybabvuzpfqtubujvv/Build/Products/Release-iphonesimulator/ios.app/main.jsbundle does not exist. This must be a bug with.
Then I tried generating the main.jsbundle manually by running the following command and adding this main.jsbundle in Copy Bundle Resources in Build Phases from XCode.
npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
Still, I am not being able to build the ios app in release mode but this time the build succeed but the app doesn't show anything in screen and the error i got in Xcode is:
Could not find the expected embedded asset at-rules.json. Check that expo-updates is installed correctly.

"Error: EMFILE: too many open files" using Xcode to archive React Native App

I know there are a lot of similar questions out there, but my issue seems to be unique, and the solutions suggested aren't solving it:
I'm trying to build an archive of a React Native App from Xcode and, since updating to macOS 11.3.1 and Xcode 12.5, I get "Error: EMFILE: too many open files" when Xcode is trying to run the node bundle command.
I've already installed and updated watchman via homebrew, and have also increased my system's maximum open files and open files per process to unreasonably high values.
Oddly enough, I can do a debug build from Xcode with no issues, and running the node bundle command that Xcode's archive fails on from the command line completes without any issues. I'm able to run and debug the App with no issues, it's just when Xcode is trying to bundle the js for an archive that it seems to fail.
It's almost like Xcode is not using watchman (while the terminal is) and/or it's process has a limit on the number of open files that is different from what I get in the terminal.
I had the same problem and here's how I fixed it.
I believe this error is happening due to the bundle for iOS is missing so it's trying to build the bundle when Xcode is building the app (it shouldnt fail but no idea why it does)
I fixed it by first adding this command to my package.json to build the iOS bundle manually.
"bundle:ios": "react-native bundle --entry-file='index.js' --bundle output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'",
I ran npm run bundle:ios first, and then I proceeded to add the bundle file in Xcode,
under Build Phases => Copy Bundle Resources
I cleaned my project in Xcode and the build works after.

Using React Native iOS Release Build doesn't load new code but the version does

My React Native App do not respond to my changes of code in the Release mode of iOS. I don't know why but I cannot upload a new version with my changes. However, the version changes, is the only thing it changes when I apply a change in my code.
What can I do to fix it?
No matter if I build the app from XCode or by using the snippet react-native run-ios --configuration Release --device "iPhone of Charles" or if I just archive it and upload to the App Store.
Finally I found the solution.
The problem was that the main.jsbundle I was generating was placing in the wrong place having 2 main.jsbundle at the same time, the old and corrupted and the right one.
I had the right one outside /ios/ProjectName and the old one there. I just had to apply this snippet which would generate a new and clean main.jsbundle:
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets
and then get the file main.jsbundle and the assets folder and place them inside /ios/ProjectName
Thanks all for the help.

React Native archive error: Unable to find React Native files. Make sure "react-native" module is installed in your project dependencies

I'm trying to archive my (otherwise perfectly building, running on simulator/device for debug) iOS app built with React Native.
When I try to archive in Xcode, it compiles and links correctly but while trying to generate assets the following command is invoked:
node '/Users/Can/Documents/Programming/React Native/REDACTED/node_modules/react-native/cli.js' bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/Can/Library/Developer/Xcode/DerivedData/REDACTED-eebdhuhscigvmvduljehleepetoi/Build/Intermediates.noindex/ArchiveIntermediates/REDACTED/BuildProductsPath/Release-iphoneos/REDACTED.app/main.jsbundle --assets-dest /Users/Can/Library/Developer/Xcode/DerivedData/REDACTED-eebdhuhscigvmvduljehleepetoi/Build/Intermediates.noindex/ArchiveIntermediates/REDACTED/BuildProductsPath/Release-iphoneos/REDACTED.app
It fails with error:
error Unable to find React Native files. Make sure "react-native" module is installed in your project dependencies.. Run CLI with --verbose flag for more details.
(Before you ask, yes, react-native is installed in my project dependencies, obviously)
When I invoke that exact node command manually, it generates assets perfectly fine:
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, /Users/Can/Library/Developer/Xcode/DerivedData/REDACTED-eebdhuhscigvmvduljehleepetoi/Build/Intermediates.noindex/ArchiveIntermediates/REDACTED/BuildProductsPath/Release-iphoneos/REDACTED.app/main.jsbundle
info Done writing bundle output
info Copying 30 asset files
info Done copying assets
I am unable to archive my app because of this. It suggests me to run CLI with --verbose flag but I have no idea where to add the flag as the command itself is invoked from an autogenerated/complicated script.
What am I doing wrong? I am on Xcode 10.2 and React Native 0.59.3.
According to the error Make sure "react-native" module is installed you are not on the project root path. So delete the derived data and OPen Terminal & set Project Path
cd ../projectpath_foldername
run the command
npm start
after that
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
Now run
react-native run-ios
once its build and run open the xcode and archive your app.
After investigating some issues such as https://github.com/facebook/react-native/issues/22354 I've found the problem after several hours:
I had a space in my project path. I've moved my project to a path without space and it started to archive perfectly. Apparently, it really was a bug with React Native.

React Native app not running in XCode iOS simulator

I try to make my first steps using React Native. Development for Android (on Windows host) works. Now I wanted to test iOS, and tried to set up a development environment on a MacBook Pro.
Problem: React Native starts the iOS simulator, and then nothing happens any more. The simulator runs OK, but my React native app won't start.
What do I need to do to get my React Native installation going?
More Info:
I set up XCode and React Native according to the docs on the MacBook Pro running OSx 10.13.2 (High Sierra). XCode was installed and tested successfully, including the simulator.
When I installed Node.js I deliberately picked an older version (containing npm 4.2.0), since forums say that React Native does still have problems with npm 5. I also installed Homebrew and Watchman, like stated in the docs.
To initialize an empty project, I used
create-react-native-app HelloWorldProject
and a projet structure got created in my Documents folder.
If I finally fire up my "Hello World" test app using
cd HelloWorldProject
sudo react-native run-ios
the system responds:
Starting packager ...
Starting simulator ...
and then nothing happens. The simulator does indeed start (boot --> apple logo --> progress bar --> IOs start screen), but nothing happens afterwards.
Edit
I have given up on React Native for several reasons, I leave this question here for documentary purposes, but I cannot verify or accept any answer, I don't have a React Native development environment any more.
It's probably because you used sudo. /.expo/ is owned by root. Try to change the ownership with
sudo chown -R `whoami` ~/.expo
Refer https://github.com/react-community/create-react-native-app/issues/422
Even everything in your app seems fine, sometime you face the issue that the app is taking too much time to load either through terminal or Xcode. If there is no any other specific issue with your project, the following solution works most of the time:
Go to your app folder and then go to 'iOS' folder.
Delete 'Podfile.lock' and 'Pods' folder.
Execute the following command in Terminal from your 'ios' folder, that will bring back the 'Podfile.lock' and required Pods will be installed to 'Pods' folder:
pod install
Delete the 'build' folder in your 'iOS' folder.
Run the following command in terminal:
react-native run-ios
While the terminal is running, open '.xcworkspace' in your 'ios' folder in Xcode.
The above steps will make sure it will be build your react native project newly and will run on the simulator.
Thanks
Wasantha Wijayaratna

Resources