【问题标题】:Cocoa Pods failed to link libraries while running in the debug mode?Cocoa Pods 在调试模式下运行时无法链接库?
【发布时间】:2014-11-28 12:22:45
【问题描述】:

我正在使用pods 链接AfNetworkingfacebook 等库,它在release 模式下运行良好,但我想通过调试检查变量值,但它在发布模式下显示所有变量 nil .我尝试通过编辑架构以debug 模式运行,但编译失败,显示各种库未找到错误。

编辑我已经尝试更新架构.....但这无济于事。 调试模式下的错误日志

ld: warning: directory not found for option '-L/Users/madept/Desktop/personally/Pods/build/Debug-iphoneos'
ld: warning: ignoring file /Users/madept/Desktop/personally/libCloudinary.a, missing required architecture x86_64 in file /Users/madept/Desktop/personally/libCloudinary.a (3 slices)
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_AFHTTPRequestOperation", referenced from:
      objc-class-ref in ZRAPIClient.o
  "_OBJC_CLASS_$_AFHTTPRequestSerializer", referenced from:
      objc-class-ref in ZRAPIClient.o
  "_OBJC_CLASS_$_AFJSONResponseSerializer", referenced from:
      objc-class-ref in ZRAPIClient.o
  "_OBJC_CLASS_$_BITHockeyManager", referenced from:
      objc-class-ref in ZRAppDelegate.o
  "_OBJC_CLASS_$_CLCloudinary", referenced from:
      objc-class-ref in ZRMediaManager.o
  "_OBJC_CLASS_$_CLTransformation", referenced from:
      objc-class-ref in ZRMediaManager.o
  "_OBJC_CLASS_$_DDFileLogger", referenced from:
      objc-class-ref in Zooplr.o
  "_OBJC_CLASS_$_DDLog", referenced from:
      objc-class-ref in Chat.o
      objc-class-ref in ZRManagedObject.o
      objc-class-ref in ZRTelescopingScrollView.o
      objc-class-ref in ZRAddMessageBarController.o
      objc-class-ref in ZRCreateAccountViewController.o
      objc-class-ref in ZRAddressBookHelper.o
      objc-class-ref in Zooplr.o
      ...
  "_OBJC_CLASS_$_DDTTYLogger", referenced from:
      objc-class-ref in Zooplr.o
  "_OBJC_CLASS_$_ELCAlbumPickerController", referenced from:
      objc-class-ref in ZRMediaCaptureController.o
  "_OBJC_CLASS_$_ELCImagePickerController", referenced from:
      objc-class-ref in ZRMediaCaptureController.o
  "_OBJC_CLASS_$_EZAudioPlotGL", referenced from:
      objc-class-ref in ZRMediaCaptureController.o
  "_OBJC_CLASS_$_EZMicrophone", referenced from:
      objc-class-ref in ZRMediaCaptureController.o
  "_OBJC_CLASS_$_EZRecorder", referenced from:
      objc-class-ref in ZRMediaCaptureController.o
  "_OBJC_CLASS_$_FBAppCall", referenced from:
      objc-class-ref in ZRAppDelegate.o
  "_OBJC_CLASS_$_FBErrorUtility", referenced from:
      objc-class-ref in ZRSocialClient.o
  "_OBJC_CLASS_$_FBRequest", referenced from:
      objc-class-ref in ZRSocialClient.o
  "_OBJC_CLASS_$_FBRequestConnection", referenced from:
      objc-class-ref in ZRSocialClient.o
  "_OBJC_CLASS_$_FBSession", referenced from:
      objc-class-ref in ZRAppDelegate.o
      objc-class-ref in ZRSocialClient.o
  "_OBJC_CLASS_$_Mixpanel", referenced from:
      objc-class-ref in ZRAnalyticsTracker.o
      objc-class-ref in Zooplr.o
  "_OBJC_CLASS_$_Reachability", referenced from:
      objc-class-ref in Zooplr.o
  "_OBJC_CLASS_$_SSKeychain", referenced from:
      objc-class-ref in ZRAuthManager.o
  "_OBJC_CLASS_$_SVProgressHUD", referenced from:
      objc-class-ref in ZRAccountEditViewController.o
      objc-class-ref in ZRAppDelegate.o
  "_OBJC_CLASS_$_SocketIO", referenced from:
      objc-class-ref in ZRChatSocketClient.o
  "_OBJC_CLASS_$_TTTAttributedLabel", referenced from:
      objc-class-ref in ZRBubbleViewTextMessage.o
  "_kReachabilityChangedNotification", referenced from:
      -[ZRAppDelegate application:didFinishLaunchingWithOptions:] in ZRAppDelegate.o
      -[ZRChatSocketClient init] in ZRChatSocketClient.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

任何帮助或建议将不胜感激。

【问题讨论】:

  • 验证您的用户标题搜索路径等
  • debug模式和release模式是不是不一样...如果不一样,那我们怎么设置呢?
  • 看来你需要为所有目标添加架构

标签: ios objective-c xcode cocoapods


【解决方案1】:

如果上述答案对您不起作用,则问题可能出在您安装 pod 时。检查你在运行pod install时是否有这样的消息

ProjectName [Release] 目标覆盖了在 `Pods/Target Support Files/ProjectName/Pods-ProjectName.release.xcconfig' 中定义的 OTHER_LDFLAGS 构建设置。这可能会导致 CocoaPods 安装出现问题

或类似的消息,但使用debug 而不是释放(或两者)。 如果是这样,请在 Xcode 中删除工作区中的 pod 项目,然后按照这个问题的答案The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig,我在这里过去了:

这在大多数情况下肯定有效:

转到您的目标构建设置 -> 其他链接器标志 -> 双击 .将 $(inherited) 添加到新行。

然后再次运行pod install。它为我做到了。

【讨论】:

  • FWIW,我遇到了同样的问题,运行 pod install 时没有收到任何警告。
  • 不必删除我工作区中的 pod 项目。我在其他链接器标志中添加了 $(inherited) 并清理了 pod 目标(从产品>方案,更改方案和清理)重新启动了 xcode,它工作了。希望这对某人有所帮助。
【解决方案2】:

这意味着您使用的静态库不支持 x86_64 架构,
所以

  1. 为“Pods”目标打开“构建设置”,并添加“x86_64”架构(在“架构”和“有效架构”部分)。
  2. 将“仅构建活动架构”设置为“否”。
  3. 清理“Pods”目标。
  4. 构建您的目标。

【讨论】:

  • 我尝试了您的解决方案,它对现在的 ld 有所帮助:警告:找不到选项'-L/Users/madept/Desktop/personally/Pods/build/Debug-iphoneos' ld 的目录: 警告:忽略文件 /Users/madept/Desktop/personally/libCloudinary.a,在文件 /Users/madept/Desktop/personally/libCloudinary.a 中缺少所需的架构 x86_64(3 片)架构 x86_64 的未定义符号:“_OBJC_CLASS_$_CLCloudinary ",引用自:ZRMediaManager.o 中的objc-class-ref "_OBJC_CLASS_$_CLTransformation",引用自:ZRMediaManager.o 中的objc-class-ref
  • “Pods”是指“Cocoapods”吗?
【解决方案3】:

删除 /Users/YourName/Library/Developer/Xcode/DerivedData/YourProject/Build/Products/Debug-iphoneos 中的 .a 文件。然后清理并构建。这对我有帮助。

【讨论】:

  • 谢谢!在没有其他方法之后,这对我有用。
【解决方案4】:

对我有用的是将 $(inherited) 添加到:

  • OTHER_LDFLAGS
  • OTHER_CFLAGS
  • FRAMEWORK_SEARCH_PATHS
  • GCC_PREPROCESSOR_DEFINITIONS

提示:内部构建设置 ->(搜索栏)-> 在上方输入选项并添加 $(inherited)

【讨论】:

    【解决方案5】:

    我删除了 .a 文件,它对我不起作用,但是当我删除 /Users/YourName/Library/Developer/Xcode/DerivedData/YourProject 中的项目文件夹时。 这对我有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 2015-09-16
      相关资源
      最近更新 更多