swift-log icon indicating copy to clipboard operation
swift-log copied to clipboard

xcodebuild DocC error with Xcode 14

Open fraune opened this issue 2 years ago • 24 comments

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

fraune avatar Sep 16 '22 16:09 fraune

I have created a repository with the minimum code required to see the error: https://github.com/fraune/xcodebuild-swiftlog-error

fraune avatar Sep 16 '22 16:09 fraune

@fraune Have you found any solution so far? We've seen this error showing up in another project: https://github.com/malcommac/SwiftDate/issues/799

But according to the date of the Swift forums thread, this issue should be unrelated to Xcode 14.

EmDee avatar Sep 21 '22 21:09 EmDee

Haven’t found a solution yet. I am guessing the guys on the Swift forums were getting the same error but unrelated to this package. Downgrading to Xcode 13.4.1 is my current workaround.

fraune avatar Sep 21 '22 22:09 fraune

Is that error preventing editing/opening of the package? I'm told it should be harmless hm...

ktoso avatar Sep 21 '22 22:09 ktoso

I also experienced this issue and had to downgrade to 1.3

JeanAzzopardi avatar Sep 22 '22 12:09 JeanAzzopardi

We're looking into this, thanks for reporting

ktoso avatar Sep 24 '22 01:09 ktoso

Yea, I didn't have trouble importing or using this package when programming or running the app on a device through Xcode. Just having trouble building my app with xcodebuild when this dependency is in my project.

fraune avatar Sep 24 '22 02:09 fraune

Hi, any news on this? i have same problem

javichaques avatar Oct 02 '22 18:10 javichaques

Hello, same problem here. Downgrading to Xcode 13.4.1 solved the problem. (temporarily, until I will really need Xcode 14)

To clarify : issue only appear on command line build (using xcodebuild). Building from Xcode is OK

sebsto avatar Oct 12 '22 15:10 sebsto

This seems fixed for me after renaming the "Docs.docc" folder. Can you check my fork: https://github.com/kalinjul/swift-log

.package(url: "https://github.com/kalinjul/swift-log.git", exact: "1.4.4-fix"),

kalinjul avatar Oct 18 '22 06:10 kalinjul

@kalinjul , that would break the doc generation with SPM's docc plugin, no?

geertbleyen avatar Oct 18 '22 07:10 geertbleyen

Quite possible, but i did want a working library more than documentation. Is the .docc suffix for documentation folders mandatory?

kalinjul avatar Oct 18 '22 11:10 kalinjul

I'm unable to reproduce any actual build issue myself, but I do see the .docc related error. Could someone please post a full build log where we can see any further errors?

neonichu avatar Oct 18 '22 22:10 neonichu

@neonichu iiuc you are saying the .docc message is not preventing a successful build, so may be a "red herring"?

@sebsto @javichaques @geertbleyen or others that reported broken builds - could you provide more information on what prevented the build from succeeding?

tomerd avatar Oct 18 '22 22:10 tomerd

@tomerd, hmmm, for some reason I can't get it to fail the build on that error, it seems to just pass it by in my smaller repro environment. But it still shows this error: 2022-10-19 09:16:05.365 xcodebuild[38506:3571385] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x6000039eb400: name:Documentation.docc path:group:Documentation.docc> Failed to load container at path: /Users/geertbleyen/Library/Developer/Xcode/DerivedData/AppDemo-gzhzregmfuinbmephwjeyzxmqkoz/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".}

geertbleyen avatar Oct 19 '22 07:10 geertbleyen

@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.

sebsto avatar Oct 19 '22 09:10 sebsto

thanks @sebsto the actual build error is

/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
       ^

the docc output here is a red herring afaict. of course there is still the questions of why this is failing only with xcodebuild -quiet, but should probably be tracked separately. cc @neonichu

tomerd avatar Oct 19 '22 17:10 tomerd

Packages aren't really supported in legacy-style builds, the project builds for me when passing -scheme xcodeinstall.

neonichu avatar Oct 19 '22 17:10 neonichu

@tomer agreed but I though the Atomic lib build failed to build because of the error in the preceding steps. Building on Xcode 13 worked (not anymore with this project because I now use swift 5.7 language features)

sebsto avatar Oct 19 '22 18:10 sebsto

@sebsto I am not are the atomic failure is related. something must have changed in Xcode 14 to that, but as @neonichu it may be because this is a less / not supported path for building projects with packages.

tomerd avatar Oct 19 '22 20:10 tomerd

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.

geertbleyen avatar Oct 19 '22 21:10 geertbleyen

As said above, packages aren't supported in legacy-style builds (building without a scheme, which is only possible through xcodebuild), scheme-style builds are of course fine, whether through the IDE or xcodebuild.

neonichu avatar Oct 19 '22 22:10 neonichu

@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".}

sebsto avatar Oct 20 '22 05:10 sebsto

As of Xcode 14.0.1, this issue is not blocking me. I still get the warning message that I listed in my OP, but it no longer prevents me from running my builds.

fraune avatar Oct 31 '22 14:10 fraune