【发布时间】:2017-04-10 20:41:59
【问题描述】:
我是一名 Web 开发人员,我是第一次构建 React Native 应用程序。 在我添加了对推送通知的 FCM 支持之前,该应用程序一直在运行和编译。
我按照React-Native-FCM 的所有说明使用 CocoaPods。
现在通过构建 xCode 失败并出现以下错误:
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)
我的 AppDelegate 文件如下所示:
// // 版权所有 (c) 2016 Google Inc. // // 根据 Apache 许可证 2.0 版(“许可证”)获得许可; // 除非遵守许可证,否则您不得使用此文件。 // 您可以在以下网址获取许可证副本 // // http://www.apache.org/licenses/LICENSE-2.0 // // 除非适用法律要求或书面同意,否则软件 //根据许可分发是在“原样”基础上分发的, // 不提供任何明示或暗示的保证或条件。 // 请参阅许可证以了解特定语言的管理权限和 // 许可证下的限制。 // #import "AppDelegate.h" #import "RCTBundleURLProvider.h" #import "RCTRootView.h" #import "RNFIRMessaging.h" // 从 Apple 的标头中复制,以防在某些情况下(例如 Xcode 8 之前的版本)丢失。 #ifndef NSFoundationVersionNumber_iOS_9_x_Max #define NSFoundationVersionNumber_iOS_9_x_Max 1299 #万一 @implementation AppDelegate - (BOOL)应用程序:(UIApplication *)应用程序 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *jsCodeLocation; jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 模块名称:@“妈妈” 初始属性:无 启动选项:启动选项]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; [FIRApp 配置]; #如果定义(__IPHONE_10_0)&& __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; #万一 返回是; } #如果定义(__IPHONE_10_0)&& __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.request.content.userInfo]; if([[notification.request.content.userInfo valueForKey:@"show_in_foreground"] isEqual:@YES]){ 完成处理程序(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound); }别的{ 完成处理程序(UNNotificationPresentationOptionNone); } } - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { NSDictionary* userInfo = [[NSMutableDictionary alloc] initWithDictionary: response.notification.request.content.userInfo]; [userInfo setValue:@YES forKey:@"opened_from_tray"]; [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo]; } #别的 //如果不想使用本地通知可以跳过这个方法 -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.userInfo]; } #万一 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo]; 完成处理程序(UIBackgroundFetchResultNoData); } @结尾我的 PodFile 是这样的:
目标“应用程序”做 使用_frameworks! # 应用程序的 Pod 吊舱“火力基地/核心” pod 'Firebase/消息传递' 目标“AppTests”做 继承! :search_paths # 用于测试的 Pod 结尾 结尾有人遇到过这样的问题吗?我什至无法理解是什么原因造成的(因为错误消息的描述性不是很好)
【问题讨论】:
标签: ios xcode react-native cocoapods firebase-cloud-messaging