背景简介
我们在做项目的过程中很多时候都是会遇到打包的需求,打包就是将我们的工程打成ipa包,然后交给运营或者测试部门去测试。那么这么打包怎么打呢?以下我就会为大家介绍以下打包的最普遍多用的两种方式。
PS: 当然还有很多种打包方式,比如说用Fastlane自动打包,还有自己写自动化打包脚本都可以实现打包的需求。
打包需求
- dev包(开发包)
- dis包(发布包)
- adhoc包(测试包)
- 企业包(这个不常用)
两种方式
- 方式一:常规xcode的organizer导包
- 方式二:拖拽iTunes的快速打包
方式一:常规xcode的organizer导包
- 1、先创建工程,然后编写项目所需代码,创建证书和描述文件,然后配置好,如下:

PS: 如果大家对证书和描述文件的创建有问题的话,请参考以下传送门:
-
2、选择真机或者Generic iOS Device,最好选后者:


PS: 选择模拟器是Archive不了的:

- 3、xcode->product->Archive

- 4、进入如下界面:

- 5、选择右边的Export:

- 6、再次选择要导出为什么包,有三种包dev/dis/adhoc包

- 7、接下来就是校验开发者团队之类的东西了,就不赘述了



- 8、然后点击Export就行了


方式二:拖拽iTunes的快速打包
- 1、先创建工程,然后编写项目所需代码,创建证书和描述文件,然后配置好,点击对应的Target->General,然后按照如下的方式配置:

- 2、找到Edit Scheme:

- 3、Run->info->build configuration:

- 4、如果第三步骤我们选择debug,那么我们此时选择真机或者Generic iOS Device成功编译一遍(command+B)会生成一个.app文件,注意一定要变成黑色,建议运行前command+shift+k 一下:


PS: 如果此处用模拟器去command+B之后生成的.app文件经过后面的步骤生成的.ipa包是没有.mobileprovision这个文件的。所以千万不可以用模拟器打包,建议用Generic iOS Device方式。
- 5、打开iTunes,打开如下图位置,点击刚刚4步骤生成的.app文件,然后将.app文件拖入到iTunes打开的位置空白处:


- 6、拖入后会生成如下图标一样的应用:

- 7、然后再点击如下应用拖动到桌面上就生成了dev的ipa包:

- 8、如果要生成dis的ipa包怎么生成呢?在第3步的时候将debug改成release就可以了,然后再次运行生成.app然后再拖到iTunes上,但是一定要注意要再次运行一遍:

- 9、如果要生成adhoc包怎么办呢?首先要选择正确的描述文件,如果发现dev和dis的描述文件都能够选,就是这个adhoc不能选,但是你刚开始又有双击对应的adhoc描述文件的话,你可 :

-
10、然后再在第3步的时候选择release,然后重新运行一遍程序,生成.app文件,然后拖到iTunes上即可。
Snip20170527_489.png
以上就是两种最常见的打包方式!!!
注意:
- 一定要注意两种方式最好都选用Generic iOS Device方式,也可以选用真机,但最好用前者,然后有人会说如果选择Generic iOS Device之后就运行不了了,是运行不了了但是我们可以Command + B编译一下就会生成.app文件了,并不一定要运行才会生成.app文件,这是个误区。
- 如果选择模拟器打包,那么第一种根本行不通,因为Archive是灰色的,所以有可能的也就只有第二种方式通过iTunes了,通过iTunes方式是可以生成ipa包,但是生成之后是没有以下的embedded.mobileprovision这个文件的,没有这个文件真机无法运行:

- 如果选择模拟器打包之后,生成的ipa包通过iTools去安装的时候也会出现如下的报错提示,如果不知道如何使用iTools安装ipa包的请看iOS的ipa安装到设备上测试:

- 如果选择模拟器打包之后,生成的ipa包通过PP助手去安装的时候也会出现如下的报错提示,如果不知道如何使用PP助手安装ipa包的请看iOS的ipa安装到设备上测试:

大家感兴趣可以去看看iOS-打包成ipa的4种方法
以上!!!

网友评论