React Native App crashes on Launch Screen on device - ios

I'm starting with React Native, everything works fine in the iOS simulator. I decide to try it on a device.
The app launches, I can play with it, I close/reopen it around 4 or 5 times, and then somewhat randomly the app crashes on Launch Screen (the one with "Powered By React Native"). It just shows the screen, and the app crashes to the iPhone home screen.
Any idea how I can further debug that?
Edit: I added Bugsnag in my AppDelegate.m, but bugsnag doesn't detect anything when the app crashes.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
[BugsnagReactNative start];
// Rest of code
}

I came across this issue today. Read a few SO posts and saw one guy mentioned if your app launches and hangs on the splash screen and then crashes with no error it probably has something to one of your npm dependencies.
After digging deeper i saw the react packager was throwing the error
This error is caused by a #providesModule declaration with the same name across two different files.
To fix
check / clean up dependencies(check for same name declerations)
rm -rf node_modules
rm -rf $TMPDIR/react-*
npm i

This can caused by many issues it seems. Recently this happened to me and I had to search a bit to find out the exact reason.
I'll save you guys the trouble by sharing few places I read
- https://github.com/facebook/react-native/issues/14500#issuecomment-348063910
- https://github.com/facebook/react-native/issues/17276#issuecomment-357538208
In my case it was a library issue which I have not linked properly.
-https://github.com/ivpusic/react-native-image-crop-picker/issues/204
So yeah! my point is, it's something we have done or not done. Bit more research would help!!!

I had a similar issue. My application crashed on emulator device every time I ran the application without throwing any error in the console.
Here are a bunch of solutions that might work:
Solution 1 Remove node_modules
rm -rf /node_modules
npm install
Solution 2 Remove /android/app/build directory (This one worked for me)
rm -rf /android/app/build
After this, uninstall the application from emulator device and then run your application again

I was also facing the same issue on real device and it was working fine on simulator. So, i have fixed my issue by given solution
Solution: i have uninstall the application from simulator and then installed it again. This time it showed me the actual error on simulator that i had made mistake.

I finally solve this error by running the app in release mode from xcode
goto Product->Scheme and then click edit Scheme
Select run from left side menu
change Debug to Release
untick Debug executable
now clean the project and run your app in release mode
Some time you have to delete pods and install again after doing above
look for your error in xcode console in my case VS code has imported a Library I just have to remove that import

I had this problem also, what triggered it for me though was updating react and react-native.
I did a build after updating and then I experienced the same issue. I downgraded back to the previous versions of react and react-native, but that didn't work for me.
I tried removing node modules, and reinstalling, that didn't help. Then I noticed that when I was building: react-native run-ios,
the files in ios/build were not updating
I rm -rf ios/build/ and then I react-native run-ios and the ios/build folder populated. My app ran fine after that.

For me lottie package was creating problem. After removing the package able to launch the package.
Make sure by checking the last package/packages installed

In my case it was the Firebase GoogleService-info.plist file which was missing that is supposed to be present in your project.xcodewrkspc when opened using XCode. Adding that resolved the issue.

Related

Problem with running IOS simulator for my flutter app

I'm trying to run my flutter app on the IOS simulator and its not working. So tried on the most basic flutter app (create my_app and then tried to run it) and nothing seem to work!
Everything seems to work fine when I run it from the terminal until the linking and signing phase and that where I get the error, how can I fix it?
This is the error I get:
Unable to install
/Users/MyUserName/Desktop/my_app/build/ios/iphonesimulator/Runner.app on
82562E3A-E7BD-4FE0-9BF9-8BB9C7AD5F15. This is sometimes caused by a malformed
plist file:
ProcessException: Process exited abnormally:
An error was encountered processing the command
(domain=IXUserPresentableErrorDomain, code=1):
This app could not be installed at this time.
Could not install at this time.
Failed to transfer ownership of path
/Users/MyUserName/Library/Developer/CoreSimulator/Devices/82562E3A-E7BD-4FE0-9BF9-8B
B9C7AD5F15/data/Containers/Shared/SystemGroup/systemgroup.com.apple.installcoord
inationd/Library/InstallCoordination/PromiseStaging/98CD703F-760F-4AAE-B991-BC2E
82D37D17/my_app.app to installd
Underlying error (domain=MIInstallerErrorDomain, code=103):
Failed to transfer ownership of path
/Users/MyUserName/Library/Developer/CoreSimulator/Devices/82562E3A-E7BD-4FE0-9BF9-8
BB9C7AD5F15/data/Containers/Shared/SystemGroup/systemgroup.com.apple.installcoo
rdinationd/Library/InstallCoordination/PromiseStaging/98CD703F-760F-4AAE-B991-B
C2E82D37D17/my_app.app to installd
Command: /usr/bin/xcrun simctl install 82562E3A-E7BD-4FE0-9BF9-8BB9C7AD5F15
/Users/MyUserName/Desktop/my_app/build/ios/iphonesimulator/Runner.app
Error launching application on iPhone 11 Pro Max.
Edit:
I updated my MacOS, Deeleted and reinstalled Xcode, I even tried to run the most simple swift app and I get always this same error, it looks like the build was successful but it unable to install. I still get this same error, what can I do?
This occurred when I opened the Simulator first and then updated XCode -- even without running the app until after XCode updated completely.
What worked for me:
Close Simulator completely (from the dock, right-click -> "Quit")
Close XCode (if applicable)
Run flutter clean
Re-open Simulator
Re-open XCode and let it compile
Run the app again
If it still does not work, try resetting the device at "Device" -> "Erase All Content and Settings..." from the Simulator menu.
I had the same issue a couple of days ago
What I did - and what fixed the problem - was to reset the simulator (Device -> Erase All Content and Settings), and then run $ flutter clean
You should now be able to run your app again
None of the above worked for me. I created another flutter application and copied it's ios folder to my project. Worked like a charm
Save time, just go to erase device content and settings from the emulator, then run flutter clean. App should run fine then.
Run flutter clean and then run your app again
If error persist, generate a new flutter project on Android studio. Replace the ${projectHome}/ios/Runner.xcodeproj folder with the ${newFlutterProjectHome}/iOS/Runner.xcodeproj. Your app should run fine now.
If error persist still, delete the ios folder and replace it with a new one copied from a freshly generated project.
This happens if the GoogleService-Info.plist is missing.
This also happens when you have updated your XCode and your simulator is in the background.
Close the simulator and open the Xcode, you will get an option to install additional tools, install them and then run the application.
An alternate solution is to run the Runner.xcworkspace app once from Xcode and this may fix it.
In my case it was because of hanging empty GoogleService-Info.plist file inside Xcode after migrating to new Firebase (FlutterFire) initialization.
Xcode is not a regular drag and drop IDE which directly maps project files to the ones in the file system. It rather caches file references. So even when you delete a .plist file, the Xcode still maintains a reference to it.
Simply opened Xcode IDE and removed .plist file (which updated project.pbxproj in turn). This helped me to compile the project fine.
I had this same issue recently. I found out I added my GoogleService-info.plist file to the subdirectory Runner and not the main Project directory Runner through xcode. I opened up xcode again, deleted the file and re-added it to the proper place and now everything is working correctly.
for this you have to give some value in CfBundleVersionShortString like
<key>CFBundleShortVersionString</key>
<string>1.0</string>
And Give the build value in Runner as 1.0 and version as 1.0
enter image description here
To be honest. it's really frustrating for the developers
This is how I fixed!
flutter clean
flutter pub get
go to ios folder
rm Podfile.lock
pod repo update
pod install
Then it works!

Expo React Native App Not Loading the AppEntry.bundle

I am working on a react-native app using expo. The app was working just fine. I could do npm start to run the metro builder and then run my app on simulator as well as iOS devices directly.
I did 2 things.
I upgraded the expo version to latest - 3.17.15
I rebooted my laptop.
After these 2 changes, I could still do npm start without any issues. But, when I tried to open/ run the app in iOS simulator it got stuck at the bundle loading. In fact it could not get the bundle file only.
I thought this was a network problem where the simulator/ device was not able to reach http://127.0.0.1:19000 However, when I visited the url in the browser that was working.
The bunlde url that I saw in the error:
Now, when I try to visit that bundle url through the simulator:
http://127.0.0.1/node_modules/expo/AppEntry.bundle
The browser never loads the thing and times out.
I have already tried:
Cleaning the cache - npm start --reset-cache
Deleting the .expo folders in ~/.expo as well as ~/project/.expo
Changing the mode from Lan -> Tunnel.
Upgrading the global expo-cli to latest version.
removing the node_modules directory in the project ~/project/node_modules
re installing the node_modules by doing - npm install.
IMPORTANT - After having this issue with my current app, I decided to spawn a new blank expo app and run the same. Same result. The bundle was not loaded. I also remember something like this happening to me in the past but don't remember how I fixed it.
My Network is a hotspot through my phone. The same network used to work until yesterday without any issues. So not sure if reboot has caused some setting to revert.
Any help troubleshooting this problem would be very helpful here.
Finally after spending 2 days and working on 2 different laptops I could get to the root of this problem.
Firstly, I thought this was an OS upgrade issue (I upgraded my OS to Mac OS Catalina). So, I cloned my repo on another laptop, a fresh one where these was no node expo or react native. I initialized a new expo typescript react native project. Tried to run it - Worked like a charm. Simulator was not installed but worked on my device without any issues. The metro bundle log was generated.
This was leading me even closer to my assumption. So I tried to revert all the changes I had in my repo and tried building the app with npm start which eventually runs expo start. Did not work.
Finally - I created a fresher user on my laptop. The upgraded one. Cloned the repo - and tried to build the project. This time! Again it failed, however there was one change - in the metro builder log I got a this error:
2020-04-06T21:29:57,075: [0x110e7fdc0] while computing sockname: failed to create /usr/local/var/run/watchman/shrikant-state: Permission denied
Watchman: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2020-04-06T21:29:57,075: [0x110e7fdc0] while computing sockname: failed to create /usr/local/var/run/watchman/shrikant-state: Permission denied
To solve that I just changed the permission to the watchman directory:
sudo chmod 042777 /usr/local/var/run/watchman/
The app was finally built and running successfully on both the simulator and the device!
If anyone else runs into something similar, I was stuck on this and it turned out expo didn't like me using a logical OR assignment ( ||= ) even though typescript and my linters were fine with it. I replaced my ||= with a ternary and worked fine.

React Native iOS starts the development server but never connects and then just crashes

So I run my react-native iOS app from Xcode or react-native run-ios like normal. The server starts and says "Loading dependency graph, done." as normal. The app boots up on the simulator and then stays on the splash screen for around 20 seconds then crashes. It never seems to be able to find the development server and it doesn't print any error in the console.
I haven't been able to solve this issue for the life of me today. I've tried every solution I can find. If someone has any insight, please let me know. Thanks!
How to overcome :
cd ios && pod install
then Open in Xcode (project.xworkspace)
then clean and build project with Xcode
Ok so I ended up updating everything... Xcode, react native (0.60), my node_modules, and cleaned and rebuilt and finally everything works properly now. Updating took some time but it was worth it.

Don't succeed running a react native app from Xcode (running the same app from cli work just fine)

When I try to run the app on a real device or emulator (running from Xcode) I get stuck on splash screen and able to see 'Loading dependency graph'
However, if run it from command line like react-native run-ios --simulator="iPhone 8" everything works just fine and I have no problems.
What might cause the problem? Thanks
try starting the bundler in a separate terminal window, e.g., npm start -- --reset-cache and then run Xcode.
OH MY GOD
Being a deep js believer, I actually had never used Xcode and furthermore had never put any effort towards debugging.
Turns out, I accidentally put a breakpoint somewhere in main.m that has been causing the issue. I didn't notice it and now everything works just fine when I removed it.

Installing on Iphone gets stuck after setting up firebase_messaging

Following the Readme of the https://github.com/flutter/plugins/tree/master/packages/firebase_messaging I set up the IOS and Android firebase. On Android it works but when I try to install the app by running "flutter run" on IOS, it gets stuck at installing it and I can't open it.
After I took the screenshot a new line appeared under "Installing and launching", "Configuring firebase for this app..." (or something like this).
I tried deleting the pods and set up again.
I tried deleting the app so it can be installed again.
I that at some point during the "Installing and launching..." the app tries to open but closes back immediately. Is it a crash? How do I get some sort of info regarding this? Thank you!
check these two things:
For iOS, the firebase_messaging functionality only works on real devices, it doesn't work on the simulator. (it does work in Android emulator)
Run open -a xcode ios/ and try to build the app there (⌘R), there will be more details on possible errors, specially regarding filling in the Signing section. Even if it's not signing, you will find out what it is, and after fixing it, the flutter cli will resume running without issues.

Resources