Generate xcarchive into a specific folder from the command line

后端 未结 7 793
南旧
南旧 2020-11-28 23:58

For the purposes of CI, I need to be able to generate an XCARCHIVE and an IPA file in our nightly build. The IPA is for our testers, to be signed with our ad-hoc keys, and t

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 00:30

    My current solution is to rename the user's existing archives folder, run the build, and do a 'find' to copy the archives where i want, then delete the archives folder and rename the old folder back as it was, with code like this in my ruby build script:

    # Move the existing archives out of the way
    system('mv ~/Library/Developer/Xcode/Archives ~/Library/Developer/Xcode/OldArchivesTemp')
    # Build the .app, the .DSYM, and the .xcarchive
    system("xcodebuild -scheme \"#{scheme}\" clean build archive CONFIGURATION_BUILD_DIR=\"#{build_destination_folder}\"")
    # Find the xcarchive wherever it was placed and copy it where i want it
    system("find ~/Library/Developer/Xcode/Archives -name *.xcarchive -exec cp -r {} \"#{build_destination_folder}\" \";\"")
    # Delete the new archives folder with this new xcarchive
    system('rm -rf ~/Library/Developer/Xcode/Archives')
    # Put the old archives back
    system('mv ~/Library/Developer/Xcode/OldArchivesTemp ~/Library/Developer/Xcode/Archives')
    

    Its a bit hacky but i don't see a better solution currently. At least it preserves the user's 'archives' folder and all their pre-existing archives.

    --Important note!--

    I since found out that the line of code where i find the archive and cp it to the folder i want doesn't copy the symlinks inside the archive correctly, thus breaking the code signing in the app. You'll want to replace that with a 'mv' or something that maintains symlinks. Cheers!

提交回复
热议问题