-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functioning debug build for iOS device #1396
Comments
The problem is in #if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; As stated here, this will try and work out your device's IP address and connect to it. This works fine with an emulator as it is running on the same system and the IP might default to localhost. It does not work at with the device as it cannot find the development environment.
Solution 1We can replace this line with our own local tunnel thing, for example if we use ngrok: #if DEBUG
return [NSURL URLWithString:@"https://73c05e9e.ngrok.io/index.bundle?platform=ios"]; This works. It must https and the actual URL needs to be adjusted to your currently running ngrok process. This is fine for just loading the bundle, but will not work with the 'Debug JS Remotely'. Debug JS RemotelyIn if (!_url) {
NSInteger port = [[[_bridge bundleURL] port] integerValue] ?: RCT_METRO_PORT;
NSString *host = [[_bridge bundleURL] host] ?: @"localhost";
NSString *URLString = [NSString stringWithFormat:@"http://%@:%lld/debugger-proxy?role=client", host, (long long)port];
_url = [RCTConvert NSURL:URLString];
}
if (!_url) {
NSString *host = [[_bridge bundleURL] host] ?: @"localhost";
NSString *URLString = [NSString stringWithFormat:@"http://%@/debugger-proxy?role=client", host];
_url = [RCTConvert NSURL:URLString];
} Now pressing 'Debug JS Remotely' will bring up an error of REFERENCE: NotesThis current solution doesn't seem optimal, as it requires updating the AppDelegate.m every time we wish to use it. It may be a reasonable option for now, however. Additionally, we still have a repeating log in Xcode similar to this issue
|
As Search for If you are developing on simulator, use the default: // FOR SIMULATOR DEVELOPMENT VERSION, REMOTE DEBUGGER
if (!_url) {
NSInteger port = [[[_bridge bundleURL] port] integerValue] ?: RCT_METRO_PORT;
NSString *host = [[_bridge bundleURL] host] ?: @"localhost";
NSString *URLString = [NSString stringWithFormat:@"http://%@:%lld/debugger-proxy?role=client", host, (long long)port];
_url = [RCTConvert NSURL:URLString];
} If you are developing on device, use this version: // FOR DEVICE DEVELOPMENT VERSION, REMOTE DEBUGGER
if (!_url) {
NSString *host = [[_bridge bundleURL] host] ?: @"localhost";
NSString *URLString = [NSString stringWithFormat:@"http://%@/debugger-proxy?role=client", host];
_url = [RCTConvert NSURL:URLString];
} |
To run a development build on an iOS device, some settings need to be tweaked. Some comments have been added to AppDelegate.m to help with this. More information is available at the issue: #1396 Notion should also hold some documentation.
Is this related to the react native update to 0.59? How was it functioning before? |
We never had a development version on iOS. We had a set-up similar to this. We would comment out the development line and comment in the production line to load from the main bundle that is bundled in, rather than use a development server. |
Is there any way to pass in things from build-time environment variables? Probably must be done through some form of generated file, if there are any such files for iOS builds. That would be optimal, to avoid changing things in the code itself just for building, and also because the IP can be directly baked in and no need to go through ngrok |
There is a script that actually runs in the original config of our AppDelegate.m: https://github.com/facebook/react-native/blob/master/scripts/react-native-xcode.sh This is meant to get the IP and use it. I was meant to test this today at home to see if it is another betahaus problem, but I forgot to bring an iOS device home. Also my wifi at home uses WPS for its password with some really long password and there is no easy way of using this on iOS. |
iOS devices access the dev server over the network, and the device needs to be on the same network for this to work. And the network needs to allow it of course, so this was non-functional in Betahaus. This is probably the only reference to Betahaus in our git logs; this is their legacy. Anyway, there's an xcode build phase script (node_modules/react-native/scripts/react-native-xcode.sh) which "guesses" the build machine's IP and writes it to a text file inside the .ipa, which is then loaded by the react bridge. Closes #1396
Scope of the feature
Currently, installing the app from Xcode onto a iOS has a few problems:
These may all be due to the configuration within the
AppDelegate.m
file, where thejsBundleURLForBundleRoot
is incorrect.It would be ideal to have a functioning debug version of the app that runs on an attached iOS device.
Tasks
The text was updated successfully, but these errors were encountered: