简体   繁体   English

通过终端批量构建和存档iOS应用程序

[英]Batch Build and Archive of iOS apps via Terminal

I am trying to simplify the build->archive->submit process for iOS app publishing. 我正在尝试简化iOS应用程序发布的构建 - >存档 - >提交过程。 We have over 50 mobile apps that have nearly identical framework, but with different artwork and configuration settings. 我们有超过50个移动应用程序具有几乎相同的框架,但具有不同的图稿和配置设置。

I normally would load each project in xcode 4.2 and build->archive->submit the usual way with the xcode GUI, but we are up over 50 apps now and this process is very tiresome any time we push out an update. 我通常会在xcode 4.2和build-> archive->中加载每个项目,并使用xcode GUI提交常规方法,但我们现在已经有超过50个应用程序,并且这个过程在我们推出更新时非常烦人。

That being said, I am trying to speed up this process with using a shell function. 话虽这么说,我试图使用shell函数加速这个过程。 I did plenty of research and found that xcodebuild (See Reid's answer) should work, however the Archive option is not working as I get the following error: 我做了大量的研究,发现xcodebuild (请参阅Reid的答案)应该可以工作,但是Archive选项不起作用,因为我收到以下错误:

unsupported build action 'archive'

So I wrote the following: 所以我写了以下内容:

# $1 should be a date like: 2012-07-17
# $2 should be a time like: 10.31AM
# $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 {
    mkdir ~/Library/Developer/Xcode/Archives/$1
    mybase=$PWD
    for x in `ls`
    do
        mkdir ~/Library/Developer/Xcode/Archives/$1/$x
        mkdir ~/Library/Developer/Xcode/Archives/$1/$x/dSYMs
        mkdir ~/Library/Developer/Xcode/Archives/$1/$x/Products
        mkdir ~/Library/Developer/Xcode/Archives/$1/$x/Products/Applications
        cd $mybase/$x
        xcodebuild
        #read -p "Press [Enter] to continue"
        cd $mybase/$x
        cp $x/$x-Info.plist ~/Library/Developer/Xcode/Archives/$1/$x/Info.plist
        cp -r build/Release-iphoneos/$x.app.dSYM ~/Library/Developer/Xcode/Archives/$1/$x/dSYMs/$x.app.dSYM
        cp -r build/Release-iphoneos/$x.app ~/Library/Developer/Xcode/Archives/$1/$x/Products/Applications/$x.app
        cd ~/Library/Developer/Xcode/Archives/$1/
        mv $x $x\ $1\ $2.xcarchive
        cd $mybase
    done
}
export -f xcodeArchive

I put this in my .bash_profile and everything runs correctly as I would expect, except I'm not copying the correct "Info.plist" and I can't figure out where to copy it from or how to generate it. 我把它放在我的.bash_profile中,一切都按照我的预期正确运行,除了我没有复制正确的“Info.plist”,我无法弄清楚从哪里复制它或如何生成它。 So now I am stuck. 所以现在我被卡住了。

Xcode will recognize the archives, but it lists them under "Unknown Schema" and "Unnamed Archive" in the organizer. Xcode将识别存档,但它会在组织者的“Unknown Schema”和“Unnamed Archive”下列出它们。

Any help regarding now to get the correct Info.plist is greatly appreciated. 任何关于现在获得正确的Info.plist的帮助非常感谢。

I also welcome recommendations on how to improve the script and/or a more efficient way to batch build+archive these iOS apps. 我也欢迎有关如何改进脚本和/或更有效地批量构建和存档这些iOS应用程序的建议。

Note: 注意:

  • I am unable to upgrade beyond Xcode 4.2 as that requires (as I understand it) OS X 10.7+ which I am not able to obtain yet (company computer). 我无法升级超出Xcode 4.2,因为这需要(据我所知)OS X 10.7+,我无法获得(公司计算机)。

  • I am still very much a bash/shell novice, so I apologize for any ugly code/practice above. 我仍然是一个bash / shell新手,所以我为上面任何丑陋的代码/做法道歉。

  • Also, this is for official app submission, not for ad-hoc or anything like that. 此外,这是官方应用程序提交,而不是ad-hoc或类似的东西。

Thanks again for your help. 再次感谢你的帮助。

I had the same issue with the archive command, and found this question via Google. 我在archive命令中遇到了同样的问题,并通过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 我在Mac OS X 10.7.5上运行XCode 4.5.1

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. 在做了更多的搜索和大量的猜测和检查后,我发现我仍然可以使用xcodebuild的“archive”选项,我只需要指定一个工作区和方案,显然我之前没有正确地做到这一点作品。

So, for anyone looking for a similar solution (to batch archive xcode projects), here is my function: 因此,对于寻找类似解决方案的任何人(批量存档xcode项目),这是我的功能:

# $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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM