xcodecocoalumberjack

Building Apps using xcodebuild that depend on CocoaLumberjack installed via SPM


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


Solution

  • 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