asc-xcode-build
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseXcode Build and Export
Xcode 构建与导出
Use this skill when you need to build an app from source and prepare it for upload to App Store Connect.
当你需要从源码构建应用并准备上传至App Store Connect时,使用本技能。
Preconditions
前置条件
- Xcode installed and command line tools configured
- Valid signing identity and provisioning profiles (or automatic signing enabled)
- 已安装Xcode并配置好命令行工具
- 拥有有效的签名身份和配置文件(或已启用自动签名)
Manage version and build numbers with asc
asc使用asc
管理版本号与构建号
ascBefore archiving, prefer over manual edits when you need to inspect or bump app versions.
asc xcode version ...pbxprojbash
asc xcode version view
asc xcode version edit --version "1.3.0" --build-number "42"
asc xcode version bump --type build
asc xcode version bump --type patchNotes:
- Use when you are not running from the project root.
--project-dir "./MyApp" - Use for deterministic reads in multi-target projects.
--target "App" - These commands support both legacy projects and modern
agvtool/MARKETING_VERSIONsetups.CURRENT_PROJECT_VERSION
在归档之前,当你需要查看或更新应用版本时,优先使用命令,而非手动编辑文件。
asc xcode version ...pbxprojbash
asc xcode version view
asc xcode version edit --version "1.3.0" --build-number "42"
asc xcode version bump --type build
asc xcode version bump --type patch注意事项:
- 如果不是从项目根目录运行命令,请使用参数。
--project-dir "./MyApp" - 在多目标项目中,使用参数以确保读取的确定性。
--target "App" - 这些命令同时支持传统项目和现代
agvtool/MARKETING_VERSION配置。CURRENT_PROJECT_VERSION
iOS Build Flow
iOS 构建流程
1. Clean and Archive
1. 清理并归档
bash
xcodebuild clean archive \
-scheme "YourScheme" \
-configuration Release \
-archivePath /tmp/YourApp.xcarchive \
-destination "generic/platform=iOS"bash
xcodebuild clean archive \
-scheme "YourScheme" \
-configuration Release \
-archivePath /tmp/YourApp.xcarchive \
-destination "generic/platform=iOS"2. Export IPA
2. 导出IPA文件
bash
xcodebuild -exportArchive \
-archivePath /tmp/YourApp.xcarchive \
-exportPath /tmp/YourAppExport \
-exportOptionsPlist ExportOptions.plist \
-allowProvisioningUpdatesA minimal for App Store distribution:
ExportOptions.plistxml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store-connect</string>
<key>teamID</key>
<string>YOUR_TEAM_ID</string>
</dict>
</plist>bash
xcodebuild -exportArchive \
-archivePath /tmp/YourApp.xcarchive \
-exportPath /tmp/YourAppExport \
-exportOptionsPlist ExportOptions.plist \
-allowProvisioningUpdates用于App Store分发的极简:
ExportOptions.plistxml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store-connect</string>
<key>teamID</key>
<string>YOUR_TEAM_ID</string>
</dict>
</plist>3. Upload with asc
3. 使用asc上传
bash
asc builds upload --app "APP_ID" --ipa "/tmp/YourAppExport/YourApp.ipa"bash
asc builds upload --app "APP_ID" --ipa "/tmp/YourAppExport/YourApp.ipa"macOS Build Flow
macOS 构建流程
1. Archive
1. 归档
bash
xcodebuild archive \
-scheme "YourMacScheme" \
-configuration Release \
-archivePath /tmp/YourMacApp.xcarchive \
-destination "generic/platform=macOS"bash
xcodebuild archive \
-scheme "YourMacScheme" \
-configuration Release \
-archivePath /tmp/YourMacApp.xcarchive \
-destination "generic/platform=macOS"2. Export PKG
2. 导出PKG文件
bash
xcodebuild -exportArchive \
-archivePath /tmp/YourMacApp.xcarchive \
-exportPath /tmp/YourMacAppExport \
-exportOptionsPlist ExportOptions.plist \
-allowProvisioningUpdatesbash
xcodebuild -exportArchive \
-archivePath /tmp/YourMacApp.xcarchive \
-exportPath /tmp/YourMacAppExport \
-exportOptionsPlist ExportOptions.plist \
-allowProvisioningUpdates3. Upload PKG with asc
3. 使用asc上传PKG文件
macOS apps export as files. Upload with :
.pkgascbash
asc builds upload \
--app "APP_ID" \
--pkg "/tmp/YourMacAppExport/YourApp.pkg" \
--version "1.0.0" \
--build-number "123"Notes:
- automatically sets platform to
--pkg.MAC_OS - For uploads,
.pkgand--versionare required (they are not auto-extracted like IPA uploads).--build-number - Add if you want to wait for build processing to complete.
--wait
macOS应用会导出为文件,使用上传:
.pkgascbash
asc builds upload \
--app "APP_ID" \
--pkg "/tmp/YourMacAppExport/YourApp.pkg" \
--version "1.0.0" \
--build-number "123"注意事项:
- 参数会自动将平台设置为
--pkg。MAC_OS - 上传文件时,
.pkg和--version为必填参数(不像IPA上传那样会自动提取)。--build-number - 如果需要等待构建处理完成,请添加参数。
--wait
Build Number Management
构建号管理
Each upload requires a unique build number higher than previously uploaded builds.
In Xcode project settings:
- - build number (e.g., "316")
CURRENT_PROJECT_VERSION - - version string (e.g., "2.2.0")
MARKETING_VERSION
Check existing builds:
bash
asc builds list --app "APP_ID" --platform IOS --limit 5每次上传都需要一个比之前上传版本更高的唯一构建号。
在Xcode项目设置中:
- - 构建号(例如:"316")
CURRENT_PROJECT_VERSION - - 版本字符串(例如:"2.2.0")
MARKETING_VERSION
查看已有的构建版本:
bash
asc builds list --app "APP_ID" --platform IOS --limit 5Troubleshooting
故障排查
"No profiles for bundle ID" during export
导出时出现“无对应Bundle ID的配置文件”错误
- Add flag
-allowProvisioningUpdates - Verify your Apple ID is logged into Xcode
- 添加参数
-allowProvisioningUpdates - 验证你的Apple ID已登录Xcode
Build rejected for missing icon (macOS)
构建因缺少图标被拒绝(macOS)
macOS requires ICNS format icons with all sizes:
- 16x16, 32x32, 128x128, 256x256, 512x512 (1x and 2x)
macOS要求ICNS格式的图标包含所有尺寸:
- 16x16、32x32、128x128、256x256、512x512(1倍和2倍分辨率)
CFBundleVersion too low
CFBundleVersion过低
The build number must be higher than any previously uploaded build. Increment it with , or resolve a remote-safe number with and then apply it with before rebuilding.
asc xcode version bump --type buildasc builds next-build-number --app "APP_ID" --version "2.2.0" --platform IOSasc xcode version edit --build-number "NEXT_BUILD"构建号必须高于之前上传过的任何版本。使用命令递增构建号,或者使用获取一个安全的远程可用构建号,然后在重新构建前使用应用该构建号。
asc xcode version bump --type buildasc builds next-build-number --app "APP_ID" --version "2.2.0" --platform IOSasc xcode version edit --build-number "NEXT_BUILD"Notes
注意事项
- Always clean before archive for release builds
- Use to verify configuration
xcodebuild -showBuildSettings - For submission issues (encryption, content rights), see skill
asc-submission-health
- 发布版本构建前务必先执行清理操作
- 使用验证配置
xcodebuild -showBuildSettings - 若遇到提交问题(加密、内容权限等),请查看技能
asc-submission-health