gpt4 book ai didi

ios - React Native iOS 构建失败 "unable to execute command: Segmentation fault: 11"

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:02:41 24 4
gpt4 key购买 nike

我是一名网络开发人员,我是第一次构建 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 文件如下所示:

////  Copyright (c) 2016 Google Inc.////  Licensed under the Apache License, Version 2.0 (the "License");//  you may not use this file except in compliance with the License.//  You may obtain a copy of the License at////  http://www.apache.org/licenses/LICENSE-2.0////  Unless required by applicable law or agreed to in writing, software//  distributed under the License is distributed on an "AS IS" BASIS,//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.//  See the License for the specific language governing permissions and//  limitations under the License.//#import "AppDelegate.h"#import "RCTBundleURLProvider.h"#import "RCTRootView.h"#import "RNFIRMessaging.h"// Copied from Apple's header in case it is missing in some cases (e.g. pre-Xcode 8 builds).#ifndef NSFoundationVersionNumber_iOS_9_x_Max#define NSFoundationVersionNumber_iOS_9_x_Max 1299#endif@implementation AppDelegate- (BOOL)application:(UIApplication *)application    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  NSURL *jsCodeLocation;  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation                                                      moduleName:@"Mamaz"                                               initialProperties:nil                                                   launchOptions:launchOptions];  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 configure];  #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0    [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];  #endif  return YES;}#if defined(__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]){    completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);  }else{    completionHandler(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];}#else//You can skip this method if you don't want to use local notification-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.userInfo];}#endif- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo];  completionHandler(UIBackgroundFetchResultNoData);}@end

我的 PodFile 是这样的:

target 'App' do  use_frameworks!  # Pods for App  pod 'Firebase/Core'  pod 'Firebase/Messaging'  target 'AppTests' do    inherit! :search_paths    # Pods for testing  endend

有人遇到过这样的问题吗?我什至不明白是什么原因造成的(因为错误消息的描述性不强)

最佳答案

对于一般性的错误消息,您可能只会得到一般性的答案。

尝试:

a) 删除 #define NSFoundationVersionNumber_iOS_9_x_Max 1299 以获得提示,就好像您的工具链是否正确一样。

b) 关闭 Xcode 8.1(完全关闭,就像使用 cmd+q),删除 DerivedData 文件夹,清空垃圾箱。并且只有在最后一步之后重新打开 Xcode,才能正确地重新构建缓存。

c) 确保您使用的是 CocoaPods 1.1.1。毫无疑问,您也可以更新其他工具。示例:sudo gem update -n/usr/local/bin --system && sudo gem update -n/usr/local/bin

d) use_frameworks!target 之前,我们通常就是这样做的

e) pod deintegrate && pod install,正确地重新集成 pod

f) 最后,克隆你的项目,并尝试从克隆的 repo 构建:如果可行,删除旧的 repo 并使用新的 :)。如果它仍然失败,那么您可以开始删除代码片段以尝试获得具有最小测试用例的配置,您可以在 CocoaPods 问题跟踪器上共享该配置以供调查。

关于ios - React Native iOS 构建失败 "unable to execute command: Segmentation fault: 11",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40822061/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com