当我尝试使用xcodebuild为模拟器构建我的项目时,我面临着奇怪的错误(直接使用Xcode构建它时工作正常).
09:54:55 - tito@lt0311 Game> xcrun xcodebuild -verbose -scheme Game -configuration Debug -sdk iphoneos9.2 -derivedDataPath builds clean build | xcpretty ? Cleaning Game/Game [Debug] ? Check Dependencies ? Clean Succeeded ? Building Game/Game [Debug] ? Check Dependencies ? Compiling AppDelegate.m ? Compiling main.m ? Compiling ViewController.m ? Compiling ViewController.m ? Compiling AppDelegate.m ? Compiling main.m ? Compiling Main.storyboard ? Compiling LaunchScreen.storyboard ? Processing Info.plist ? Touching Game.app ? Signing builds/Build/Products/Debug-iphoneos/Game.app ? Build Succeeded 09:55:06 - tito@lt0311 Game> xcrun xcodebuild -verbose -scheme Game -configuration Debug -sdk iphonesimulator9.2 -derivedDataPath builds clean build | xcpretty ? Cleaning Game/Game [Debug] ? Check Dependencies ? Clean Succeeded ? Building Game/Game [Debug] ? Check Dependencies ? Compiling ViewController.m ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/cdefs.h:707:2: Unsupported architecture #error Unsupported architecture ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/machine/_types.h:34:2: architecture not supported #error architecture not supported ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:55:9: unknown type name '__int64_t' typedef __int64_t __darwin_blkcnt_t; /* total blocks */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:56:9: unknown type name '__int32_t' typedef __int32_t __darwin_blksize_t; /* preferred block size */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:57:9: unknown type name '__int32_t' typedef __int32_t __darwin_dev_t; /* dev_t */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:60:9: unknown type name '__uint32_t' typedef __uint32_t __darwin_gid_t; /* [???] process and group IDs */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:61:9: unknown type name '__uint32_t' typedef __uint32_t __darwin_id_t; /* [XSI] pid_t, uid_t, or gid_t*/ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:62:9: unknown type name '__uint64_t'; did you mean 'uint64_t'? typedef __uint64_t __darwin_ino64_t; /* [???] Used for 64 bit inodes */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:68:9: unknown type name '__darwin_natural_t' typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:70:9: unknown type name '__uint16_t' typedef __uint16_t __darwin_mode_t; /* [???] Some file attributes */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:71:9: unknown type name '__int64_t' typedef __int64_t __darwin_off_t; /* [???] Used for file sizes */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:72:9: unknown type name '__int32_t' typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:73:9: unknown type name '__uint32_t' typedef __uint32_t __darwin_sigset_t; /* [???] signal set */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:74:9: unknown type name '__int32_t' typedef __int32_t __darwin_suseconds_t; /* [???] microseconds */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:75:9: unknown type name '__uint32_t' typedef __uint32_t __darwin_uid_t; /* [???] user IDs */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:76:9: unknown type name '__uint32_t' typedef __uint32_t __darwin_useconds_t; /* [???] microseconds */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types/_intptr_t.h:30:9: unknown type name '__darwin_intptr_t' typedef __darwin_intptr_t intptr_t; ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/_types.h:42:9: unknown type name '__uint32_t' typedef __uint32_t __darwin_wctype_t; ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types/_size_t.h:30:9: unknown type name '__darwin_size_t'; did you mean '__darwin_ino_t'? typedef __darwin_size_t size_t; ^ ? fatal error: too many errors emitted, stopping now [-ferror-limit=] ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKitDefines.h:8:9: could not build module 'Darwin' #import^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11:10: could not build module 'Darwin' #include ~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: could not build module 'CoreFoundation' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/objc/objc.h:31:10: could not build module 'Darwin' #include // for __DARWIN_NULL ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/mach-o/arch.h:32:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/dispatch/dispatch.h:25:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/os/base.h:24:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:32:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:8:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImageDefines.h:10:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CoreVideo.h:16:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTDefines.h:12:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CABase.h:11:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/EAGL.h:8:10: could not build module 'Foundation' #include ~~~~~~~~^ ? /Users/tito/Documents/workspace/Game/Game/ViewController.h:9:9: could not build module 'UIKit' #import ~~~~~~~~^ ? Compiling AppDelegate.m ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/cdefs.h:707:2: Unsupported architecture #error Unsupported architecture ~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/machine/_types.h:34:2: architecture not supported #error architecture not supported ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:55:9: unknown type name '__int64_t' typedef __int64_t __darwin_blkcnt_t; /* total blocks */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:56:9: unknown type name '__int32_t' typedef __int32_t __darwin_blksize_t; /* preferred block size */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:57:9: unknown type name '__int32_t' typedef __int32_t __darwin_dev_t; /* dev_t */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:60:9: unknown type name '__uint32_t'; did you mean 'uint32_t'? typedef __uint32_t __darwin_gid_t; /* [???] process and group IDs */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:61:9: unknown type name '__uint32_t'; did you mean 'uint32_t'? typedef __uint32_t __darwin_id_t; /* [XSI] pid_t, uid_t, or gid_t*/ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:62:9: unknown type name '__uint64_t'; did you mean 'uint64_t'? typedef __uint64_t __darwin_ino64_t; /* [???] Used for 64 bit inodes */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:68:9: unknown type name '__darwin_natural_t' typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:70:9: unknown type name '__uint16_t'; did you mean 'uint16_t'? typedef __uint16_t __darwin_mode_t; /* [???] Some file attributes */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:71:9: unknown type name '__int64_t' typedef __int64_t __darwin_off_t; /* [???] Used for file sizes */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:72:9: unknown type name '__int32_t' typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:73:9: unknown type name '__uint32_t'; did you mean 'uint32_t'? typedef __uint32_t __darwin_sigset_t; /* [???] signal set */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:74:9: unknown type name '__int32_t' typedef __int32_t __darwin_suseconds_t; /* [???] microseconds */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:75:9: unknown type name '__uint32_t'; did you mean 'uint32_t'? typedef __uint32_t __darwin_uid_t; /* [???] user IDs */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types.h:76:9: unknown type name '__uint32_t'; did you mean 'uint32_t'? typedef __uint32_t __darwin_useconds_t; /* [???] microseconds */ ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types/_intptr_t.h:30:9: unknown type name '__darwin_intptr_t' typedef __darwin_intptr_t intptr_t; ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types/_size_t.h:30:9: unknown type name '__darwin_size_t' typedef __darwin_size_t size_t; ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/_types/_ct_rune_t.h:31:9: unknown type name '__darwin_ct_rune_t'; did you mean '__darwin_wctrans_t'? typedef __darwin_ct_rune_t ct_rune_t; ^ ? fatal error: too many errors emitted, stopping now [-ferror-limit=] ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKitDefines.h:8:9: could not build module 'Darwin' #import ^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11:10: could not build module 'Darwin' #include ~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: could not build module 'CoreFoundation' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/objc/objc.h:31:10: could not build module 'Darwin' #include // for __DARWIN_NULL ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/mach-o/arch.h:32:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/dispatch/dispatch.h:25:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/os/base.h:24:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:32:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:8:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImageDefines.h:10:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CoreVideo.h:16:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTDefines.h:12:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CABase.h:11:10: could not build module 'Darwin' #include ~~~~~~~~^ ? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/EAGL.h:8:10: could not build module 'Foundation' #include ~~~~~~~~^ ? /Users/tito/Documents/workspace/Game/Game/AppDelegate.h:9:9: could not build module 'UIKit' #import ~~~~~~~~^ ? Compiling main.m ? Compiling AppDelegate.m ** BUILD FAILED ** The following build commands failed: CompileC builds/Build/Intermediates/Game.build/Debug-iphoneos/Game.build/Objects-normal/arm64/ViewController.o Game/ViewController.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler CompileC builds/Build/Intermediates/Game.build/Debug-iphoneos/Game.build/Objects-normal/armv7/AppDelegate.o Game/AppDelegate.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler (2 failures)
这个命令已经在我刚用Xcode7.2创建的项目上执行.
有谁知道如何解决这些错误?
在苹果论坛用户里面发现了另一种解决方法:
传递
PLATFORM_NAME=iphonesimulator
给xcodebuild
,除了-sdk iphonesimulator
.
通过这种方式,您与模拟器名称或ID无关.
https://forums.developer.apple.com/thread/27975
解决方法是在构建时指定目标参数 -
xcodebuild ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${TARGET_NAME}" -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" **-destination 'platform=iOS Simulator,id=DC050A0D-6041-40F5-9D0E-EAEFA1D1EA42,OS=9.2'** clean build
(如果您只有一个特定类型的模拟器,请将名称替换为"id",例如name = iPhone 6)