Live Reloading works on simulator but not my physical device. This has been the case since I've removed expo and it's packages completely from my project. Following a few tutorials I revised my Babel config to use this package (also installed via yarn):
module.exports = function(api) {
api.cache(true);
return {
presets: ['module:metro-react-native-babel-preset'],
};
};
I also added a main.jsbundle file to my project and added the command to populate it:
yarn react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
The only thing that appears when the app's done install is a black bar above the app saying:
Connect to metro to develop javascript react native
Things to Note:
My phone is connected to the same network as my M1 Mac
Entering the IP and port manually in the test app doesn't seem to work either
Cleaning the build, deleting/reinstalling the app from my phone, and restarting Xcode + Mac doesn't work
My build scheme is set to "Debug" and NOT set to "Release"
React Version: 0.64.0
Related
I have problem with running expo, newly created app (empty Hello World!). It works perfectly with android studio emulator, but when I try to open it on the IOS simulator Expo go app is being installed, but app is not starting. It looks like crash without any errors in console (expo app splash screen is visible for a moment, then app disappears).
My Xcode app is updated
My dependencies:
"expo": "~47.0.8",
"expo-status-bar": "~1.4.2",
"react": "18.1.0",
"react-native": "0.70.5"
I tried:
granting different permissions for Xcode app on my macOS
removing node_modules and package-lock.json and installing dependencies again (npm install)
removing .expo directory
using different ios simulators
uninstalling expo app on simulators and resetting them
I also followed expo documentation and I have Xcode command line tools installed (https://docs.expo.dev/workflow/ios-simulator/)
Any suggestions?
You might need to install Rosetta if you are working on an M1 MacBook, because expo was created for intel chips.
softwareupdate --install-rosetta
Expo Go app in simulator closes automatically without errors
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
I'd like to integrate react-native modules in already existing iOS App but keeping both solutions separately.
Instead of doing this https://facebook.github.io/react-native/docs/integration-with-existing-apps.html which modifies the existing solution, I would like to have a standalone react-native solution and somehow import the Xcode project of the react-native app into my already existing app.
This allows me to continue developing the already existing app without being affected by the RN solution which installs and add libraries to the Xcode project.
Basically the concepto would be to export the react-native solution as a bundle or static library and import it in my already existing iOS App. After that interact with this library from the already existing iOS App and also allow the React-Native Solution library interact with the already existing app. There should be a way to communicate from the already existing app to the RN Solution library and also from the RN solution library with the already existing (i.e. for launching modules from the already existing iOS app and also from the RN solution be able to launch views of the already existing app)
Is this possible?
You can do most of the things you are referring. Excuse me if a miss something...
Runninig as standalone
If you don't have ios and android folders in your RN directory, you must run react-native eject from CLI.
React-native application can be started as a standalone native app using the CLI commands below:
react-native run-ios (only on MacOS)
react-native run-android
Add --port #### if the default is being used.
Both commands will start something like a sandbox native app which will load the JS inside. It will also start the Metro bundler which will serve the js bundle as well.
Loading RN into existing app
You need to add the native RN libraries for Android and iOS as dependencies, so you can use them to load either the JS bundle from the Dev server or insert the JS bundle within the native build.
To use the dev server run react-native start.
To build the JS as a file which will be added to the native package you must run:
react-native bundle ios
Followed by couple of options
--dev false or true
--entry-file index.ios.js change this to match your entry file. It may be just index.js. Be carefull to match the name inside Java/Obj-C code.
--bundle-output ../YOUR-EXISTING-IOS-APP/main.jsbundle
--assets-dest ../YOUR-EXISTING-IOS-APP
Communication
This happens over the RCTBridge.
Check this page for a explanation and examples how to access native functionality from the RN environment.
I'm setting up a new project using React Native like this tutorial: https://facebook.github.io/react-native/docs/getting-started.html and build iOS release but it does not work, the blank white screen showed after LaunchScreen run.
The app works if build in Debug(react-native run-ios) but does not work in Release(build release by Xcode or terminal).
react-native v0.53.0
react-native-cli v2.0.1
node v8.10.0
Xcode 9.2
The log show in Xcode:
2018-02-06 15:55:14.464233+0700 MyApp[306:35863] [Accessibility] ****************** Loading GAX Client Bundle ****************
2561-02-06 15:55:14.697 [error][tid:main][RCTCxxBridge.mm:423] Failed to load bundle(file:///var/containers/Bundle/Application/4FAF82CD-9EA4-4E73-800A-A2ABC9313405/MyApp.app/main.jsbundle) with error:(Error reading bundle /var/containers/Bundle/Application/4FAF82CD-9EA4-4E73-800A-A2ABC9313405/MyApp.app/main.jsbundle (null))
2018-02-06 15:55:14.706782+0700 Shiip[306:35863] Failed to load bundle(file:///var/containers/Bundle/Application/4FAF82CD-9EA4-4E73-800A-A2ABC9313405/MyApp.app/main.jsbundle) with error:(Error reading bundle /var/containers/Bundle/Application/4FAF82CD-9EA4-4E73-800A-A2ABC9313405/MyApp.app/main.jsbundle (null))
I use many node version so the Xcode not using the node version which I used in my Terminal, it's make my app build crashed. Let's do this to solved my problem
Open The Script Build Phases in Xcode:
Now, using with the node version path exactly (use command: which node to get your node version path)
And my problem was solved
In my case,
Xcode v14.1
React native 0.69.5
I found out that the error source is due to the node version which system use for running release build. credits to this answer Stack overflow
I had to add the following lines in Xcode ==> Project ==> Build phases ==> Build react native code and images
export NODE_BINARY="/Users/<UserName>/.nvm/versions/node/v14.17.0<Your_Version>/bin/node"
../node_modules/react-native/scripts/react-native-xcode.sh
change UserName and Node version in this line accordingly
If you need to test in release build before uploading to testflight
for review
Go to Xcode ==> product ==> Scheme ==> edit scheme ==> Select Run ==> change build configuration to release
to run a release build from terminal
you just only need to type the following command:
npx react-native run-ios --configuration Release
If you want run your project on a real device use --device parameter:
npx react-native run-ios --configuration Release --device "Your Device Name"
The reason this is happening is because debug mode runs on the chrome javascript engine where as release mode runs on the device javascript engine. Some javascript features that work on chrome don’t work on the engines that mobile devices use. Please see mdn for more information there must be some js function you’re using that is undefined and causing the white screen.
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