Search code examples
iosswiftxcode12apple-appclips

Unable to export App Clip separately with Ad Hoc distribution


I created an App Clip for my App and I am able to launch it from XCode (Version 12.4 (12D4e)) on my iPhone. I can see the App Clip in the App Library of my iPhone.

Next, I want to create an Ad Hoc distribution so my team members can load the App Clip for testing.

According to https://developer.apple.com/documentation/app_clips/distributing_your_app_clip :

"You may also choose Ad Hoc or Development distribution. Note that you need to export the App Clip and the full app separately in these cases."

I do have a separate identifier and Ad Hoc provisioning profile for my App Clip and when I archive my app and select to distribute it Ad Hoc, I ensured both my app and app clip's provisioning profiles are selected and are able to successfully go thru the export process. I also see my app clip in the app's archive and final IPA after export. However, after app thinning, etc, in the final Review ipa screen there is just an Export button that exports the main app's IPA.

How do I export the App Clip separately? I do not see an option to export them separately. After exporting I only see my App's IPA. The App Clip is in my App's IPA but not as a separate entity.

Ad Hoc distribution process

Finally, in my App Thinning Size Report.txt, I do not see any entry for my App Clip. Here is the content:

Variant: XXXXXX.ipa Supported variant descriptors: Universal App + On Demand Resources size: 20.6 MB compressed, 43.1 MB uncompressed App size: 20.6 MB compressed, 43.1 MB uncompressed On-Demand Resources size: Zero KB compressed, Zero KB uncompressed

Would appreciate any help. Thanks.


Solution

  • This is a bug with SPM packages that use binary assets like Instabug in this case.

    The fix incase of plugins is mentioned here.

    The fix in this case of app clips is adding the following snippet in Archive > Post actions -> Run script phase:

    FRAMEWORK_NAME="<ADD THE NAME OF THE BINARY ASSET HERE>"
    APP_PATH=$(dirname "${ARCHIVE_PRODUCTS_PATH}/Applications/${EXECUTABLE_PATH}")
    APPCLIP_FOLDER_PATH="AppClips"
    APPCLIP_INSTABUG="${APP_PATH}/${APPCLIP_FOLDER_PATH}/${FRAMEWORK_NAME}.framework"
    if [ -d "${APPCLIP_INSTABUG}" ]; then
       echo "Removing ${FRAMEWORK_NAME} from appclips at ${APPCLIP_INSTABUG}"
       rm -rf "${APPCLIP_INSTABUG}"
    else
       echo "${FRAMEWORK_NAME} does not exist at ${APPCLIP_INSTABUG}"
    fi
    

    enter image description here