2

I'm trying to automate the build of a project that depends on CocoaLumberjack that was installed using Swift Package Manager (SPM). The project builds fine in Xcode (12.5.1 and 13), but fails when building in terminal using xcodebuild. I get an error complaining that the module map isn't found. I've created two new projects, one swift, and one objective-c to replicate the issue. In both cases, things work great from Xcode, but fail on the command line.

Objective-C Error:

fatal error: module map file '/Users/XXX/Development/git/TestAppObjC/build/GeneratedModuleMaps/CocoaLumberjack.modulemap' not found

Swift Error:

<unknown>:0: error: module map file '/Users/XXX/Development/git/TestAppSwift/build/GeneratedModuleMaps/CocoaLumberjackSwiftSupport.modulemap' not found
<unknown>:0: error: module map file '/Users/XXX/Development/git/TestAppSwift/build/GeneratedModuleMaps/CocoaLumberjack.modulemap' not found

The exact command that I'm running:

xcodebuild clean build

Sample Projects:

Objective-C Test App

Swift Test App

  • any luck @jragingfury? feel like this could be due to xcodebuild searching for built spm modules in the wrong location. – markturnip May 31 '22 at 09:55

1 Answers1

1

Passing derivedDataPath to xcodebuild appears to resolve the issue.

You can find the 'Derived Data' path in Xcode preferences.

In my case:

xcodebuild -scheme TestAppSwift -derivedDataPath /Users/mt/Library/Developer/Xcode/DerivedData

Successful build:

note: Build preparation complete
note: Building targets in dependency order
** BUILD SUCCEEDED ** [0.132 sec]

enter image description here

markturnip
  • 405
  • 2
  • 7
  • Note that `scheme` is required when passing `derivedDataPath`: `xcodebuild: error: The flag -scheme, -testProductsPath, or -xctestrun is required when specifying -derivedDataPath.` – markturnip May 31 '22 at 10:08
  • alternative is to pass `clonedSourcePackagesDirPath` – markturnip May 31 '22 at 10:14