Xcode 8:针对pods的arm64架构未找到符号

5

升级到Xcode 8之后,应用程序无法在设备上运行,只能在模拟器上运行。所有添加到项目中的pods都会抛出错误:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_AFNetworkReachabilityManager", referenced from:
      objc-class-ref in FeedViewController.o
  "_OBJC_CLASS_$_TSMessage", referenced from:
      l_OBJC_$_CATEGORY_TSMessage_$_Override in NotificationMessenger.o
      objc-class-ref in NotificationMessenger.o
  "_OBJC_CLASS_$_AFHTTPRequestSerializer", referenced from:
      objc-class-ref in HTTPSessionTask.o
  "_OBJC_CLASS_$_AFJSONRequestSerializer", referenced from:
      objc-class-ref in HTTPSessionTask.o
  "_OBJC_METACLASS_$_SWTableViewCell", referenced from:
      _OBJC_METACLASS_$_MessagesCell in MessagesCell.o
      _OBJC_METACLASS_$_PaymentMethodCell in PaymentMethodCell.o
      _OBJC_METACLASS_$_SwipeTitleCell in SwipeTitleCell.o
  "_OBJC_CLASS_$_FBRequestConnection", referenced from:
      objc-class-ref in FacebookManager.o
  "_OBJC_CLASS_$_SWTableViewCell", referenced from:
      _OBJC_CLASS_$_MessagesCell in MessagesCell.o
      _OBJC_CLASS_$_PaymentMethodCell in PaymentMethodCell.o
      _OBJC_CLASS_$_SwipeTitleCell in SwipeTitleCell.o
  "_OBJC_CLASS_$_FBRequest", referenced from:
      objc-class-ref in FacebookManager.o
  "_OBJC_CLASS_$_AFURLSessionManager", referenced from:
      objc-class-ref in HTTPSessionTask.o
  "_OBJC_CLASS_$_Branch", referenced from:
      objc-class-ref in MyImpactViewController.o
      objc-class-ref in UINavigationController+Activity.o
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FBSession", referenced from:
      objc-class-ref in FacebookManager.o
      objc-class-ref in ExternalFacebookCommand.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

对于每个文件,也会抛出此警告:
file was built for archive which is not the architecture being linked (arm64)

活跃的架构没问题,我已经尝试删除派生数据文件夹、重新安装pods、将“只构建活跃的架构”设置为是和否,但都没有用。

我的Podfile长这样:

platform :ios, '8.0'
workspace 'Purple'
target 'Purple' do
pod 'AFNetworking', '2.6.3'
pod 'SAMKeychain', '~> 1.3'
pod 'TSMessages'
pod 'Facebook-iOS-SDK', '~> 3.23.2'
pod 'SWTableViewCell'
pod 'CardIO'
pod 'Parse'
pod 'PureLayout'
pod 'Branch'
pod 'DZNEmptyDataSet'
end

你能展示你的Podfile吗? - Anbu.Karthik
我已经在问题中添加了Podfile。 - damjandd
尝试使用 pod AFNetworking', '~> 3.1.0'pod install 命令进行安装,更多信息请参阅 https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking.podspec。 - Anbu.Karthik
尝试更新pods。 - Sachin Amrale
我已经更新了pods,但是由于一些旧代码,我必须保留旧版本的AFNetworking。问题不仅仅出现在AFNetworking上,您可以看到。 - damjandd
在 Pod 文件中添加 use_frameworks! - MAhipal Singh
3个回答

9

尝试清除XCode缓存:

rm -rf ~/Library/Developer/Xcode/DerivedData/

清除 CocoaPods 缓存并重新安装依赖:
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update

最后到"Pods"项目中,将"Debug"配置的"Build Active Architectures Only"属性也设置为"No"。

参考资料 https://dev59.com/U4nca4cB1Zd3GeqP9VS9#37930840


这对我很有帮助:最后进入“Pods”项目,并将“仅构建活动架构”设置为“否”,也适用于“调试”配置。 - Aleksey Tsyss

2
"OPN [Debug]目标覆盖了OTHER_LDFLAGS构建设置。" 这是主要问题。在其他链接器标志中添加$(inherited)解决了我的问题。"

enter image description here


0
请使用以下的Pod代码。
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ‘9.0’
use_frameworks!

target “NoteCheckdo

    pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => ‘4.0.1’
    pod 'AlamofireNetworkActivityIndicator',    '~> 2.0'
    pod 'AlamofireObjectMapper',        '~> 4.0.0'
    pod 'UIActivityIndicator-for-SDWebImage',   '~> 1.2'
    pod 'SVProgressHUD'         ,:git => 'https://github.com/SVProgressHUD/SVProgressHUD.git'
    pod 'Reachability',             '~> 3.2'
    pod 'SwiftyJSON',               '~> 3.0.0'
    pod 'ObjectMapper' ,            '~> 2.0'
    pod 'SDWebImage',               '~> 3.8'

    pod 'SZTextView',               '~> 1.2'
    pod 'TPKeyboardAvoiding',           '~> 1.3'
    pod 'FXBlurView' ,              '~> 1.6.4'
    pod 'AMSmoothAlert',            '~> 1.0'

    pod 'DGElasticPullToRefresh',       '~> 1.1'
end

//一些cocoapod库支持最低iOS9.0版本。所以尝试将最低部署目标设置为9.0,并检查所有支持Swift3.0的cocoapod库。在编辑pod文件后,更新pod。

对于Swift,我们应该使用Alamofire。或者您也可以使用AFNetworking。 - Mehul
无法解决问题。 - damjandd

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接