简体   繁体   中英

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). 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:

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. Also, check to make sure the libPods.a entry is made in the target, for each target in your project. 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.

Remember to run pod update (from Terminal on a Mac) after making changes like this. It is a good idea to rerun pod update anytime you make changes that are intended to modify a setting related to cocoapods.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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