swift-log: xcodebuild DocC error with Xcode 14

Expected behavior

My team and I normally build our app with a CLI command like this:

xcodebuild -quiet -workspace MyApp.xcworkspace -scheme MyApp

Actual behavior

After updating Xcode from 13 to 14, running our xcodebuild command now fails with the following error:

2022-09-16 11:05:28.019 xcodebuild[47484:558966] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x600000287c00: name:Documentation.docc path:group:Documentation.docc> Failed to load container at path: /Users/username/Library/Developer/Xcode/DerivedData/MyApp-darnasgcpehipbceilnyjlqsmpxt/SourcePackages/checkouts/swift-log/Sources/Logging/Documentation.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Documentation.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Documentation.docc" as a "Swift Package Folder" because it is already open as a "Folder".}

Steps to reproduce

  1. Create a brand new Xcode 14 project targeting iOS with Swift/SwiftUI
  2. Under Project Settings, add swift-log (https://github.com/apple/swift-log.git) as a Package Dependency
  3. Navigate to the project’s root folder in Terminal
  4. Execute xcodebuild -quiet
  5. This error shows up

If possible, minimal yet complete reproducer code (or URL to code)

I found a related issue on the Swift forums that was posted a few months back: https://forums.swift.org/t/xcode-and-swift-package-manager/44704

I tried modifying the xcodebuild flags for derivedDataPath and clonedSourcePackagesDirPath, but it did not appear to change how this issue was affecting my builds.

SwiftLog version/commit hash

{
    "package": "swift-log",
    "repositoryURL": "https://github.com/apple/swift-log.git",
    "state": {
        "branch": null,
        "revision": "6fe203dc33195667ce1759bf0182975e4653ba1c",
        "version": "1.4.4"
    }
}

Swift & OS version (output of swift --version && uname -a)

swift-driver version: 1.62.8 Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
Target: x86_64-apple-macosx12.0
Darwin x2-l-fraune 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 5
  • Comments: 24 (8 by maintainers)

Most upvoted comments

We’re looking into this, thanks for reporting

@neonichu @tomerd confirming that xcodebuild -scheme <name> works for me. The Docc error messages are not preventing the build to complete.

2022-10-20 05:42:51.642 xcodebuild[81571:6167958] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x60000074f200: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio-ssl/Sources/NIOSSL/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}

I’m a bit confused. What is this ‘less / not supported path’ or legacy-style builds for building projects with packages? We use xcodebuild in our CI system, and don’t know any other way to build Xcode workspaces (which uses SPM packages). We are passing the sdk to use, which scheme to use, etc… Is there another way to do this?

for example: /usr/bin/xcodebuild -sdk iphoneos -configuration Release -workspace /Users/agent/azagent-A3/_work/3/s/app.xcworkspace -scheme MyScheme build ENABLE_BITCODE=NO CODE_SIGN_STYLE=Automatic | /usr/local/bin/xcpretty -r junit --no-color If there are other ways to do this better, I gladly hear it.

@tomerd here are steps to reproduce on my project

ec2-user@ip-172-31-5-66 ~ % uname -a 
Darwin ip-172-31-5-66.ec2.internal 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:35 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T8101 arm64

ec2-user@ip-172-31-5-66 ~ % xcodebuild -version 
Xcode 14.0.1
Build version 14A400

ec2-user@ip-172-31-5-66 ~ % swift --version 
swift-driver version: 1.62.8 Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
Target: arm64-apple-macosx12.0

ec2-user@ip-172-31-5-66 ~ % ls -al /Applications 
total 0
drwxrwxr-x   8 root      admin  256 Oct 19 09:24 .
drwxr-xr-x  20 root      wheel  640 Aug 11 06:44 ..
-rw-r--r--   1 root      wheel    0 Aug 11 06:44 .localized
drwxr-xr-x@  3 root      wheel   96 Oct 12 18:36 Safari.app
drwxr-xr-x   3 root      wheel   96 Aug 11 06:44 Utilities
drwxr-xr-x   3 ec2-user  staff   96 May 18 04:10 Xcode-13.4.1.app
drwxr-xr-x   3 ec2-user  staff   96 Sep 14 13:01 Xcode-14.0.1.app
lrwxr-xr-x   1 ec2-user  admin   16 Oct 19 09:24 Xcode.app -> Xcode-14.0.1.app
  1. Clone project
ec2-user@ip-172-31-5-66 ~ % git clone https://github.com/sebsto/xcodeinstall.git 
Cloning into 'xcodeinstall'...
remote: Enumerating objects: 1123, done.
remote: Counting objects: 100% (496/496), done.
remote: Compressing objects: 100% (260/260), done.
remote: Total 1123 (delta 281), reused 389 (delta 210), pack-reused 627
Receiving objects: 100% (1123/1123), 50.01 MiB | 59.27 MiB/s, done.
Resolving deltas: 100% (579/579), done.

ec2-user@ip-172-31-5-66 ~ % cd xcodeinstall 
  1. Build using SPM - works
(redacted)
Compiling plugin GenerateManualPlugin...
Building for debugging...
[993/993] Linking xcodeinstall
(redacted)
Compiling plugin GenerateManualPlugin...
Building for debugging...
[993/993] Linking xcodeinstall
Build complete! (50.29s)
  1. Building using xcodebuild - do not work
ec2-user@ip-172-31-5-66 xcodeinstall % xcodebuild -quiet 
2022-10-19 09:52:42.245 xcodebuild[62352:6001462] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x600000487b00: name:Documentation.docc path:group:Documentation.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-argument-parser/Sources/ArgumentParser/Documentation.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Documentation.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Documentation.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
2022-10-19 09:52:42.254 xcodebuild[62352:6001462] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x6000004f3900: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/async-http-client/Sources/AsyncHTTPClient/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
2022-10-19 09:52:42.280 xcodebuild[62352:6001462] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x6000004a1900: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio-ssl/Sources/NIOSSL/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
2022-10-19 09:52:42.287 xcodebuild[62352:6001462] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x6000004a4e00: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio-extras/Sources/NIOHTTPCompression/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
2022-10-19 09:52:42.288 xcodebuild[62352:6001462] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x6000004a5700: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio-extras/Sources/NIOExtras/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
2022-10-19 09:52:42.289 xcodebuild[62352:6001462] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x6000004a6200: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio-extras/Sources/NIOSOCKS/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
2022-10-19 09:52:42.347 xcodebuild[62352:6001462] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x60000045ff00: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio-transport-services/Sources/NIOTransportServices/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
/Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio/Sources/NIOEmbedded/AsyncTestingEventLoop.swift:15:8: error: no such module 'Atomics'
import Atomics
       ^
/Users/ec2-user/Library/Developer/Xcode/DerivedData/xcodeinstall-gcrbebvtaghxhtcomuvtejtakvio/SourcePackages/checkouts/swift-nio/Sources/NIOEmbedded/AsyncTestingEventLoop.swift:15:8: error: no such module 'Atomics'
import Atomics
       ^
warning: Building targets in manual order is deprecated - check "Parallelize build for command-line builds" in the project editor, or set DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING in any of the targets in the current build to suppress this warning
note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'xcodeinstall' from project 'xcodeinstall')
** BUILD FAILED **

Building from Xcode GUI works.