我在 mac Sonoma 14.1.1 上,使用 xcode v.15.0
我正在尝试通过 bash 脚本使用 xcode 构建一个捆绑包,其命令如下所示:
sudo xcodebuild build -project $(dirname "$PWD")/MyProject.xcodeproj -scheme "INTEL_Generic" -derivedDataPath "derData/" -configuration Release HOME=${HOME}
Sudo 用于允许写入权限,HOME 定义是因为 bash 脚本环境不断传递 /var/root/ 作为 home 而不是 /Users/me。
但是,虽然在定义的 /derData 内正确创建了一些日志信息,但应包含我的 .bundle 的 build/Products 文件夹似乎丢失了。
这就是派生数据文件夹包含的内容
我尝试使用product->build从xcode应用程序内部构建,这很好地生成了产品,但即使命令行声明构建成功,也没有生成任何产品或中间体。这是输出
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild build -project /Users/me/Documents/MyProject.xcodeproj -scheme INTEL_Generic -derivedDataPath derData/ -configuration Release HOME=/Users/me
User defaults from command line:
IDEDerivedDataPathOverride = /Users/me/Documents/derData
IDEPackageSupportUseBuiltinSCM = YES
Build settings from command line:
HOME = /Users/me
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:x86_64, id:13BCBEA6-9D69-52BE-9F0C-C03D51DA1439 }
{ platform:macOS, name:Any Mac }
ComputeTargetDependencyGraph
note: Building targets in dependency order
note: Target dependency graph (1 target)
Target 'INTEL_Project' in project 'Project' (no dependencies)
GatherProvisioningInputs
CreateBuildDescription
ClangStatCache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk /Users/me/Documents/derData/SDKStatCaches.noindex/macosx14.0-23A334-4a76ee93ef69e462914ffe9883de22b8.sdkstatcache
cd /Users/me/Documents/MyProject.xcodeproj
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -o /Users/me/derData/SDKStatCaches.noindex/macosx14.0-23A334-4a76ee93ef69e462914ffe9883de22b8.sdkstatcache
** BUILD SUCCEEDED **
尝试将 CONTENTS_FOLDER_PATH 添加到您的
xcodebuild
调用中。
所以你的命令将如下所示:
OUTPUT_DIR= # your output directory
sudo xcodebuild build \
-project $(dirname "$PWD")/MyProject.xcodeproj \
-scheme "INTEL_Generic" \
-derivedDataPath "derData/" \
-configuration Release \
HOME=${HOME} \
CONTENTS_FOLDER_PATH="$OUTPUT_DIR/MyBundle.bundle"