【问题标题】:xcode 7.2 Could not build Objective-C modulexcode 7.2 无法构建 Objective-C 模块
【发布时间】:2015-12-09 13:36:15
【问题描述】:

我刚刚将我的 Xcode 更新到了 7.2 版。现在我尝试使用 xcodebuild 从命令行构建framework,但出现此错误

.... /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

【问题讨论】:

  • 试过构建干净,删除派生数据文件夹并重建?
  • 这是我尝试的第一件事,但没有成功。
  • 我遇到了同样的问题,但什么也没有。如果有人发现了什么,请分享。
  • 您使用的命令行参数是什么?我在这里看到了类似的问题,我认为这与 -sdk iphonesimulator 没有得到充分尊重有关,看起来它正在尝试使用该 SDK,但它输出到错误的中间构建文件夹,在我的情况下,如果我使用 @ 987654326@ 也可以看到,虽然设置说它应该转到Debug-iphonesimulator,但它实际上试图将二进制文件放入Build/Products/Debug-iphoneos 文件夹中。
  • 我编辑了我的问题以显示我使用的命令。

标签: ios xcode module xcodebuild


【解决方案1】:

一种可能的解决方法是通过添加以下内容来提供目的地:

-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'

【讨论】:

  • 是的!谢谢你!你能解释一下,为什么需要它吗?
  • 过去是命令行工具自动选择的目的地,现在不是了
【解决方案2】:

尝试指定目的地,即xcodebuild -workspace 'App.xcworkspace' -scheme 'App Scheme' -destination 'id=[THE_SIMULATOR_ID_YOU_WISH_TO_USE]' -sdk iphonesimulator9.2 -configuration Debug

参考:https://twitter.com/nlutsenko/status/674863890342109185

【讨论】:

    【解决方案3】:

    替代方法是使用https://github.com/facebook/xctool 它的工作原理类似于 xcodebuild

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

    【讨论】:

      【解决方案4】:

      我向 Apple 报告了同样的问题,当使用“方案”从命令行构建并将 -sdk 指定为模拟器时,它实际上发生在任何类型的项目中。

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

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

      【讨论】:

      • 我最初认为我的 Xcode 7.2 安装不正确。我从 AppStore 进行了软件更新。所以即使我们清理并重新安装 Xcode7.2 也不会解决这个问题,对吧?它显然是 Xcode 7.2 中的一个问题。请确认。
      • 是的,具体来说,看起来像是 CLI 工具的问题。
      猜你喜欢
      • 1970-01-01
      • 2018-03-31
      • 1970-01-01
      • 2017-06-29
      • 2015-07-05
      • 2016-10-16
      • 2016-04-06
      • 2018-05-25
      相关资源
      最近更新 更多