Xcode and Swift Package manager

I'm observing the following error when building an Xcode project that has a number of Swift Packages as dependencies. The error happens only when building on CI (Bitrise). Does anyone have any idea what could cause it?

2021-02-12 13:16:42.779 xcodebuild[2330:13452] [MT] IDEFileReferenceDebug: [Load] 
<IDESwiftPackageCore.IDESwiftPackageDependencyFileReference,
0x7fcb299757f0: name:MyPackage path:absolute:/Users/vagrant/git/archive/checkouts/my-package>
Failed to load container at path: /Users/vagrant/git/archive/checkouts/my-package,
Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6
"Cannot open "my-package" as a "Swift Package Proxy" because it is already
open as a "Swift User Managed Package Folder"." UserInfo={NSLocalizedDescription=Cannot
open "my-package" as a "Swift Package Proxy" because it is already open
as a "Swift User Managed Package Folder".}

More details:

021-02-12 12:15:55.891 xcodebuild[2285:13348] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-17220/IDEFoundation/ProjectModel/Containers/IDEContainer.m:580
Details:  Error: Mismatch between existing container extension: <DVTExtension 0x7ff09ac8f0d0: Swift User Managed Package Folder (Xcode.IDEFoundation.Container.SwiftPackageUserManagedFolder) from com.apple.dt.IDE.IDESwiftPackageSupport> and requested container extension: <DVTExtension 0x7ff09ac8f600: Swift Package Proxy (Xcode.IDEFoundation.Container.SwiftPackageProxy) from com.apple.dt.IDE.IDESwiftPackageSupport> for file path: <DVTFilePath:0x7ff09ea23e80:'/Users/vagrant/git/archive/checkouts/DifferenceKit'>
Object:   <IDEContainer>
Method:   +_retainedContainerAtFilePath:fileDataType:workspace:options:error:
Thread:   <NSThread: 0x7ff0994192d0>{number = 1, name = main}
Hints: 
Backtrace:
  0   -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
  1   _DVTAssertionHandler (in DVTFoundation)
  2   _DVTAssertionFailureHandler (in DVTFoundation)
  3   __82+[IDEContainer _retainedContainerAtFilePath:fileDataType:workspace:options:error:]_block_invoke_2 (in IDEFoundation)
  4   _dispatch_client_callout (in libdispatch.dylib)
  5   _dispatch_lane_barrier_sync_invoke_and_complete (in libdispatch.dylib)
  6   DVTDispatchBarrierSync (in DVTFoundation)
  7   -[DVTDispatchLock performLockedBlock:] (in DVTFoundation)
  8   __82+[IDEContainer _retainedContainerAtFilePath:fileDataType:workspace:options:error:]_block_invoke (in IDEFoundation)
  9   -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation)
 10   +[IDEContainer _retainedContainerAtFilePath:fileDataType:workspace:options:error:] (in IDEFoundation)
 11   +[IDEContainer retainedContainerAtFilePath:fileDataType:workspace:error:] (in IDEFoundation)
 12   -[IDEFileReference _recalculateReferencedContainer] (in IDEFoundation)
 13   -[IDEFileReference referencedContainer] (in IDEFoundation)
 14   __38-[IDEWorkspace _setupContainerQueries]_block_invoke (in IDEFoundation)
 15   -[IDEContainerQuery _processContainerGraphObject:insertedMatches:deletedMatches:] (in IDEFoundation)
 16   -[IDEContainerQuery _traverseContainerGraphObject:forDeletion:checkedContainers:insertedMatches:deletedMatches:] (in IDEFoundation)
 17   -[IDEContainerQuery _traverseContainerGraphObjects:forDeletion:insertedMatches:deletedMatches:] (in IDEFoundation)
 18   -[IDEContainerQuery _objectsDidChange:] (in IDEFoundation)
 19   __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
 20   ___CFXRegistrationPost1_block_invoke (in CoreFoundation)
 21   _CFXRegistrationPost1 (in CoreFoundation)
 22   ___CFXNotificationPost_block_invoke (in CoreFoundation)
 23   -[_CFXNotificationRegistrar find:object:observer:enumerator:] (in CoreFoundation)
 24   _CFXNotificationPost (in CoreFoundation)
 25   -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
 26   -[DVTModelObjectGraph _coalescingTick] (in DVTFoundation)
 27   __58-[DVTModelObjectGraph performBlockCoalescingModelChanges:]_block_invoke (in DVTFoundation)
 28   -[DVTModelGraphTransactionScope performTransaction:] (in DVTFoundation)
 29   -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation)
 30   -[IDEGroup insertGroupSubitems:atIndexes:] (in IDEFoundation)
 31   -[IDEGroup insertObject:inGroupSubitemsAtIndex:] (in IDEFoundation)
 32   -[NSMutableArray(DVTFoundationClassAdditions) dvt_uniqueSortedInsert:withComparator:] (in DVTFoundation)
 33   IDESPMWorkspaceDelegate.dependencyPackageDidUpdate(package:) (in IDESwiftPackageCore)
 34   closure #10 in closure #1 in SPMWorkspace.processPackageGraphActionsInBackgroundIfNeeded() (in SwiftPM)
 35   partial apply for thunk for @callee_guaranteed () -> () (in SwiftPM)
 36   thunk for @escaping @callee_guaranteed () -> () (in SwiftPM)
 37   _dispatch_client_callout (in libdispatch.dylib)
 38   _dispatch_async_and_wait_invoke (in libdispatch.dylib)
 39   _dispatch_client_callout (in libdispatch.dylib)
 40   _dispatch_main_queue_callback_4CF (in libdispatch.dylib)
 41   __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation)
 42   __CFRunLoopRun (in CoreFoundation)
 43   CFRunLoopRunSpecific (in CoreFoundation)
 44   +[DVTKVOConditionValidator waitForCondition:sourceObject:keyPathAffectingConditionBlock:timeout:] (in DVTFoundation)
 45   -[Xcode3CommandLineBuildTool waitForRemoteSourcePackagesToFinishLoading] (in Xcode3Core)
 46   -[Xcode3CommandLineBuildTool _resolveInputOptionsWithTimingSection:] (in Xcode3Core)
 47   -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
 48   main (in xcodebuild)
 49   start (in libdyld.dylib)

We've resolved this by disabling caching on our CI.

Interesting, SPM stores checkouts in DerivedData locally - looks like caching is an essential part of its functions.

I was running into this issue too on Bitrise while using "xcodebuild build test" with some extra flags. After changing this to "xcodebuild test" I solved my issue.

Terms of Service

Privacy Policy

Cookie Policy