neoDev
neoDev

Reputation: 3049

react native app starts only through xcode

I created a mobile app using react native framework

but it only starts through xcode, if I try to open the app from the iphone it doesn't start

It works fine when I open it through xcode (myapp.xcodeproj), it builds the app on the iphone and then opens it without problems

What can be the problem?

Upvotes: 1

Views: 1047

Answers (2)

Monochrome
Monochrome

Reputation: 163

I have also run into this problem today, after upgrading React Native from ~32 to 39.2 (I haven't used it for a long time, that's what I want to say).

I got it fixed by doing the following:

  1. Completely disabling the ATS (not sure if it is actually needed as I wanted to run the device locally with no server connected, but at this point I'm too afraid to ask); You can read more about it here: https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ .

  2. Building the app before running it (I think this is the main thing). So I don't remember doing it back in the days, but after I've upgraded, this seems to be the right way to do it:

a) Make sure your phone is connected to the Mac via USB cable

b) In Xcode, go to Product -> Build for -> Running

c) Wait for it to build (this will not run the app yet, so be patient)

d) Run the app as usual

I guess that's it! Then you can disconnect your phone. At least it works for me; hope it will help you, too.

UPD: still doesn't work!

Later this day, I tried launching my app again and found out that my advice happened to be useless – oddly enough, it didn't solve this problem this time... But no worries – I somehow made it work again!

What I did was go to my AppDelegate.m and change the jsCodeLocation line look just like it looked when I used a lower version of React Native:

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

So it works for now... Hope this helps :)

UPD 2 : don't forget to change the code back when you decide to run it on the Simulator!

jsCodeLocation = [[RCTBundleURLProvider sharedSettings]      
jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

Upvotes: 1

The running on device guide from React Native's official site : https://facebook.github.io/react-native/docs/running-on-device.html

Upvotes: 1

Related Questions