Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xcodebuild DocC error with Xcode 14 #234

Open
fraune opened this issue Sep 16, 2022 · 24 comments
Open

xcodebuild DocC error with Xcode 14 #234

fraune opened this issue Sep 16, 2022 · 24 comments

Comments

@fraune
Copy link

fraune commented Sep 16, 2022

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
Copy link
Author

fraune commented Sep 16, 2022

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

@EmDee
Copy link

EmDee commented Sep 21, 2022

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

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

@fraune
Copy link
Author

fraune commented Sep 21, 2022

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.

@ktoso
Copy link
Member

ktoso commented Sep 21, 2022

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

@JeanAzzopardi
Copy link

I also experienced this issue and had to downgrade to 1.3

@ktoso
Copy link
Member

ktoso commented Sep 24, 2022

We're looking into this, thanks for reporting

@fraune
Copy link
Author

fraune commented Sep 24, 2022

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.

@javichaques
Copy link

Hi, any news on this? i have same problem

@sebsto
Copy link

sebsto commented Oct 12, 2022

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

@kalinjul
Copy link

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"),

@geertbleyen
Copy link

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

@kalinjul
Copy link

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

@neonichu
Copy link
Member

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?

@tomerd
Copy link
Member

tomerd commented Oct 18, 2022

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

@geertbleyen
Copy link

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

@sebsto
Copy link

sebsto commented Oct 19, 2022

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

@tomerd
Copy link
Member

tomerd commented Oct 19, 2022

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

@neonichu
Copy link
Member

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

@sebsto
Copy link

sebsto commented Oct 19, 2022

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

@tomerd
Copy link
Member

tomerd commented Oct 19, 2022

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

@geertbleyen
Copy link

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.

@neonichu
Copy link
Member

neonichu commented Oct 19, 2022

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.

@sebsto
Copy link

sebsto commented Oct 20, 2022

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

@fraune
Copy link
Author

fraune commented Oct 31, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants