升级React Native 0.71.2与iOS 15.2后模拟器启动黑屏求助
React Native 0.71.2升级后iOS模拟器启动页后黑屏问题
我近期将React Native升级至0.71.2版本,在iOS模拟器中打开应用时,会先显示启动页(Splash screen),随后淡出至黑屏状态。

在Xcode的日志中我看到以下信息:
2023-03-05 14:26:02.425529-0700 swoop[46482:1781261] <Warning>: The value for FacebookAdvertiserIDCollectionEnabled is currently set to FALSE so you're sending app events without collecting Advertiser ID. This can affect the quality of your advertising and analytics results. 2023-03-05 14:26:02.568162-0700 swoop[46482:1781382] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics 2023-03-05 14:26:02.572400-0700 swoop[46482:1781382] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics 2023-03-05 14:26:02.583568-0700 swoop[46482:1781375] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics 2023-03-05 14:26:02.766479-0700 swoop[46482:1781403] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics 2023-03-05 14:26:02.776339-0700 swoop[46482:1781383] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics 2023-03-05 14:26:03.345793-0700 swoop[46482:1781386] 7.0.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: 2023-03-05 14:26:03.400447-0700 swoop[46482:1781386] 7.0.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at: https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging to ensure proper integration. 2023-03-05 14:26:32.653488-0700 swoop[46482:1782007] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics
AppDelegate.mm 文件内容
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import "RNSplashScreen.h" #import "AppDelegate.h" #import <React/RCTBridge.h> #import <React/RCTBundleURLProvider.h> #import <React/RCTRootView.h> #import <FBSDKCoreKit/FBSDKCoreKit.h> #import <FBSDKCoreKit/FBSDKCoreKit-swift.h> #import "RNGoogleSignin.h" #import <GoogleMaps/GoogleMaps.h> #import "RNNotifications.h" #import <Firebase.h> #import <UserNotifications/UserNotifications.h> #import <React/RCTLinkingManager.h> #import <CodePush/CodePush.h> #import <React/RCTAppSetupUtils.h> @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.moduleName = @"swoop"; self.initialProps = @{}; if ([FIRApp defaultApp] == nil) { [FIRApp configure]; } [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; return YES; } - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) { return YES; } if ([RCTLinkingManager application:app openURL:url options:options]) { return YES; } return NO; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RNNotifications didFailToRegisterForRemoteNotificationsWithError:error]; } - (BOOL)concurrentRootEnabled { return true; } @end
Podfile 文件内容
require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, min_ios_version_supported prepare_react_native_project! flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end target 'swoop' do config = use_native_modules! # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], :flipper_configuration => flipper_config, :app_path => "#{Pod::Config.instance.installation_root}/.." ) # React Native Maps dependencies rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-google-maps', :path => rn_maps_path pod 'GoogleMaps' pod 'Google-Maps-iOS-Utils' permissions_path = '../node_modules/react-native-permissions/ios' pod 'react-native-fbsdk-next', :path => '../node_modules/react-native-fbsdk-next' pod 'react-native-maps', :path => '../node_modules/react-native-maps' pod 'RNReanimated', :path => '../node_modules/react-native-reanimated' pod 'Permission-LocationAccuracy', :path => "../node_modules/react-native-permissions/ios/LocationAccuracy" pod 'Permission-LocationWhenInUse', :path => "../node_modules/react-native-permissions/ios/LocationWhenInUse" pod 'Permission-Notifications', :path => "../node_modules/react-native-permissions/ios/Notifications" pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler' # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. # use_flipper!() post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64" end end end end
内容的提问来源于stack exchange,提问作者TheJediCowboy
相关产品推荐
相关产品推荐

