iOS: <unknown>:0: error: unknown argument: '-enable-batch-mode' Command CompileSwiftSources failed with a nonzero exit code

一个人想着一个人 提交于 2020-06-22 12:37:52

问题


I have an error message that I don't understand. I downloaded on the www.swift.org the swift toolchain 4.0.3 because I had an error message "Module compiled with Swift 4.0.3 cannot be imported by the Swift 4.2 compiler:"

Now, it makes me a different message:

CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target: CameraDemo)
    cd /Users/OlostA/Desktop/Git/r-d/CamBox
    export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
    export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk
    export TOOLCHAINS="org.swift.40320171205a "
    /Library/Developer/Toolchains/swift-4.0.3-RELEASE.xctoolchain/usr/bin/swiftc -incremental -module-name CameraDemo -Onone -enable-batch-mode -enforce-exclusivity=checked -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk -target arm64-apple-ios9.3 -g -module-cache-path /Users/OlostA/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Index/DataStore -swift-version 4 -I /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos -F /Users/OlostA/Desktop/Git/r-d/framework/iphonesimulator -F . -F CameraDemo -F YI360Demo -F . -F CameraDemo -F YI360Demo -F . -F CameraDemo -F YI360Demo -F /Users/OlostA/Desktop/Git/r-d/CamBox/YICamera.framework -F /Users/OlostA/Desktop/Git/r-d/CamBox/SwiftyJSON.framework -F /Users/OlostA/Desktop/Git/r-d/CamBox/CocoaAsyncSocket.framework -F . -F CameraDemo -F YI360Demo -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos/CocoaAsyncSocket.framework -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos/YICamera.framework -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos/CameraDemo.app -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos/CameraDemo.swiftmodule -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos/CameraDemo.app/Frameworks -F /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos/CameraDemo.app/_CodeSignature -F /Users/OlostA/Desktop/Git/r-d/CamBox -c -j4 /Users/OlostA/Desktop/Git/r-d/CamBox/CameraDemo/ViewController.swift /Users/OlostA/Desktop/Git/r-d/CamBox/CameraDemo/AppDelegate.swift -output-file-map /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/Objects-normal/arm64/CameraDemo-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/Objects-normal/arm64/CameraDemo.swiftmodule -Xcc -I/Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/CameraDemo-generated-files.hmap -Xcc -I/Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/CameraDemo-own-target-headers.hmap -Xcc -I/Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/CameraDemo-all-target-headers.hmap -Xcc -iquote -Xcc /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/CameraDemo-project-headers.hmap -Xcc -I/Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Products/Debug-iphoneos/include -Xcc -I/Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/DerivedSources/arm64 -Xcc -I/Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/DerivedSources -Xcc -DDEBUG=1 -emit-objc-header -emit-objc-header-path /Users/OlostA/Library/Developer/Xcode/DerivedData/CameraDemo-atqalgbmsahmkqezdvsdizmgxtek/Build/Intermediates.noindex/CameraDemo.build/Debug-iphoneos/CameraDemo.build/Objects-normal/arm64/CameraDemo-Swift.h -Xcc -working-directory/Users/OlostA/Desktop/Git/r-d/CamBox

<unknown>:0: error: unknown argument: '-enable-batch-mode'
Command CompileSwiftSources failed with a nonzero exit code

May be I have to remove that arguments, but I don't know where to search...

Do you have any ideas?


回答1:


TLDR

There is nothing you can do to fix the issue. Use Xcode 9 or update your codebase to Swift 5.


Full answer:

I encountered the same error, when using Xcode 10 with a Swift 4.0.3 toolchain, to build a project with a static library.

The issue here is as follows: because Xcode 10 operates on Swift 4.2, it composes a compile command for this specific Swift version. Specifically, it adds -enable-batch-mode flag, which optimizes build process. If you remove the flag by hand (e.g. pasting the whole command to Terminal app), it should succeed.

When you change the toolchain, Xcode itself is not smart enough to understand, that there is no such thing as -enable-batch-mode in 4.0.3.

Now, you could disable batch mode, and it should fix the issue, right? You do it in Build Settings, by adding new User-Defined Setting, SWIFT_ENABLE_BATCH_MODE with value NO.

But guess, what happens? Another unknown flag.

<unknown>:0: error: unknown argument: '-disable-batch-mode'
Command CompileSwiftSources failed with a nonzero exit code

Related questions:

  • How can I remove or ignore arguments from the swift compiler
  • Command CompileSwiftSources failed with a nonzero exit code Xcode 10
  • Build failed with "CompileSwiftSources failed with a nonzero exit code"
  • How can I switch to Swift 4.0 in Xcode 9.3?


来源:https://stackoverflow.com/questions/52988852/ios-unknown0-error-unknown-argument-enable-batch-mode-command-compiles

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