Wednesday 28 November 2018

Adventures resigning an ipa with xCode 10.1 - aka arm64e causes 'Invalid Swift Support'


Re signing our ipa

I was recently in a position where we needed to re-sign an iOS app. One of my colleagues had already integrated a script into our TFS build process for handling this: github.com/huhuvipi/VH_ipa_packger However we also wanted to ensure that we will be using the same version of support libraries in our package as we have available when we do the signing, so in the loop we also copy the support files from xCode into our app too.


cp -f "${DEVELOPER_DIR}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/${SWIFT_LIB}" "${APP}/Frameworks/${SWIFT_LIB}"

Impact of xCode 10.1

This had been fine until our most recent submission, where we got the following error uploading through App Store Connect:
We identified one or more issues with a recent delivery for your app, "XXX". Please correct the following issues, then upload again.
Invalid Swift Support - The files libswiftCore.dylib, ..., ..., etc. don’t match /Payload/XXX.app/Frameworks/libswiftCore.dylib, ..., ..., etc. Make sure the files are correct, rebuild your app, and resubmit it. Don’t apply post-processing to /Payload/XXX.app/Frameworks/libswiftCore.dylib, ..., ..., etc
One of the things that had changed since our last submission was the version of xCode that we were using. A review of the release notes revealed the following; XCode 10.1 now contains support for a preview of the arm64e architecture but carries the following warning:
The App Store and TestFlight don't accept submissions containing arm64e. xCode will remove arm64e content from your app when you distribute from the Organizer window. (42296212)
Because our continuous integration pipeline pulls the support files directly from xCode, we were now unwittingly packaging arm64e as part of the support files which is not supported on submissions to the store. This consequently reports the 'Invalid Swift Support' message.

We can verify the inclusion of arm64e by interrogating the libraries using the lipo command

lipo -info "${DEVELOPER_DIR}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/${SWIFT_LIB}"

more information on lipo can be found here

Removing the unsupported arm64e architecture

Now we know that we are not allowed to upload arm64e support, and that xCode would normally omit this from the release on our behalf, we can simply do the same and strip the unwanted architecture from the libraries that we are using.

To do this, instead of copying the support files out of xCode we could output the support files with the unsupported architecture removed. ie:
 
lipo "${DEVELOPER_DIR}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/${SWIFT_LIB}" -remove arm64e -output "${TEMP_IPA_BUILT}/SwiftSupport/${SWIFT_LIB}"
and
lipo "${DEVELOPER_DIR}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/${SWIFT_LIB}" -remove arm64e -output "${APP}/Frameworks/${SWIFT_LIB}"

We are now able to submit our app successfully as before.


Finally

When arm64e is supported we can revert back to copying the full support library or we could spin this around and explicitly declare the support we want contained within our swift support libraries.

Most importantly, we can continue signing and submitting our app. Which is nice.