xcode 7.2 Could not build Objective-C module

匿名 (未验证) 提交于 2019-12-03 01:31:01

问题:

I have just updated my Xcode to version 7.2. Now I try to build a framework from command line using xcodebuild but have this error

.... /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          ^ /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           ^ /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          ^ /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          ^ /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          ^ :1:9: note: in file included from :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           ^ :1:9: note: in file included from :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          ^ :0: error: could not build Objective-C module 'Kingfisher' 

Everything worked well in XCode 7.1. so there must be something changed in XCode 7.2. Anyone has a clue?

Edit:

this is my build commmand

This works

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

This doesn't work:

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

回答1:

One possible workaround would be to supply a destination by adding the following:

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

In your case this would like this:

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



回答2:

Try to specify the destination, i.e, xcodebuild -workspace 'App.xcworkspace' -scheme 'App Scheme' -destination 'id=[THE_SIMULATOR_ID_YOU_WISH_TO_USE]' -sdk iphonesimulator9.2 -configuration Debug

Reference: https://twitter.com/nlutsenko/status/674863890342109185



回答3:

Alternative could be to use https://github.com/facebook/xctool which works similar to xcodebuild

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


回答4:

I reported the same issue to Apple, it actually happens on any type of project when building from the command line using a "scheme" and specifying -sdk as simulator.

I looks like the ARCH and PLATFORM_NAME variables are incorrectly set even though we're specifying -sdk iphonesimulator. My current work around is to specify PLATFORM_NAME=iphonesimulator on top of the -sdk iphonesimulator flag on my xcodebuild command line.

Waiting to hear more from my bug report to Apple.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!