SwiftSupport folder not included in the IPA when generating build from script

帅比萌擦擦* 提交于 2020-07-10 06:26:32

问题


The project is in Objective-C and we recently added some swift files into it. It is a white label application and builds are generated from the server.

When I submit the build to appstore it gave error :-

ITMS-90426: Invalid Swift Support - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.

When I debugged the issue I find out the build generated from automation is now having SwiftSupport in IPA while when I generate the build from my system is does have the IPA

I cannot post the whole script here because it does have important information and I'm not allowed to share it but here a little snippet with some predefined variables :-

function xc_package
{
    echo "Building scheme \"$3\" => $1"
    
    # Calculated paths
    
    APP_IPA="$1/$APPNAME.ipa"
    APP_APP="$1/$APPNAME.app"
    APP_DSYM="$1/$APPNAME.app.dSYM"
    APP_DSYM_ZIP="$1/$APPNAME.dSYM.zip"
    PROFILE="$4"
    UUID=`uuid_from_profile "$PROFILE"`

    [ -n "$UUID" ] || failed "Failed - missing provisioning profile UUID"
    echo "Building with Provisioning Profile $UUID (${PROFILE})"
    
    # Unlock keychain
        
    echo "Unlocking keychain..."
     security unlock-keychain -p "$BUILD_KEYCHAIN_PW" "${HOME}/Library/Keychains/login.keychain" || failed "Failed unlocking keychain"

        
    # xcodebuild
    XCODE_VERSION=`xcodebuild -version`
    XCODE_PATH=`xcode-select -p`
    echo "Building with $XCODE_VERSION in $XCODE_PATH profile : $UUID"

    export LC_CTYPE=en_US.UTF-8

    echo "xcodebuild -> -scheme $3 -> clean build ->  CONFIGURATION_BUILD_DIR -> $1 PROVISIONING_PROFILE_SPECIFIER -> $UUID CODE_SIGN_IDENTITY -> $5"

#-workspace "Motto_Mobile_New.xcworkspace" \
#-configuration Release

    xcodebuild \
    -scheme "$3" \
    -configuration Release \
    clean build \
    CONFIGURATION_BUILD_DIR="$1" \
    PROVISIONING_PROFILE_SPECIFIER="$UUID" \
    CODE_SIGN_IDENTITY="$5" | xcpretty || failed "Failed building"


    # Package IPA
    echo "Packaging IPA..."
    xcrun -sdk iphoneos \
    PackageApplication "$APP_APP" \
    -o "$APP_IPA" \
    --embed "$PROFILE" || failed "Failed packaging"
    
    # Zip dSYM
    echo "Zipping .dSYM..."
    zip -qr "$APP_DSYM_ZIP" "$APP_DSYM"
        
    echo "Generating Symbols and repackaging IPA..."
    
    SYMBOLS="$(xcode-select -p)/usr/bin/symbols"
    IPA_DIR="$1/IPA_TMP"
    
    rm -R "$IPA_DIR"
    
    unzip -q "$APP_IPA" -d "$IPA_DIR"
    
    
    mkdir -p "$IPA_DIR/Symbols"
    
    echo "$BUILD_KEYCHAIN_PW" | sudo -S $SYMBOLS -noTextInSOD -noDaemon -arch all \
    -symbolsPackageDir "$IPA_DIR/Symbols" \
    "${IPA_DIR}/Payload/${APPNAME}.app/$APPNAME"
    
    
    cd "$IPA_DIR" && zip -qr "$APP_IPA" .
}

This function has been called with these parameters

xc_package \
"$current_path/build" \
"'preprocess_defines'" \
"Motto_Mobile_New" \
"$profile_fullpath" \
"$certificate_name"

cd ${current_path}
cp "build/${APPNAME}.ipa" "build/${file_name}.ipa"

cp "build/${file_name}.ipa" "/$resourceDirPath/${file_name}.ipa"

回答1:


After your PackageApplication step, you should have an .xcarchive and an .ipa. I can't be sure why you don't have a SwiftSupport folder in your original .ipa (in my case it was because it was exported for enterprise distribution), but you should be able to just copy the SwiftSupport folder from the .xcarchive into your unzipped .ipa, right after the unzip step:

unzip -q "$APP_IPA" -d "$IPA_DIR"

# Copies the SwiftSupport folder from the .xcarchive into the .ipa
mkdir -p "${IPA_DIR}/SwiftSupport/iphoneos"
cd "${archivePath}/SwiftSupport/iphoneos"
for file in *.dylib; do
    cp "$file" "${IPA_DIR}/SwiftSupport/iphoneos"
done

You can also create the SwiftSupport folder using the Xcode toolchain like this:

# Creates the SwiftSupport folder from the Xcode toolchain and copies it into the .ipa
mkdir -p "${IPA_DIR}/SwiftSupport/iphoneos"
cd "${IPA_DIR}/Payload/${appName}.app/Frameworks"
for file in *.dylib; do
  cp "${toolchainPath}/${file}" "${IPA_DIR}/SwiftSupport/iphoneos"
done

This looks in the .app/Frameworks folder to see which .dylib files should be in the SwiftSupport folder.

For Xcode 11, this should be the toolchain path:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos


来源:https://stackoverflow.com/questions/62635971/swiftsupport-folder-not-included-in-the-ipa-when-generating-build-from-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!