xCodeBuild命令行/代码签名失败

时间:2016-08-05 19:16:47

标签: xcode xcode7 xcodebuild

我在xcode 6.3中使用了xcrun而我没有遇到任何问题。

<exec executable="xcrun" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
            <arg line="-sdk ${TARGET_SDK}" />
            <arg line="PackageApplication"/>
            <arg line="-v ${PROJECT_BUILD_LOCATION_SRC}/${IOS_APP_BUNDLE_NAME}.app" />
            <arg line="-o ${PACKAGE_DIR_SRC}/${APP_TARGET}.ipa" />
            <arg line="--sign '${CODE_SIGNING_IDENTITY_SRC}'" />
            <arg line="--embed ${basedir}/${PROVISONING_PROFILE_SRC}" />
        </exec>

然而,在我升级到xCode 7.3.1之后,该命令开始在我们的应用程序上出现问题,在调查之后,我读到我需要使用xcodebuild命令创建存档并使用我们的中断证书导出已签名的ipa文件。

我使用以下内容:

第一:清洁:

<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
            <arg line="-project ${XCODE_PROJECT_NAME}.xcodeproj"/>
            <arg line="-alltargets clean"/>
        </exec>

第二:编译:

<exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}"
            failonerror="true">
            <arg line="-project ${XCODE_PROJECT_NAME}.xcodeproj"/>
            <arg line="-alltargets" />
            <arg line="-sdk ${TARGET_SDK}" />
            <arg line="-arch armv7"/>
            <arg line="-configuration ${CONFIGURATION_NAME}" />
            <arg line="CONFIGURATION_BUILD_DIR='${PROJECT_BUILD_LOCATION_SRC}'"/>
            <arg value="clean"/>
            <arg value="build"/>
        </exec>

第三:创建档案:

      <exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">
            <arg line="-scheme ${XCODE_PROJECT_NAME}" />
            <arg line="-sdk ${TARGET_SDK}" />
            <arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
            <arg line="-configuration ${CONFIGURATION_NAME}" />
            <arg line="archive"/>
        </exec>

Forth:将存档导出到签名的IPA。

         <exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">

            <arg line="-exportArchive"/>
            <arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
            <arg line="-exportPath ${PACKAGE_DIR_SRC}" />
            <arg line="-exportFormat" />
            <arg line="IPA" />
            <arg line="PROVISIONING_PROFILE ${basedir}/${PROVISONING_PROFILE_SRC}" />

        </exec>

但是,我收到此错误:

 Codesign check fails : /var/folders/_y/069ykjxd3hv51j9l62flnq2m0000gn/T/12AEA489-05B5-4682-BE29-7527661382B4-14940-000038AD332AE345/BankMobile.app: a sealed resource is missing or invalid
     [exec] file missing: /private/var/folders/_y/069ykjxd3hv51j9l62flnq2m0000gn/T/12AEA489-05B5-4682-BE29-7527661382B4-14940-000038AD332AE345/BankMobile.app/archived-expanded-entitlements.xcent

我无法创建已签名的IPA文件,我缺少什么?

1 个答案:

答案 0 :(得分:0)

经过三天的研究,我找到了完整的解决方案,如下所示:

首先

在您的Xcode项目中,您需要从ResourcesRules.plist移除Code Signing Resource Rules Path并将other code signing flags设置为--no-strict

enter image description here

第二名:

我删除了问题中提到的所有脚本并添加了以下内容:

    <property name="CONFIGURATION_NAME" value="Release"/>
    <property name="TARGET_SDK" value="iphoneos"/>
    <property name="PROVISONING_PROFILE_SRC" value='"Company Mobile In House Distribution"'/>

    <exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">

                <arg line="-scheme ${XCODE_PROJECT_NAME}" />
                <arg line="-sdk ${TARGET_SDK}" />
                <arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
                <arg line="-configuration ${CONFIGURATION_NAME}" />
                <arg line="clean"/>
                <arg line="archive"/>

            </exec>

             <echo level="info">Exporting the Archive file ${XCODE_PROJECT_NAME}.xcarchive</echo>
             <exec executable="xcodebuild" dir="${IOS_PROJECT_ROOT_SRC}" failonerror="true">

                <arg line="-exportArchive"/>
                <arg line="-archivePath ${IOS_PROJECT_ROOT_SRC}/${XCODE_PROJECT_NAME}.xcarchive" />
                <arg line="-exportPath ${PACKAGE_DIR_SRC}/${APP_TARGET}.ipa" />
                <arg line="-exportProvisioningProfile ${PROVISONING_PROFILE_SRC}"/>
            </exec>

棘手的部分是-exportProvisioningProfile的值。此值配置配置文件的UUID。

在配置文件下的xCode帐户中显示的确切名称,必须被双引号括起来,例如&#34;&#34;。

[仔细查看PROVISONING_PROFILE_SRC值属性并根据您自己的配置名称进行更新,因为我先添加单引号,然后用双引号括起我的配置名称

enter image description here