升级成Xcode8之后Qt编译之后经常会出现以下几个错误,其中:
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
这个问题在前一篇中已经解决了,可以参照MAC之Qt在Xcode8上编译错误(一)
下面介绍另外几个常见的错误和解决办法:
错误1:
Project ERROR: Current iphonesimulator SDK version (10.0) is too old. Please upgrade Xcode.
明明已经是最新的SDK版本,但是在编译的过程中还是会说版本不对,我也尝试了最新版本的Qt,在官网下载了Qt 5.7,还是会有这个问题,这里确实是Qt的配置文件不对,需要修改“QT_DIR/5.7/ios/mkspecs/macx-ios-clang/features/sdk.prf”里的内容,直接将:
lessThan(QMAKE_MAC_SDK_VERSION, "8.0"): \
error("Current $$QMAKE_MAC_SDK SDK version ($$QMAKE_MAC_SDK_VERSION) is too old. Please upgrade Xcode.")
这句话删除,不要修改QMAKE_MAC_SDK_VERSION的版本,8.0改成10.0貌似没有用,还是直接删了吧,前后diff的文件如下:
192:features shirny$ diff sdk.prf sdk_bak.prf
14a15,17
> lessThan(QMAKE_MAC_SDK_VERSION, "8.0"): \
> error("Current $$QMAKE_MAC_SDK SDK version ($$QMAKE_MAC_SDK_VERSION) is too old. Please upgrade Xcode.")
>
错误2:
先看看报错,着实很无语:
xcodebuild build -scheme test -sdk iphonesimulator -configuration Debug -destination "id=12.9 inch" -destination-timeout 1
Build settings from command line:
SDKROOT = iphonesimulator10.0
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ id:12.9 inch }
Unsupported device specifier option.
The device “My Mac” does not support the following options: id
Please supply only supported device specifier options.
Available destinations for the "test" scheme:
{ platform:iOS Simulator, id:B3F40C24-5D60-4E50-9752-72FCEBE12124, OS:10.0, name:iPad Air }
{ platform:iOS Simulator, id:0EC6E7D4-29AE-467E-8690-06F5562BCFF3, OS:10.0, name:iPad Air 2 }
{ platform:iOS Simulator, id:277E2258-C60B-4813-BE20-42B7698CEBE5, OS:10.0, name:iPad Pro (9.7 inch) }
{ platform:iOS Simulator, id:63A51897-9CA4-4F78-903B-5DB2D6DA1135, OS:10.0, name:iPad Pro (12.9 inch) }
{ platform:iOS Simulator, id:8D9B0429-EE0B-4F2A-88BD-863FF3363265, OS:10.0, name:iPad Retina }
{ platform:iOS Simulator, id:30B53E9C-785A-49B4-AECE-217CCFD1FA31, OS:10.0, name:iPhone 5 }
{ platform:iOS Simulator, id:E021930D-5D58-4C3E-B0C3-26C2BE7BA28E, OS:10.0, name:iPhone 5s }
{ platform:iOS Simulator, id:7008A8CE-1542-4E3B-8DFA-4D5FD81A6B73, OS:10.0, name:iPhone 6 }
{ platform:iOS Simulator, id:0FD3D8EB-F3FB-4D48-86C3-A92DFA3B1C6E, OS:10.0, name:iPhone 6 Plus }
{ platform:iOS Simulator, id:E455FB97-B46D-47FC-8559-573FF9572196, OS:10.0, name:iPhone 6s }
{ platform:iOS Simulator, id:400435BC-8C7D-42AF-92DD-7D79CE35A7D4, OS:10.0, name:iPhone 6s Plus }
{ platform:iOS Simulator, id:1E6768EC-132A-4997-9052-E1F189466081, OS:10.0, name:iPhone 7 }
{ platform:iOS Simulator, id:7447D592-68E5-44A6-9997-DCC65984EB92, OS:10.0, name:iPhone 7 Plus }
{ platform:iOS Simulator, id:60038664-3B47-4C86-BC52-5C762EFBEC66, OS:10.0, name:iPhone SE }
Ineligible destinations for the "test" scheme:
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
make: *** [xcodebuild-debug-iphonesimulator] Error 70
关于iOS Simulator报错了,修改方法:
进入“QT_DIR/5.7/ios/mkspecs/macx-ios-clang ”修改xcodebuild.mk
Replace:
IPHONESIMULATOR_GENERIC_DESTINATION := "id=$(shell xcrun simctl list devices | grep -E 'iPhone|iPad' | grep -v unavailable | perl -lne 'print $$1 if /((.*?))/' | tail -n 1)"
With:
IPHONESIMULATOR_GENERIC_DESTINATION := "id=$(shell xcrun simctl list devices | grep -E 'iPhone|iPad' | grep -v unavailable | awk 'match ($$0, /\(([A-F0-9\-]*\))/ ) { print substr ($$0, RSTART+1, RLENGTH-2) }' | tail -n 1)"
前后diff的文件对比:
192:macx-ios-clang shirny$ diff xcodebuild.mk xcodebuild_bak.mk
74c74
< IPHONESIMULATOR_GENERIC_DESTINATION := "id=$(shell xcrun simctl list devices | grep -E 'iPhone|iPad' | grep -v unavailable | awk 'match ($$0, /\(([A-F0-9\-]*\))/ ) { print substr ($$0, RSTART+1, RLENGTH-2) }' | tail -n 1)"
---
> IPHONESIMULATOR_GENERIC_DESTINATION := "id=$(shell xcrun simctl list devices | grep -E 'iPhone|iPad' | grep -v unavailable | perl -lne 'print $$1 if /\((.*?)\)/' | tail -n 1)"
你以为到这里就结束了,最起码我是这么认为的。
错误3
The following build commands failed: CopyPNGFile Debug-iphonesimulator/Test01.app/Default-568h@2x.png Test01.xcodeproj/Default-568h@2x.png
这个错误还是Xcode8搞得鬼,原因就是系统有两个xcrun文件,产生了冲突,所以进入“/Applications/Xcode.app/Contents/Developer/usr/bin/”修改“copying”:
Replace:
my $PNGCRUSH = `xcrun -f pngcrush`;
With:
my $PNGCRUSH = `/usr/bin/xcrun -f pngcrush`;
到这里我已经能编译成功了
/usr/bin/codesign --force --sign - --timestamp=none /Users/shirny/build-test-iphonesimulator_clang_Qt_5_7_0_for_iOS-Debug/Debug-iphonesimulator/test.app
/Users/shirny/build-test-iphonesimulator_clang_Qt_5_7_0_for_iOS-Debug/Debug-iphonesimulator/test.app: replacing existing signature
** BUILD SUCCEEDED **
23:44:44: 进程"/usr/bin/make"正常退出。
23:44:44: Elapsed time: 00:02.