HELP! - Building Swift in Xcode error

I'm following Apple/Swift's getting started guide to build Swift for development on my computer.

First, I run this command:

utils/build-script --skip-build-benchmarks \                                        
  --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
  --sccache --release-debuginfo --swift-disable-dead-stripping --test \
  --xcode \

But I get error:

The following build commands failed:
	CompileSwift normal x86_64 /Users/jevonmao/Documents/GitHub/swift-project/swift/validation-test/BuildSystem/swift-cmake/Klass.swift
	CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
ERROR: command terminated with a non-zero exit status 65, aborting

But then I thought, no big deal. I saw the Xcode project was generated and tried to build directly inside Xcode. But I got this error:

I also tried to run tests with command:

utils/run-test --lit ../llvm-project/llvm/utils/lit/lit.py \
  ../build/Xcode-RelWithDebInfoAssert/swift-macosx-$(uname -m)/test-macosx-$(uname -m)

and the vast majority of them failed (6146 failures).


Device and Software Information:

System: macOS Big Sur 11.5 beta
Xcode: Xcode 13.0 beta

Building using swift-frontend scheme

Update 1
I was able to get swift-frontend to build successfully, with help from this Swift forum post by opening and build the CMake Xcode Project. However, there are over 999 warnings so I assume I'm definitely doing something wrong.

The ALL_Build scheme fails to build. Error log below:

Ld /Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/Debug/lib/libTestPureSwiftSharedLib.dylib normal (in target 'TestPureSwiftSharedLib' from project 'Swift')
    cd /Users/jevonmao/Documents/GitHub/swift-project/swift
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-macos11.3 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -L/Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/Debug/lib -L/Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/Debug -L/Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-x86_64/RelWithDebInfo/lib -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/Debug -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -F/Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/Debug/lib -filelist /Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/validation-test/BuildSystem/swift-cmake/Swift.build/Debug/TestPureSwiftSharedLib.build/Objects-normal/x86_64/TestPureSwiftSharedLib.LinkFileList -install_name @rpath/libTestPureSwiftSharedLib.dylib -Xlinker -object_path_lto -Xlinker /Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/validation-test/BuildSystem/swift-cmake/Swift.build/Debug/TestPureSwiftSharedLib.build/Objects-normal/x86_64/TestPureSwiftSharedLib_lto.o -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/validation-test/BuildSystem/swift-cmake/Swift.build/Debug/TestPureSwiftSharedLib.build/Objects-normal/x86_64/TestPureSwiftSharedLib.swiftmodule -Xlinker -compatibility_version -Xlinker 1 -import-objc-header /Users/jevonmao/Documents/GitHub/swift-project/swift/validation-test/BuildSystem/swift-cmake/CPPLib.h -dynamiclib /Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/Debug/lib/libTestCPPLib.a -lc++ -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/validation-test/BuildSystem/swift-cmake/Swift.build/Debug/TestPureSwiftSharedLib.build/Objects-normal/x86_64/TestPureSwiftSharedLib_dependency_info.dat -o /Users/jevonmao/Documents/GitHub/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64/Debug/lib/libTestPureSwiftSharedLib.dylib

clang: error: unknown argument: '-import-objc-header'
clang: error: cannot specify -o when generating multiple output files
Command Ld failed with a nonzero exit code

Failing at validation-test/BuildSystem/swift-cmake/Klass.swift is a known issue. See SR-14725

If that's the case, it would mean that development for Swift is completely offline because no one can even build the project. I don't think the issue is that extreme. So what am I supposed to do? Is there any known workaround or solution?

Actually, I was able to successfully build using this workaround solution: CPPLib_log error when building with Xcode - #12 by LucianoPAlmeida. Thank you for filing a bug report so people can know about this issue.

Terms of Service

Privacy Policy

Cookie Policy