Xcode 7.2 无法构建 Objective-C 模块。

9

我刚刚将我的Xcode更新至7.2版本。现在我尝试使用xcodebuild从命令行构建框架,但是却出现了以下错误:

.... /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTiming.h:6:9: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTiming.h:6:
#import <QuartzCore/CABase.h>
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CABase.h:11:10: error: could not build module 'Darwin'
#include <stdbool.h>
         ^
/Users/atran/Desktop/Repos/DSA_Working_Directory/Libs/Kingfisher/Kingfisher/Kingfisher.h:27:9: note: while building module 'UIKit' imported from /Users/atran/Desktop/Repos/DSA_Working_Directory/Libs/Kingfisher/Kingfisher/Kingfisher.h:27:
#import <UIKit/UIKit.h>
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UICollectionViewLayout.h:11:9: note: while building module 'QuartzCore' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UICollectionViewLayout.h:11:
#import <QuartzCore/CATransform3D.h>
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAEAGLLayer.h:7:9: note: while building module 'OpenGLES' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAEAGLLayer.h:7:
#import <OpenGLES/EAGLDrawable.h>
        ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/EAGL.h"
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/EAGL.h:8:10: error: could not build module 'Foundation'
#include <Foundation/Foundation.h>
         ^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/atran/Desktop/Repos/DSA_Working_Directory/Libs/Kingfisher/Kingfisher/Kingfisher.h"
        ^
/Users/atran/Desktop/Repos/DSA_Working_Directory/Libs/Kingfisher/Kingfisher/Kingfisher.h:27:9: error: could not build module 'UIKit'
#import <UIKit/UIKit.h>
        ^
<unknown>:0: error: could not build Objective-C module 'Kingfisher'

XCode 7.1的一切都运行良好,所以XCode 7.2一定有所改变。有人有线索吗?

编辑:

这是我的构建命令

这个可以工作

xcodebuild clean build -workspace XYZ.xcworkspace -scheme ABC -configuration Debug -sdk iphoneos

这个不起作用:

xcodebuild clean build -workspace XYZ.xcworkspace -scheme ABC -configuration Debug -sdk iphonesimulator

那是我尝试的第一件事,但它没有起作用。 - Peacemoon
我也遇到了同样的问题,什么都没有解决。如果有人发现了什么,请分享一下。 - Santiago Ferrer Deheza
你使用了哪些命令行参数?我在这里看到了一个类似的问题,我认为它与 -sdk iphonesimulator 没有被完全尊重有关,它似乎正在尝试使用该SDK,但输出到错误的中间生成文件夹,如果我同时使用 -showBuildSettings 我可以看到它,尽管设置说应该进入 Debug-iphonesimulator,但实际上它会尝试将二进制文件放入 Build/Products/Debug-iphoneos 文件夹。 - Roberto Andrade
我编辑了我的问题以显示我使用的命令。 - Peacemoon
也在苹果论坛上提问过:https://forums.developer.apple.com/thread/27975 - Peacemoon
显示剩余3条评论
4个回答

13

一个可能的解决方法是通过添加以下内容来提供目标位置:

-destination 'platform=iOS Simulator,name=iPhone 6'

在您的情况下,应该像这样:

xcodebuild clean build -workspace XYZ.xcworkspace \ -scheme ABC -configuration Debug \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone 6'


是的!谢谢你!你能解释一下为什么需要吗? - skywinder
1
目标不再由命令行工具自动拾取。 - Y. S.

2

0

另一个选择是使用https://github.com/facebook/xctool,它与xcodebuild类似

../<path>/xctool/xctool.sh clean build -workspace XYZ.xcworkspace -scheme ABC -configuration Debug -sdk iphonesimulator

0

我向苹果报告了同样的问题,这实际上发生在使用“scheme”并指定-sdk作为模拟器时的任何类型的项目上。

看起来ARCHPLATFORM_NAME变量设置不正确,即使我们正在指定-sdk iphonesimulator。 我目前的解决方法是在我的xcodebuild命令行上,除了-sdk iphonesimulator标志外,还要指定PLATFORM_NAME = iphonesimulator

等待从我的错误报告中听到更多消息。


我最初认为我的Xcode 7.2安装不正确。我从AppStore进行了软件更新。因此,即使我们清理并重新安装Xcode7.2,也无法解决这个问题,对吗?这显然是Xcode 7.2的问题。请确认一下。 - arango_86
是的,看起来是CLI工具出了问题,更具体地说。 - Roberto Andrade

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接