错误 ITMS-90171:“无效的捆绑结构不允许二进制文件 MyApp.app/libswiftRemoteMirror.dylib

ERROR ITMS-90171: "Invalid Bundle Structure The binary file MyApp.app/libswiftRemoteMirror.dylib is not permitted

我在尝试上传基于 Jenkins 构建的 ipa 时遇到错误。

ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'ideaPitch.app/libswiftRemoteMirror.dylib' is not permitted. Your app can’t contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure."

我如何在 Jenkins 上获取 ipa

   /usr/bin/xcodebuild -list -workspace My_App.xcworkspace
   /usr/bin/xcodebuild -scheme My_App -workspace My_App.xcworkspace -configuration Release clean build CONFIGURATION_BUILD_DIR=${WORKSPACE}/build -UseModernBuildSystem=0
   /usr/bin/xcrun -sdk iphoneos PackageApplication -v "${WORKSPACE}/build/My_App.app" -o ${WORKSPACE}/build/My_App${PRODUCT_VERSION}-${PRODUCT_VERSION}.ipa

   ditto -c -k --keepParent -rsrc "${WORKSPACE}/build/My_App.app.dSYM" ${WORKSPACE}/build/My_App-${PRODUCT_VERSION}-${PRODUCT_VERSION}-dSYM.zip

当我在 Xcode 上获得 ipa 时,一切正常。但是,我需要在 Jenkins 上进行。什么会导致这个问题?谢谢。

EDIT 我搜索了 SO 并找到了一些帖子(如下一个)。但是,我需要找出这个问题的哪一行或代码,所以我不能直接复制并粘贴答案。所以请不要将其标记为重复。

问题是获取构建然后从中获取 iPA。在我搜索时,正确的路径是归档项目,然后使用 xcodebuild 从归档中获取 iPA。

正确的两行代码是;

 /usr/bin/xcodebuild -quiet -workspace ${workspaceName} -scheme ${schemeName} -sdk iphoneos -configuration Release archive -archivePath ${WORKSPACE}/build/${appName}.xcarchive
 /usr/bin/xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/${appName}.xcarchive -exportOptionsPlist My_Project_Main_Folder/Resources/${environment}/${environment}_ExportOptions.plist -exportPath ${WORKSPACE}/build

P.S: PackageApplication和Xcodebuild是有区别的。 Xcodebuild 需要一个导出选项 plist 文件,它告诉 Xcodebuild,它使用什么选项,如证书、配置文件和位码支持等。

示例导出选项 Plist 文件:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>compileBitcode</key>
    <false/>
    <key>destination</key>
    <string>export</string>
    <key>method</key>
    <string>development</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.iamdeveloper.myapp.dev</key>
        <string>My App Development Provision</string>
    </dict>
    <key>signingCertificate</key>
    <string>iPhone Developer</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>XXXXXXXXXX</string>
    <key>thinning</key>
    <string>&lt;none&gt;</string>
</dict>
</plist>