使用依赖于通过 SPM 安装的 CocoaLumberjack 的 xcodebuild 构建应用程序

Building Apps using xcodebuild that depend on CocoaLumberjack installed via SPM

我正在尝试自动构建依赖于使用 Swift 包管理器 (SPM) 安装的 CocoaLumberjack 的项目。该项目在 Xcode(12.5.1 和 13)中构建良好,但在使用 xcodebuild 在终端中构建时失败。我收到一条错误消息,抱怨找不到 module map。我创建了两个新项目,一个 swift 和一个 objective-c 来重现这个问题。在这两种情况下,Xcode 都运行良好,但在命令行上失败。

Objective-C 错误:

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

Swift 错误:

<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

我的确切命令是 运行:

xcodebuild clean build

示例项目:

Objective-C Test App

Swift Test App

derivedDataPath 传递给 xcodebuild 似乎可以解决问题。

您可以在 Xcode 首选项中找到 'Derived Data' 路径。

就我而言:

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

构建成功:

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