Xcodebuild error Swift Package with -derivedDataPath

Hi,

building swift package with Xcode 12.1 and the following command

xcodebuild -enableCodeCoverage YES -derivedDataPath Build/ -scheme FioriSwiftUI-Package -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=14.1,name=iPhone 11' clean build test

results in the following error:

Error: Mismatch between existing container extension: <DVTExtension 0x7fd732e56260: Swift User Managed Package Folder (Xcode.IDEFoundation.Container.SwiftPackageUserManagedFolder) from com.apple.dt.IDE.IDESwiftPackageSupport> and requested container extension: <DVTExtension 0x7fd732e56750: Swift Package Proxy (Xcode.IDEFoundation.Container.SwiftPackageProxy) from com.apple.dt.IDE.IDESwiftPackageSupport> for file path: <DVTFilePath:0x7fd738728c30:'/Users/d041771/git/cloud-sdk-ios-fiori/Build/SourcePackages/checkouts/observable-array'>

Why? How is it possible to build with -derivedDataPath without requiring a xcodeproj file?

Note
  • Building without -derivedDataPath works

  • Building with -derivedDataPath and specifying -project works but is not an option for us as the package shall embed localized resources (swift-tools-version 5.3) in the future and building with xcoceproj will not work then

Replies

I had this same problem and found the solution over at the Swift Forums: https://forums.swift.org/t/xcode-and-swift-package-manager/44704

The TLDR is that the Swift PM cache directory needs to be outside of your main project directory and using -derivedDataPath messes that up. You need to use the -clonedSourcePackagesDirPath parameter as well to point to a directory outside of your project folder to fix it.