Last active
August 28, 2024 13:31
-
-
Save adamzarn/6bb89d91ed4b8c3d3fb25363c221441f to your computer and use it in GitHub Desktop.
A bash script to add the SwiftSupport folder to an .ipa to resolve the ITMS-90426: Invalid Swift Support error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# 1. Copy the script into a text editor and save it with no extension | |
# 2. Make it executable like so: chmod +x path/to/script | |
# 3. Run it from the Terminal in one of two ways: | |
# * path/to/script ipa_path="path/to/ipa" archive_path="path/to/xcarchive" | |
# * path/to/script ipa_path="path/to/ipa" toolchain_path="path/to/toolchain" | |
for ARGUMENT in "$@" | |
do | |
KEY=$(echo $ARGUMENT | cut -f1 -d=) | |
VALUE=$(echo $ARGUMENT | cut -f2 -d=) | |
case "$KEY" in | |
ipa_path) ipaPath=${VALUE} ;; # Format: "Path/to/app.ipa" | |
archive_path) archivePath=${VALUE} ;; # Format: "Path/to/app.xcarchive" | |
toolchain_path) toolchainPath=${VALUE} ;; # Format: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos" | |
*) | |
esac | |
done | |
# Derived Variables | |
ipaDirectory=$(dirname "$ipaPath") | |
ipaName=$(basename "$ipaPath") | |
zipName=${ipaName/.ipa/.zip} | |
appName=${ipaName/.ipa/} | |
zipSuffix=-unzipped | |
unzippedDirectoryName=${appName}${zipSuffix} | |
newIpaSuffix=-with-swift-support | |
newIpaName=${appName}${newIpaSuffix} | |
swiftSupportPath=SwiftSupport/iphoneos | |
ipaSwiftSupportDirectory=${ipaDirectory}/${unzippedDirectoryName}/${swiftSupportPath} | |
# Changes the .ipa file extension to .zip and unzips it | |
function unzipIPA { | |
mv "${ipaDirectory}/${ipaName}" "${ipaDirectory}/${zipName}" | |
unzip "${ipaDirectory}/${zipName}" -d "${ipaDirectory}/${unzippedDirectoryName}" | |
} | |
# Copies the SwiftSupport folder from the .xcarchive into the .ipa | |
function copySwiftSupportFromArchiveIntoIPA { | |
mkdir -p "$ipaSwiftSupportDirectory" | |
cd "${archivePath}/${swiftSupportPath}" | |
for file in *.dylib; do | |
cp "$file" "$ipaSwiftSupportDirectory" | |
done | |
} | |
# Creates the SwiftSupport folder from the Xcode toolchain and copies it into the .ipa | |
function copySwiftSupportFromToolchainIntoIPA { | |
mkdir -p "$ipaSwiftSupportDirectory" | |
cd "${ipaDirectory}/${unzippedDirectoryName}/Payload/${appName}.app/Frameworks" | |
for file in *.dylib; do | |
cp "${toolchainPath}/${file}" "$ipaSwiftSupportDirectory" | |
done | |
} | |
# Adds the SwiftSupport folder from one of two sources depending on the presence of an .xcarchive | |
function addSwiftSupportFolder { | |
if [ -z "$archivePath" ] | |
then | |
copySwiftSupportFromToolchainIntoIPA | |
else | |
copySwiftSupportFromArchiveIntoIPA | |
fi | |
} | |
# Zips the new folder back up and changes the extension to .ipa | |
function createAppStoreIPA { | |
cd "${ipaDirectory}/${unzippedDirectoryName}" | |
zip -r "${ipaDirectory}/${newIpaName}.zip" ./* | |
mv "${ipaDirectory}/${newIpaName}.zip" "${ipaDirectory}/${newIpaName}.ipa" | |
} | |
# Renames original .ipa and deletes the unzipped folder | |
function cleanUp { | |
mv "${ipaDirectory}/${zipName}" "${ipaDirectory}/${ipaName}" | |
rm -r "${ipaDirectory}/${unzippedDirectoryName}" | |
} | |
# Execute Steps | |
unzipIPA | |
addSwiftSupportFolder | |
createAppStoreIPA | |
cleanUp |
The script mentioned above does not add all the *.dylib files to swiftsupport directory. Instead use https://github.com/NityaSantosh26/add-swift-support/blob/main/swift-support
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my case the error was nothing to do with Swift and was because I was trying to include dynamically linked openssl libraries in my app. Whilst this is fine for running an app in the simulator or on a development device, the Apple Store won't accept random libraries in the Frameworks folder and sends this unhelpful message.
The solution was to link the libraries statically. https://forum.qt.io/post/647893