【问题标题】:iOS Static library compilation error - table of contents is emptyiOS静态库编译错误-目录为空
【发布时间】:2014-07-15 05:02:36
【问题描述】:

我正在尝试为 iOS 创建一个 Objective C 静态库。当我尝试编译时,它会给出以下警告。

Libtool /Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Intermediates/MyLib.build/Debug-iphoneos/MyLib.build/Objects-normal/armv7/libMyLib.a normal armv7
cd /Users/******/Desktop/MyLib
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only armv7 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -L/Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Products/Debug-iphoneos -filelist /Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Intermediates/MyLib.build/Debug-iphoneos/MyLib.build/Objects-normal/armv7/MyLib.LinkFileList -ObjC -framework Foundation -o /Users/shafraz/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Intermediates/MyLib.build/Debug-iphoneos/MyLib.build/Objects-normal/armv7/libMyLib.a

armv7s 和 arm64 也遇到类似错误

(null): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for library: /Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Products/Debug-iphoneos/libMyLib.a for architecture: armv7 the table of contents is empty (no object file members in the library define global symbols)

armv7s 和 arm64 也遇到类似错误

仅在删除 MyLib.m 和 MyLib.h 文件中的类声明后才会显示此蠕虫。

我该如何解决这个问题?

【问题讨论】:

  • 尝试删除派生数据文件夹并清理您的项目。
  • 现在有些已经消失但仍然收到以下警告 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic 未指定以下标志无效: -ObjC 警告:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool:库警告:/Users/shafraz/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/ Products/Debug-iphonesimulator/libMyLib.a 目录为空(库中没有目标文件成员定义全局符号)
  • 有什么解决办法吗?我在一个新创建的 Xcode 静态库项目中看到了这一点。
  • @RawCCode 仍然找不到任何解决方案
  • 我也遇到了同样的问题。我正在使用 Xcode 6 beta 4。

标签: ios objective-c xcode


【解决方案1】:

如果您的静态库只包含类别或非正式协议,则通常会发生这种情况。链接器警告您,您似乎没有要链接的类。

【讨论】:

    【解决方案2】:

    在我的例子中,我意识到我编写的库最终只是一个标头库。这意味着我什至不需要编译库,只需在“构建设置”的“标题搜索路径”中包含标题即可。

    【讨论】:

      猜你喜欢
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-20
      • 2015-03-06
      • 1970-01-01
      • 1970-01-01
      • 2013-03-21
      相关资源
      最近更新 更多