diff --git a/ios/NewExpensify/AppDelegate.mm b/ios/NewExpensify/AppDelegate.mm index fded3061f7a5..47b7f7a9142f 100644 --- a/ios/NewExpensify/AppDelegate.mm +++ b/ios/NewExpensify/AppDelegate.mm @@ -26,7 +26,7 @@ - (BOOL)application:(UIApplication *)application // They will be passed down to the ViewController used by React Native. self.initialProps = @{}; self.dependencyProvider = [RCTAppDependencyProvider new]; - + // Configure firebase [FIRApp configure]; @@ -38,7 +38,7 @@ - (BOOL)application:(UIApplication *)application [RCTBootSplash initWithStoryboard:@"BootSplash" rootView:(RCTRootView *)self.window.rootViewController.view]; // <- initialization using the storyboard file name - + // Define UNUserNotificationCenter UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; @@ -53,7 +53,7 @@ - (BOOL)application:(UIApplication *)application [UIApplication sharedApplication].applicationIconBadgeNumber = 0; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"isFirstRunComplete"]; } - + [RNBackgroundTaskManager setup]; return YES; @@ -85,37 +85,13 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge - (NSURL *)bundleURL { - return [self getBundleURL]; -} - -- (NSURL *)getBundleURL -{ - NSURL *jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; - #if DEBUG && !TARGET_OS_SIMULATOR - NSString *ipPath = [[NSBundle mainBundle] pathForResource:@"ip" ofType:@"txt"]; - - if (ipPath) { - NSError *error; - NSString *ip = [[NSString stringWithContentsOfFile:ipPath encoding:NSUTF8StringEncoding error:&error] - stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; - - if (ip && !error) { - NSString *metroAddress = [NSString stringWithFormat:@"http://%@:8081/index.bundle?platform=ios", ip]; - jsCodeLocation = [NSURL URLWithString:metroAddress]; - NSLog(@"Using %@ as metro server address", metroAddress); - } else { - NSLog(@"Failed to get metro server ip from %@, error: %@", ipPath, error.localizedDescription); - } - } else { - NSLog(@"Could not locate ip.txt"); - } - #endif - - #if DEBUG && TARGET_OS_SIMULATOR - jsCodeLocation = [[NSURL alloc] initWithString:@"http://localhost:8081/index.bundle?platform=ios"]; - #endif - - return jsCodeLocation; +#if DEBUG + return + [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; +#else + return [[NSBundle mainBundle] URLForResource:@"main" + withExtension:@"jsbundle"]; +#endif } // This methods is needed to support the hardware keyboard shortcuts diff --git a/ios/Podfile b/ios/Podfile index d43a9d5530f1..1029402d69d4 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -49,6 +49,18 @@ def __apply_Xcode_14_3_RC_post_install_workaround(installer) end end +def __modify_react_native_settings_for_debug_build(installer) + installer.pods_project.targets.each do |target| + if target.name.include?('React') + target.build_configurations.each do |config| + if config.name.downcase.include?("debug") + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= '$(inherited) DEBUG=1' + end + end + end + end +end + # Configure Mapbox before installing dependencies pre_install do |installer| $RNMapboxMaps.pre_install(installer) @@ -101,6 +113,7 @@ target 'NewExpensify' do # :ccache_enabled => true ) __apply_Xcode_14_3_RC_post_install_workaround(installer) + __modify_react_native_settings_for_debug_build(installer) installer.pods_project.targets.each do |target| if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle" diff --git a/ios/Podfile.lock b/ios/Podfile.lock index a84ca7eb3561..48fe31431651 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -3478,6 +3478,6 @@ SPEC CHECKSUMS: VisionCamera: c95a8ad535f527562be1fb05fb2fd324578e769c Yoga: 1fd059161b449018342943b095a6d4e69bcaa719 -PODFILE CHECKSUM: e185ffe0937c6bc63c014c3164f1756b549b7af6 +PODFILE CHECKSUM: 5b2f0a75a0848d964701b52fb6ab7e9602040f3e COCOAPODS: 1.15.2