ios 苹果打包——超详细的教程分享

文章目录
前言
本教程手把手教你用 weex+eeui 框架打测试包 ipa 安装到手机(打正式包也有介绍)。
eeui 项目创建可看我的另一篇文章一文带你吃透eeui安卓开发
weex 介绍

Weex 是一个构建移动端跨平台 UI 框架。Weex 使开发人员能够使用类似 Web 的语法通过单一代码库构建 iOS、Android 和 Web 应用。 Vue.js 和 Rax(提供类 React 语法前端框架)这两个前端框架被广泛应用于 Weex 页面开发,同时 Weex 也对这两个前端框架提供了最完善的支持。
eeui 介绍
使用 Vue.js 跨平台开发高质量原生(Android/iOS)应用。
eeui 支持实时同步预览,即修改完代码可以立即查看效果

一、安装 CocoaPods
1.CocoaPods 介绍
CocoaPods 是 OS X 和 iOS 下的一个第三类库管理工具,通过 CocoaPods 工具我们可以为项目添加被称为“Pods”的依赖库(这些类库必须是 CocoaPods 本身所支持的),并且可以轻松管理其版本,可以简单理解为 ios 的 maven 库。
CocoaPods 有两个明显的优势:
1、在引入第三方库时它可以自动为我们完成各种各样的配置,包括配置编译阶段、连接器选项、甚至是 ARC 环境下的-fno-objc-arc 配置等。
2、使用 CocoaPods 可以很方便地查找新的第三方库,这些类库是比较“标准的”,而不是网上随便找到的,这样可以让我们找到真正好用的类库。在使用 CocoaPods 之后,我只需要将用到的第三方开源库放到一个名为 Podfile 的文件中,然后执行 pod install。CocoaPods 就会自动将这些第三方开源库的源码下载下来,并且为我的工程设置好相应的系统依赖和编译参数。
2.CocoaPods 的安装
打开终端:>_
1、查看当前 Ruby 版本
2、升级 Ruby 环境,首先需要安装 rvm(第一步要下载一些东西等两分钟左右)
3、查看 rvm 版本
显示如下(或者是其他版本)
4、列出 ruby 可安装的版本信息
显示如下
5、安装一个 ruby 版本(这里我选择的是 2.5.1 版本,当然你也可以选择其他的)
注意:安装过程中需要两次按下 Enter 键, 第二次按下后需要输入电脑访问密码(不可见,只管输入就行)
如果你电脑没有安装Xcode和Command Line Tools for Xcode以及Homebrew 会自动下载安装,建议提前安装这三者
这里很多小伙伴会遇到错误,大部分是因为没有安装 Homebrew 造成,所以所以所以要提前安装比较好
6、设置为默认版本
7、更换源
8、为了验证你的 Ruby 镜像是并且仅是 ruby-china,执行以下命令查看
如果是以下结果说明正确,如果有其他的请自行百度解决
9、这时候才正式开始安装 CocoaPods
10、如果安装了多个 Xcode 使用下面的命令选择(一般需要选择最近的 Xcode 版本)
11、安装本地库
12、执行以上命令后
然后就是漫长的等待,当然,网络好的情况下会更快…
如果一直安装不成功请参考这里
13、下载安装完成之后可执行下列命令检查是否可用(第一次使用可能要等一会)
14、CocoaPods 的具体使用
新建一个 Xcode 工程,使用终端 cd 到工程目录下
创建 Podfile 文件:
之后就可以在项目目录里看到一个 Podfile 文件
打开 Podfile 文件:
添加:
保存后退出
开始下载:
CocoaPods 版本
二、登录开发者中心
打开链接developer
点击 Account
2.输入帐号密码,点击 Sign In 按钮登录

3.登录后,点击 Certificates,Ldentifiers & Prlfiles,进入页面,所有证书相关的都在这里进行

二、申请 appid
1.点击 App IDs,进入页面

点击右上角的 + 号 来添加一个 APP ID,对于要发布到 Appstore 上的程序, 都有一个唯一的 AppId
填写说明:
Name:可以用 APP 的名称拼音,不能使用特殊字符。
Bundle ID:建议使用 com.yourcompany.yourappname 的格式;
PS: Bundle ID 需要和XCode中 Bundle identifier一致
如果想要支持推送服务和 iCould 等也可以在这儿配置:

出现以下页面,说明申请 appid 成功!

三、申请发布证书(Mac 系统)
1.获取证书请求文件
钥匙串访问 —> 证书助理 —> 从证书颁发机构请求证书
在下图所示的界面,
用户电子邮件地址:填你申请 idp 的电子邮件地址;
常用名称:默认;
CA 空;
选择存贮到磁盘;

点击"继续"

点击“存储:,你就可以看到你的桌面多了一个 CertificateSigningRequest.certSigningRequest 的证书请求文件。

获取 p12 文件
进入 Certificates,Ldentifiers & Prlfiles 页面,点击左边 Certificates 中的 Production
点击 + 号
直接勾选 App Store and Ad Hoc
点击 Continue
出现以下页面,点击 Choose file

选择我们前面生成在桌面的证书请求文件,点击 continue

点击"download"下载你生成的证书

双击文件安装,
钥匙串:登录
点击添加

查看你的钥匙串,应该有下面这一行 Iphone Distribution 的证书,,这个证书有一个小三角可以点击,展开后有一个对应的密钥。

现在发布证书已经安装了,我们选择这个证书,右击,选择导出"iphone Distribution:…",如下:
给你要导出的证书起个名字,如“证书”,选择一个存的位置,注意,保存成 P12 的信息交换文件

输入将来保护输出项目的密码,后面在打开证书文件时需要这个密码登录

现在你就有了发布程序需要的 p12 文件。
3.生成 provisioning 文件
在下图左边选择 Provisioning Profiles 选项下的 Distribution,来生成一个发布的准备文件:

点击 + 号

选择 App Store,其它不用管,点击下面的 Continue 按钮

然后如下图中,选择我们前面创建的 App ID ,点击下面的 Continue 如下图:

然后出现以下这个页面,选择最新的

在新的页面中填写 Profile name,文件名称,下面的 App ID,检查确认是我们之前创建的 appid,这个必须一致。确认后提交:

点击 download,下载 provisioning


四、添加测试手机设备
点击加号添加测试手机
需要使用 iphone 的 uuid 码
可使用iTunes获取手机UUID码(具体自行百度)

添加设备后在 profile 选择要测试的设备后生效(否则不能安装到手机)

五、打包
在 xcode 打开 ios 项目
打开的路径是:项目目录下\platforms\ios\eeuiApp
选择模拟器为 ios Device

选择证书文件,prefile 文件

选择为发布包


打包

导出

这里我们选择打一个测试包(打正式包则选择 app store)

导出到桌面



成功打包出 ipa 包

六、安装到手机
因为苹果ipa无法直接安装ipa,我们找一个第三方安装助手即可
这里我们用爱思助手
下载爱思助手下载
连接手机到电脑

安装

安装成功即可
完成!
总结
每个新手都被各种配置、证书、打包和发布等事情折腾,以及后面 iOS 包审核。众所周知,苹果 App Store 规定非常严格,不过过程虽然复杂,但是在过程中我们确实能学习到很多,也能磨砺耐心。
下一篇更新 eeui 安卓的开发和打包
版权声明: 本文为 InfoQ 作者【清风无影】的原创文章。
原文链接:【http://xie.infoq.cn/article/48898da8211c82c8ca25219d4】。未经作者许可,禁止转载。
评论