Batch Build and Archive of iOS apps via Terminal

别来无恙 提交于 2019-12-03 03:13:53

I had the same issue with the archive command, and found this question via Google. It would fail with this build command:

xcodebuild -verbose -project $ProductName.xcodeproj -target $ProductName -configuration Release -sdk $SDK clean archive CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build" PROVISIONING_PROFILE="${DIST_PROVISONING_PROFILE}"

Yet, it would succeed with this build command:

xcodebuild -verbose -project $ProductName.xcodeproj -scheme $ProductName -configuration Release -sdk $SDK clean archive CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build" PROVISIONING_PROFILE="${DIST_PROVISONING_PROFILE}"

The only difference is specifying the scheme in lieu of the target to build. If there is a sensible reason for this behavior, I'd enjoy hearing it.

I'm running XCode 4.5.1 on Mac OS X 10.7.5

OK I found a solution that will work. After doing a lot more searching and a lot of guess and check, I found I can still use the "archive" option with xcodebuild, I just have to specify a workspace and scheme and apparently I wasn't doing that correctly before as it now works.

So, for anyone looking for a similar solution (to batch archive xcode projects), here is my function:

# $mybase will be the current directory at the time the function was called
# so make sure to cd into the folder containing the xcode project folders first

function xcodeArchive {
    mybase=$PWD
    for x in `ls`
    do
        cd $mybase/$x
        xcodebuild -workspace $x.xcodeproj/project.xcworkspace -scheme $x archive
        cd $mybase
    done
}
export -f xcodeArchive
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!