Skip to content

Instantly share code, notes, and snippets.

Created May 11, 2015 16:53
  • Star 20 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A quick script to package up an .ipa correctly since `xcodebuild -exportArchive` misses the required SwiftSupport and WatchKitSupport folders
#!/bin/bash -e
# Bundles an iOS app correctly, using the same directory structure that Xcode does when using the export functionality.
build_dir=$(mktemp -d '/tmp/package-ipa.XXXXXX')
echo "build_dir: $build_dir"
if [ ! -d "${xcarchive}" ]; then
echo "Usage: /path/to/app.xcarchive /path/to/ouput.ipa"
exit 1
echo "Packaging ${xcarchive} into ${output_ipa}"
if [ -f "${output_ipa}" ]; then
rm "${output_ipa}"
# if [ -d "${build_dir}" ]; then
# rm -rf "${build_dir}"
# fi
echo "Preparing folder tree for IPA"
mkdir -p "${build_dir}/Payload"
# Copy .app into Payload dir
pushd "${xcarchive}/Products/Applications" > /dev/null
ls -l
cp -Rp ./*.app "${build_dir}/Payload"
popd > /dev/null
# Check for and copy swift libraries
if [ -d "${xcarchive}/SwiftSupport" ]; then
echo "Adding Swift support dylibs"
cp -Rp "${xcarchive}/SwiftSupport" "${build_dir}/"
# Check for and copy WatchKit file
if [ -d "${xcarchive}/WatchKitSupport" ]; then
echo "Adding WatchKit support file"
cp -Rp "${xcarchive}/WatchKitSupport" "${build_dir}/"
echo "Zipping"
pushd "${build_dir}" > /dev/null
zip --symlinks --verbose --recurse-paths "${output_ipa}" .
popd > /dev/null
rm -rf "${build_dir}"
echo "Created ${output_ipa}"
Copy link

Copy link

fvvliet commented Sep 16, 2015

Nice script, works great !!
It doesn't include the Symbols folder, is this folder required ?


Copy link

dlprows commented Oct 8, 2015

There's actually a new flag to use when you're creating your IPA from an XCArchive. That way you won't have to have a custom script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment