Batch build and archive iOS apps via terminal

I am trying to simplify the process build-> archive-> submit to publish iOS applications. We have more than 50 mobile applications that have an almost identical structure, but with different settings and settings.

I usually downloaded each project in xcode 4.2, and build-> archive-> represented the usual way using the xcode GUI, but now we have more than 50 applications, and this process is very tedious every time you click on the update.

In doing so, I am trying to speed up this process using the shell function. I did a lot of research and found that xcodebuild (see Reid's answer) should work, however the Archive parameter does not work, as I get the following error:

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 works correctly as I expected, except that I do not copy the correct "Info.plist" and I cannot figure out where to copy it or how to generate it. So now I'm stuck.

Xcode recognizes archives, but lists them in the Unknown Schema and Untitled sections of the organizer.

Any help on getting the right Info.plist is welcome.

I also welcome recommendations on how to improve the script and / or a more efficient way to batch build + archive these iOS apps.

Note:

  • I can’t go beyond Xcode 4.2, because this requires (as I understand it) OS X 10.7+, which I still can’t get (company computer).

  • I still really love the newbie bash / shell, so I apologize for any ugly code / practice above.

  • In addition, this is for the official presentation of the application, and not for ad-hoc or something like that.

Thanks again for your help.

+8
bash shell ios .bash-profile
source share
2 answers

OK I found a solution that will work. After a lot of searching and a lot of guesswork and verification, I found that I can still use the “archive” option with xcodebuild, I just need to specify the workspace and scheme, and apparently I didn’t do it right before I got it right now.

So, for those who are looking for a similar solution (for batch archiving of 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 
+1
source share

I had the same problem with the archive team and I found this question via Google. This will not work 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}" 

However, this build command will succeed:

 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 to specify the circuit instead of the target for the assembly. If there is a reasonable reason for this behavior, I will be pleased to hear it.

I am running Xcode 4.5.1 on Mac OS X 10.7.5

+13
source share

All Articles