我想使用xcodebuild来存档一个具有3种不同配置的方案,但配置永远不会随着归档操作而改变。
以下是.sh
中的内容xcodebuild -workspace myApp.xcodeproj/project.xcworkspace -sdk iphoneos -scheme myApp -configuration Distribution clean archive
xcodebuild -workspace myApp.xcodeproj/project.xcworkspace -sdk iphoneos -scheme myApp -configuration Inhouse clean archive
xcodebuild -workspace myApp.xcodeproj/project.xcworkspace -sdk iphoneos -scheme myApp -configuration Release clean archive
更新:构建操作正常
xcodebuild -workspace myApp.xcodeproj/project.xcworkspace -sdk iphoneos -scheme myApp -configuration Distribution clean build
xcodebuild -workspace myApp.xcodeproj/project.xcworkspace -sdk iphoneos -scheme myApp -configuration Inhouse clean build
xcodebuild -workspace myApp.xcodeproj/project.xcworkspace -sdk iphoneos -scheme myApp -configuration Release clean build
我正在使用Xcode4.5 / iOS6.0,它可以正常使用构建操作(配置更改每个xcodebuild运行),任何解决方案?
答案 0 :(得分:1)
存档操作的配置无效,可能是xcodebuild的错误。
为了更改存档的配置,我每次在运行archive命令之前编写一个shell脚本更改方案的配置。
可能不是最佳解决方案,但可以解决问题。
以下是代码:
#! /bin/sh
# Define Scheme name
PACKAGE_PROJECT_NAME="MyApp"
PACKAGE_SCHEME_NAME="MyApp"
# Get Username
PACKAGE_USER_NAME="$(whoami)"
# Scheme Path
PACKAGE_SCHEME_DIR="$SRCROOT/${PACKAGE_PROJECT_NAME}.xcodeproj/xcuserdata/${PACKAGE_USER_NAME}.xcuserdatad/xcschemes"
PACKAGE_SCHEME_PATH="${PACKAGE_SCHEME_DIR}/${PACKAGE_SCHEME_NAME}.xcscheme"
echo "PACKAGE_SCHEME_PATH = ${PACKAGE_SCHEME_PATH}"
# Set Configuration
# WARNING: BACKUP_CONFIGURATION MUST be same with build configuration of archive action in MyApp scheme
BACKUP_CONFIGURATION="Distribution"
# WARNING: Archive name of archive action in MyApp scheme MUST be set explicitly.
# WARNING: BACKUP_ARCHIVENAME MUST be same with archive name of archive action in MyApp scheme
BACKUP_ARCHIVENAME="MyAppArchive"
echo "BACKUP_CONFIGURATION = ${BACKUP_CONFIGURATION}"
echo "BACKUP_ARCHIVENAME = ${BACKUP_ARCHIVENAME}"
# -------------------------------Archive Distribution---------------------------------------
# Set Configuration
OLD_CONFIGURATION="${BACKUP_CONFIGURATION}"
NEW_CONFIGURATION="Distribution"
OLD_ARCHIVENAME="${BACKUP_ARCHIVENAME}"
NEW_ARCHIVENAME="${PACKAGE_SCHEME_NAME}_${NEW_CONFIGURATION}"
# Clean
xcodebuild -workspace ${PACKAGE_PROJECT_NAME}.xcodeproj/project.xcworkspace -sdk iphoneos -scheme ${PACKAGE_SCHEME_NAME} -configuration ${NEW_CONFIGURATION} clean
# Change archive configuration
sed -i .bak "/<ArchiveAction/,/<\/ArchiveAction>/{s/\"${OLD_CONFIGURATION}\"/\"${NEW_CONFIGURATION}\"/;s/\"${OLD_ARCHIVENAME}\"/\"${NEW_ARCHIVENAME}\"/;}" ${PACKAGE_SCHEME_PATH}
# Archive
xcodebuild -workspace ${PACKAGE_PROJECT_NAME}.xcodeproj/project.xcworkspace -sdk iphoneos -scheme ${PACKAGE_SCHEME_NAME} archive
# -------------------------------Archive Inhouse------------------------------------------
# Set Configuration
OLD_CONFIGURATION="${NEW_CONFIGURATION}"
NEW_CONFIGURATION="Inhouse"
OLD_ARCHIVENAME="${NEW_ARCHIVENAME}"
NEW_ARCHIVENAME="${PACKAGE_SCHEME_NAME}_${NEW_CONFIGURATION}"
# Clean
xcodebuild -workspace ${PACKAGE_PROJECT_NAME}.xcodeproj/project.xcworkspace -sdk iphoneos -scheme ${PACKAGE_SCHEME_NAME} -configuration ${NEW_CONFIGURATION} clean
# Change archive configuration
sed -i .bak "/<ArchiveAction/,/<\/ArchiveAction>/{s/\"${OLD_CONFIGURATION}\"/\"${NEW_CONFIGURATION}\"/;s/\"${OLD_ARCHIVENAME}\"/\"${NEW_ARCHIVENAME}\"/;}" ${PACKAGE_SCHEME_PATH}
# Archive
xcodebuild -workspace ${PACKAGE_PROJECT_NAME}.xcodeproj/project.xcworkspace -sdk iphoneos -scheme ${PACKAGE_SCHEME_NAME} archive
# -------------------------------Archive Adhoc-------------------------------------------
# Set Configuration
OLD_CONFIGURATION="${NEW_CONFIGURATION}"
NEW_CONFIGURATION="Release"
OLD_ARCHIVENAME="${NEW_ARCHIVENAME}"
NEW_ARCHIVENAME="${PACKAGE_SCHEME_NAME}_${NEW_CONFIGURATION}"
# Clean
xcodebuild -workspace ${PACKAGE_PROJECT_NAME}.xcodeproj/project.xcworkspace -sdk iphoneos -scheme ${PACKAGE_SCHEME_NAME} -configuration ${NEW_CONFIGURATION} clean
# Change archive configuration
sed -i .bak "/<ArchiveAction/,/<\/ArchiveAction>/{s/\"${OLD_CONFIGURATION}\"/\"${NEW_CONFIGURATION}\"/;s/\"${OLD_ARCHIVENAME}\"/\"${NEW_ARCHIVENAME}\"/;}" ${PACKAGE_SCHEME_PATH}
# Archive
xcodebuild -workspace ${PACKAGE_PROJECT_NAME}.xcodeproj/project.xcworkspace -sdk iphoneos -scheme ${PACKAGE_SCHEME_NAME} archive
# ------------------------------Restore Configuration-------------------------------------
sed -i .bak "/<ArchiveAction/,/<\/ArchiveAction>/{s/\"${NEW_CONFIGURATION}\"/\"${BACKUP_CONFIGURATION}\"/;s/\"${NEW_ARCHIVENAME}\"/\"${BACKUP_ARCHIVENAME}\"/;}" ${PACKAGE_SCHEME_PATH}
答案 1 :(得分:0)
使用--scheme
选项时,配置会被Scheme本身的设置覆盖。您需要创建3个不同的方案,并将每个方案配置为使用适当的配置进行存档操作:
或者您根本无法使用方案,并直接在命令行上使用--target
和--configuration
开关。