ios 9.2xcode7.2下批量打渠道包

来源:互联网 发布:迪卡侬14.9背包知乎 编辑:程序博客网 时间:2024/06/10 07:10
前提:

游戏嵌入SDK,用Adhoc配置文件打出母包.ipa,其中渠道id存储在SDK的.bundle的plist文件里。开发人员拿到母包.ipa进行修改,批量打渠道包。在进行解压缩.ipa会破坏之前的签名,所以需要重新企业签名。打开.app会发现有这两个文件。其中_CodeSignature:ipa包签名文件,embedded.mobileprovision:证书配置文件,只要替换了这两个文件就可以解决ipa重签名的主要问题。如下图。



其中还需要用到Entitlements.plist,需要cd到Payload文件下,才可以生成。利用如下shell:
/usr/libexec/PlistBuddy -x -c "print :Entitlements " /dev/stdin <<< $(security cms -D -i production.app/embedded.mobileprovision) > Entitlements.plist
其中Can be debugged(Boolean)为NO。如下图所示:

对于Can be degugged等同于get-task-allow。

其中关于这个属性简介是:get-task-allow, when signed into an application, allows other processes (like the debugger) to attach to your app. Distribution profiles require that this value be turned off, while development profiles require this value to be turned on (otherwise Xcode would never be able to launch and attach to your app).

【翻译过来是:当对应用进行签名时,有了这个属性就可以运行其他的进程访问你的app。发布文件需要这个属性关掉,此文用到的是AdHoc,用到的就是Distribution profiles,所以需要设置为NO,如果是开发文件,这个属性需要开启设置为yes。如果不这样设置的话,Xcode无法启动或者连接到你的应用程序】

【参考连接http://www.cnblogs.com/tekkaman/p/3715560.html

failed to get the task for process问题

A: Why am I getting "Error launching remote program: failed to get the task for process" when debugging an iPhone application on the device?

  You are getting the "Error launching remote program: failed to get the task for process" error message because you areeither using yourAd Hoc orDistribution Provisioning profile when debugging your iPhone application on your device or you specified a code signing entitlements property list in your build settings which does not include aget-task-allow or "Can be debugged" property.

Debugging when using a Distribution Profile

  Distribution profiles don't have a get-task-allow entitlement property, which is needed for debugging iPhone applications. However, this property is available and enabled for Development Provisioning profiles. So, use your Development profile rather than your Distribution profile when debugging your iPhone application on the device.

Missing Entitlement Property】  

  If you specified a code signing entitlements property list in your build settings, make sure that your property list contains theget-task-allow property.


准备资料如下,准备前4个。如下图

1:从企业账号里下载AdHoc配置文件;

2:创建的授权文件;

3:执行批量打包的shell文件;

4:母包ipa;

5:OutApps:存放重新签名渠道包的文件夹。

//--------

打开终端--》cd到当前文件夹

sh TjjApp.sh TjjDemo

就可以了。

其中shell文件如下:

【#!/bin/bash
# 输入的包名
name=$1
#echo 是打印的意思
echo "---ahh---"
echo ${name}
appName="${name}.app"
echo ${appName}
plistBuddy="/usr/libexec/PlistBuddy"
#configName="channel.plist"
configName="Payload/${appName}/JARIDK.bundle/data/JARChannelIDSetting.plist"
configNameNew="Payload"
ipa="${name}.ipa"
# 打好包后输出的文件夹名字
outUpdateAppDir="OutApps"

# 获取当前目录,并切换过去
currDir=${PWD}
echo ${currDir}
cd "${currDir}"
echo "-----${currDir}"


# 生成日志目录
#mkdir log
rm -rf Payload
#解压缩
unzip -o -q ${ipa} #>> log/unzipUpdateApp.log
#echo `ls Payload`

# 删除旧的文件,重新生成
rm -rf "${outUpdateAppDir}"
mkdir "${outUpdateAppDir}"

echo "------------------------开始打包程序------------------------"
#echo ""

# 渠道列表文件开始打包
#for line in $(cat TargetChanelList.txt)
#循环数组,批量打包时需要修改的渠道号和渠道Id
#ChannelID=("1174" "1173" "1156" "1155" "1152" "1184" "1151")
echo ${#ChannelID[@]}
for ((i=0;i<${#ChannelID[@]};i++))

do
    #echo是输出命令,可以忽略
    echo "........正在打包渠道号:${ChannelID[$i]}"

#    cd Payload/${appName}
    # 设置Channel.plist
    echo "-----1----${PWD}"
#修改
    $plistBuddy -c "set :SPREAD_ID ${ChannelID[$i]}" ${configName}

    echo "-----2----${PWD}"

    rm -rf Payload/${appName}/_CodeSignature
#cp AdHoc配置文件 替换 Payload/${appName}文件下的embedded.mobileprovision
    cp AdHocOrgTjj.mobileprovision "Payload/${appName}/embedded.mobileprovision"
#   ipa包签名: codesign -f -s "iPhone Distribution: Distribution证书名字,打开钥匙串可以看到" --entitlements "Entitlements.plist" "Payload/${appName}"

  codesign -f -s "iPhone Distribution:  Distribution证书名字" --entitlements "Entitlements.plist" "Payload/${appName}"
#
 #Payload/TjjDemo.app: replacing existing signature :这个时候是已经OK


    zip -rq "${outUpdateAppDir}/${ChannelID[$i]}.ipa" "Payload"

    echo "........打包已完成"
#    echo ""

done

echo "------------------------程序打包已结束------------------------"


如果安装到手机上是灰色的,就要看看是不是证书的问题【 IOS 开发 证书显示 此证书签发者无效 解决办法】

可以用下面的方法

钥匙串中的所有证书 都 提示此证书签发者无效

经查找得知系统证书WWDR在2016年2月14日失效,需要更新WWDR系统证书

下载证书地址https://developer.apple.com/certificationauthority/AppleWWDRCA.cer 下载之后 双击安装

到这  还需要一步

1.在登录里面删除过期的证书WWDR

2.在系统里面 删除过期的证书WWDR  就可以完美的解决了。所有的证书 都可以使用了

(找不到过期证书?点击显示-->显示已过期的证书。)】

参考链接:

最主要感谢一位前辈的指点

http://www.olinone.com/?p=198【iOS证书及ipa包重签名探究】

http://objccn.io/issue-17-2/【代码签名探析】

0 0
原创粉丝点击