【问题标题】:Could not build Objective-C module 'CoreGraphics'无法构建 Objective-C 模块“CoreGraphics”
【发布时间】:2017-10-22 07:43:23
【问题描述】:

我在尝试运行任何单元或 UI 测试时遇到以下错误。运行应用程序本身时不会发生。错误信息如下所示:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:12:10: note: while building module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:12:
#include <CoreFoundation/CFBase.h>
     ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/CoreFoundation.h"
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:
#include <CoreFoundation/CFBase.h>
     ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:
#include <Block.h>
     ^
/Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/table/Block.h:10:10: note: in file included from /Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/table/Block.h:10:
#include "leveldb/iterator.h"
     ^
/Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/include/leveldb/iterator.h:18:10: note: in file included from /Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/include/leveldb/iterator.h:18:
#include "leveldb/slice.h"

/Users/eirik/Documents/Utvikling/iOS/ProsjekterSamarbeid/AnchorPoint Fishing as/FerskFiskiOS/Pods/leveldb-library/include/leveldb/slice.h:21:10: error: 'string' file not found
#include <string>
     ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/CoreGraphics.h"
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:8:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:8:
#include <CoreGraphics/CGBase.h>
     ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:12:10: error: could not build module 'CoreFoundation'
#include <CoreFoundation/CFBase.h>
     ^
<unknown>:0: error: could not build Objective-C module 'CoreGraphics'

我在 Swift 3.2 模式和 CocoaPods 中使用 Xcode 9。我正在使用 Firebase 和 FirebaseUI,它们具有 leveldb 作为依赖项。可以看到错误首先在leveldb/slice.h中触发,找不到string文件。

到目前为止,我已经尝试了以下方法:

  • 清理(Shift + CMD + K)
  • 删除 DerivedData
  • 清理构建文件夹...
  • 在构建设置的框架模块中允许非模块化包含。
  • pod deintegrate, pod clean pod install.

对于它的价值,这是问题导航器中的错误:

有什么建议吗?

【问题讨论】:

  • 您解决了这个问题吗?我也有同样的问题。
  • 您是否看到我在答案下发表的关于它工作的评论,应该将Enable Bitcode 设置为NO?我那不适合你,那我就帮不上忙了,很遗憾。

标签: ios xcode firebase cocoapods leveldb


【解决方案1】:

这看起来类似于 CocoaPods 1.4.0 中修复的 CocoaPods issue。没有为单元测试目标正确设置搜索路径。

尝试更新到 CocoaPods 1.4.0 beta 并重新运行pod update

或者对 leveldb 路径使用与here 描述的类似的解决方法:

仅在 Build Settings -&gt; Header Search Paths 下将 "${PODS_ROOT}/leveldb-library/include" 添加到您的测试目标

【讨论】:

  • 我运行了pod update,然后 Could not build Objective-C module 'CoreGraphics 错误消失了,但现在出现以下错误:体系结构 x86_64 的未定义符号:ld:未找到体系结构 x86_64 的符号 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)注意:未找到体系结构 x86_64 的符号 i>.
  • 谢谢,它现在按预期工作!对于遇到我在上一条评论中提到的错误的任何人,请将 Enable Bitcode 设置为 NO
  • 我尝试了建议的解决方法,但没有解决任何问题。我还尝试更新到 CocoaPods 1.4.0 beta 2,而我得到的是 lipo: -remove's specified would result in an empty fat file。任何帮助,将不胜感激。环境:Xcode 9.1 使用 Swift 3.2。
猜你喜欢
  • 2015-07-05
  • 2016-10-16
  • 2016-04-06
  • 2018-05-25
  • 2021-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多