简体   繁体   English

使用CocoaPods的项目中Xcode 6.0.1中的Apple Mach-O链接器错误(稳定)

[英]Apple Mach-O linker error in Xcode 6.0.1 (stable) in a project with CocoaPods

I know some people will probably complain about this question, but I'm getting the following errors and just can't get any sense from it: 我知道有些人可能会抱怨这个问题,但是我遇到了以下错误,对此一无所知:

错误日志

in text: 在文字中:

    Undefined symbols for architecture x86_64:
  "__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from:
      __TFC10SimpleTest14ViewController9writeTextfS0_FCSo15UIBarButtonItemT_ in ViewController.o
      __TFC10SimpleTest9Websocket17createHTTPRequestfS0_FT_T_ in Websocket.o
      __TFC10SimpleTest9Websocket19initStreamsWithDatafS0_FTCSo6NSDataSi_T_ in Websocket.o
      __TFC10SimpleTest9Websocket16disconnectStreamfS0_FGSqCSo7NSError_T_ in Websocket.o
      __TFC10SimpleTest9Websocket15errorWithDetailfS0_FTSS4codeVSs6UInt16_CSo7NSError in Websocket.o
      __TFFC10SimpleTest9Websocket15processResponseFS0_FCS0_10WSResponseSbU_FT_T_ in Websocket.o
  "__TFSsoi1oUSs17_RawOptionSetType_USs21BitwiseOperationsTypeSs9Equatable__FTQ_Q__Q_", referenced from:
      __TFC10SimpleTest11AppDelegate11applicationfS0_FTGSQCSo13UIApplication_29didFinishLaunchingWithOptionsGSQCSo12NSDictionary__Sb in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I think it has something to do with the bridging header. 我认为这与桥接标头有关。 My project is in Swift but I added some pods (Obj-C). 我的项目在Swift中,但是我添加了一些Pod(Obj-C)。 I've been searching for hours and couldn't find any working solution! 我一直在搜索数小时,找不到任何有效的解决方案!

Thanks for your help! 谢谢你的帮助!

Checkout this article about linking from Swift to Cocoapods: 查看有关从Swift到Cocoapods链接的本文:

https://medium.com/@stigi/swift-cocoapods-da09d8ba6dd2 https://medium.com/@stigi/swift-cocoapods-da09d8ba6dd2

Basically you need some extra includes in the new bridging-header. 基本上,您需要在新的桥接头中包含一些额外的内容。

Here are a few suggestions. 这里有一些建议。 Remember to set the search path in the build settings to Pods and make it recursive. 切记在构建设置中将搜索路径设置为Pods并使其递归。 Also, check to make sure the libPods.a entry is made in the target, for each target in your project. 另外,请检查并确保为项目中的每个目标在目标中创建了libPods.a条目。 Again, click on the topmost blue folder then General, to see the list of targets in your project. 再次,单击最上方的蓝色文件夹,然后单击“常规”,以查看项目中目标的列表。 Click on the individual targets to see if it is possible to add to the Frameworks. 单击各个目标以查看是否可以添加到框架中。 If it is, click the plus sign and choose libPods.a from the list. 如果是,请单击加号,然后从列表中选择libPods.a。

Remember to run pod update (from Terminal on a Mac) after making changes like this. 进行此类更改后,请记住要运行Pod更新(从Mac上的Terminal)。 It is a good idea to rerun pod update anytime you make changes that are intended to modify a setting related to cocoapods. 在您进行旨在修改与可可足类相关的设置的更改时,最好重新运行pod更新。

In some cases I've been told to add a bridging header file to each main folder in my project, but have not yet found a case where that was required. 在某些情况下,有人告诉我将桥接头文件添加到项目中的每个主文件夹中,但是尚未找到需要这样做的情况。

My experience with the mach o linker error and cocoapods is that the problem is with targets not being linked through the frameworks option. 我对mach o链接器错误和cocoapods的经验是,问题出在没有通过frameworks选项链接目标的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM