由于客户端需要针对不同的后台环境,提供不同的ipa安装包,(供内测、演示和上线使用);现整理如下一套完整的打多个版本ad hoc的ipa包流程。
1、首先,给不同的渠道包确定对应的Bundle Identifier
内测: xxxxxxxxx.debug
演示: xxxxxxxxx.show
上线: xxxxxxxxx
2 、需要生成对应的Provisioning Profile文件:
a、开发者证书,(肯定是有的)
b、生成多个Identifiers (也没啥说的)

c、生成Provisioning Profiles
唯一需要注意的是,每个profiles对应的App ID别弄错了

生成的Provisioning Profiles:

d、最后将这些profile文件下载到本机,然后双击就行了。
3、配置XCode工程
3.1 、 增加Configurations,在Project的Info条目中;

系统创建的时候已经提供了debug和release版本了, 可以直接拿来用,此处只需要增加一个Show的分支。直接Duplicate一个,然后改下名字;
3.2、如果不同版本需要设置不同图标的话,在Assets.xcassets里面设置:

我这里只改了应用的桌面图标。
然后去Build Settings里面修改不同Configuration对应的AppIcon;

3.3、 修改应用app ID
先看一下Info.plist里面默认的参数:

Bundle identifier 、Bundle name 后面的值都是在Build Settings中配置的。改app id 和 应用名,只需要改Bundle identifier和Bundle display name就行了。(Bundle name好像没用到,Bundler display name默认值不是引用的变量,这里的Bundle_Name是我加的配置);
ChannelKey、GroupKey 是我自己加的,用来区分不同后台环境的参数,后面再讲怎么用。

3.4、增加自定义渠道配置参数:

在Build Settings 工具栏最右边的加号。点击后会在最下面生成一栏新的数据,已经包含了3个不同Configuration分支了。只需要改参数名然后给不同的Configuration设置不同的值就行了。

3.5、装载自定义渠道配置参数:
回到Info.plist文件中。直接在字典中加变量就行了,变量后面的值,使用 $(Param_Name) 的形式引用。
4、打包ipa的Scheme配置
入口在 Product ->Scheme->Manager Schemes

默认是有一个Sheme了,这里点击“+”增加两个Sheme,先只需要写一下Sheme的名字就可以了, 然后选中一个,点击左下的“Edit ....”;

以-Show的渠道版本为例,左侧的Run \Test 就不改了,主要改一下Profile和Archive,选中Archive后,Build Configuration下拉菜单包含了我们设置的3中Configuration,这里就选择Show,Archive Name也改一下,后面再Archive的时候好区分。
同样的方式,修改Debug分支和Release分支中的Profile 、 Archive。保证每个Sheme中的Profile、Arichive 对应不同的Configuration。
(我这里Debug版本对应的Sheme直接用了默认的,就没加后缀了,正式上线的sheme加了release的后缀,configuration中debug版本是加了后缀的,release版本没加,懒得改了)
5、打包生成ipa文件
首先,需要选择要执行的Archive Sheme,入口还在Product -> Sheme中,

勾选-show的Sheme,执行Archive。入口在 Product->Archive;

在Archive的窗口中可以发现,嘴边的应用名称已经是对应Configuration中配置的应用名了,点击右边的Export导出 ipa文件。
在导包的引导流程界面中有一步可以看到加载的Profiles对不对,

导包流程其他的步骤就不说了。
然后在选择其他的Sheme,再执行Archive和Export,导出debug和release版本的ipa文件。
网友评论