登陆苹果开发者中心,点击Accounts,在这里须要你填写你的Appple ID进行登陆,若是没有,点击这里申请一个,填写信息就成,这里就再也不赘述。申请完成以后,使用申请的AppID进行登陆。html
进入主页以后,而后点击Join the Apple Developer Program进行开发者帐号申请。点击Enrollreact
这里有几个点须要说明下:android
苹果的开发者帐号主要分为我的、组织(公司/企业)、教育机构ios
类型 | 费用 | 是否支持App Store上架 | 最大支持uuid数量 | 开发人数 | 备注 |
---|---|---|---|---|---|
我的(Individual) | $99 | 支持 | 100 | 1 | 能够转为公司帐号 |
组织(Organization) | $99 | 支持 | 100 | 多人 | 申请时须要填写公司的邓白氏编码(DUNS Number) |
企业程序(Enterprise Program) | $299 | 不支持 | 不限 | 多人 | 申请时须要填写公司的邓白氏编码(DUNS Number) |
点击Start Your Enrollment,目前申请开发者帐号,须要在AppStore下载 Apple Developer而后进行申请。git
点击如今注册
,按照程序一步步填写信息,最后点击订阅便可。github
通常状况下,订阅成功须要两天时间,请耐心等待。shell
小白(在没有查阅资料以前我也是😺)最初看到这三个名词的第一反应多是:证书我听过,可是其余两个是个什么东西,我倒不太清楚。api
这三个文件是作什么的,暂时能够不用了解,如今只须要记住的是:在ios打包的时候须要用到。下面是一个比较完整的ios打包流程图,能够提早帮助理解。xcode
注:以上图片来自于https://reactorapps.io/blog/ios-certificate-guide/ruby
下面,我就用小白的视角来说讲我是怎么认识这三个东西的。
证书是由公证处或认证机关开具的证实资格或权力的证件,它是代表(或帮助判定)事理的一个凭证。证件或凭证的尾部一般会烙印公章。
A certificate is a document that Apple issues to you. This certificate states that you are a trusted developer and that you are in fact, who you claim to be, rather than someone else posing as you.
证书的最主要功效就是证实你是谁以及你是否合法,就像通常开一家餐馆同样,你须要拿到一个营业执照,顾客也就认这个,这里申请的证书是苹果公司颁发的。
网上关于这方面的资料不少,这里不在赘述,能够查看手把手教你搞定ios的证书申请
生成Certificate Signing Request (CSR),填写相关的信息后,保存到本地,会生成一个以.certSigningRequest
结尾的CSR文件
A CSR or Certificate Signing request is a block of encoded text that is given to a Certificate Authority when applying for a certificate.
Certificate
public key
,这个key也会包含在生成的证书中,同时还会在keychian
中生成一个private key
Public-key cryptography, or asymmetric cryptography, is a cryptographic system that uses pairs of keys: public keys, which may be disseminated widely, and private keys,which are known only to the owner.
一个简单的例子,图片来自于https://en.wikipedia.org/wiki/Public-key_cryptography#Examples
一样仍是以开餐馆的例子来说,当餐馆越作越大,须要采购一大批原材料的时候,这时候就须要请示老板了,老板拿了采购单审查了以后,以为没啥问题,而后就会在采购单上签名。采购员拿着有老板签名的采购单,就去采购货物去了。这里面有几个关键点:
其实这就是一个非对称加密的例子,老板的签名样板其实就是一个公钥(public key),餐馆中的任何人均可以知道,而真实的老板签名字样便是私钥(private key),这个签名手法是老板独有的。只有当通过签名以后的采购清单和签名样板进行匹配(这里的匹配其实就是使用公钥解密签名以后的内容)以后,才会认为这个采购单具备效益。
那么同理,怎么认为App是你独有的呢?就须要在发布的时候,对App进行私钥加密,便是数字签名
P12文件中包含了你的证书(包含了你的公钥)和你的私钥。
当你的App须要签名的时候,P12文件会一分为二。私钥用来作数字签名,公钥会打包进入你的app中,这样用户就能够根据app中的公钥来验证你的app的真实性。
咱们能够从下载下来的证书中导出p12文件。
选择Export
,其间会要求你输入密码。
简单来讲,描述文件其实就是一份清单,包含了App中的一些必要信息,主要包括
reverse domain name
的形式出现,例如org.reactjs.native.example.TryWithReactNative
Provisioning Profiles分为两种,一种用于Development
模式,能够供多人测试使用;一种用于Distribution
模式,用于上传App Store。两种文件中的区别是,Distribution Provisioning Profiles中不包含device id。
注:以上图片来自于https://medium.com/@jadhavrajashri49/provisioning-profile-67fad1907694
关于怎么建立,以及建立不一样模式下的Provisioning Profiles,能够参看证书(Certificate)与描述文件(Provisioning Profiles),这里再也不赘述。
证书建立完成后须要把描述文件手动下载到本机
找到你要使用的描述文件(开发者、发布)单击后显示以下内容,单击“Download”后保存到 “/Users/rongshenglai/Library/MobileDevice/Provisioning Profiles” 目录中注意每一个人的我的目录不一样根据状况修改。
下载的文件名相似“XXXX.mobileprovision” 前边的XXXX记录下来它就是描述文件名,使用时不要带.mobileprovision
若是须要真机调试,可是又没法获取苹果开发者中心颁发的证书,那么可使用xcode + 免费的开发者帐号进行personal的证书申请。具体操做以下:
打开xcode
,点击Preferences
选择Accounts
点击左下角+
号,使用Apple Id
建立一个新的帐户。
Apple ID中填写本身在苹果这开发中心申请的帐号,完成后点击Manage Certificates
点击坐下角+
号,建立一个证书便可,完成以后点击Done
回到xcode
的工程目录下,在Signing & Capabilities
面板的Team
下,选择刚刚建立的Team
而后数据线连上真机,点击Run
便可。
最后一步,则是在手机设置 -> 通用 -> 设备管理
中,将未受信任的App置为信任便可。
上面讲解了怎么生成certificates、p12以及provisioning profiles,有了这三个文件,如今就能够来打包发布了。这里采用的是fastlane。
网上关于fastlane上的教程不少,这里只是简单介绍。
fastlane是一个针对iOS和Android应用的Continuous Delivery工具集。可以自动化测试、截图以及管理你的provisioning profiles,为你打包上传应用节省了不少时间。
fastlane is a tool for iOS and Android developers to automate tedious tasks like generating screenshots, dealing with provisioning profiles, and releasing your application.
注:图上的相关stage在最新的fastlane版本中可能有变化,以官网为准。
安装最新的xcode
命令行工具
xcode-select --install
复制代码
安装fastlane
# Using RubyGems sudo gem install fastlane -NV # Alternatively using Homebrew brew install fastlane 复制代码
初始化项目
fastlane init
复制代码
若是你选择了下载已经存在app的元数据,下面是生成的structure
到目前为止,Fastlane的工具集大约包含180多个小工具,基本上涵盖了打包、签名、测试、部署、发布、库管理等等移动开发中涉及到的内容。另外Fastlane自己强大的Action和Plugin机制,可以使你轻松地写出你本身想要的工具。
打包ios以前,最主要的就是要进行代码签名,这也是这篇文章上面讲解的内容。这里主要有几种方式:
A new approach to iOS code signing: Share one code signing identity across your development team to simplify your codesigning setup and prevent code signing issues.
match is the implementation of the codesigning.guide concept. match creates all required certificates & provisioning profiles and stores them in a separate git repository, Google Cloud, or Amazon S3. Every team member with access to the selected storage can use those credentials for code signing. match also automatically repairs broken and expired credentials. It's the easiest way to share signing credentials across teams
官方推荐的形式
使用git/cloud的形式管理证书
可以自动修复和过时的证书
方便在组内分享、管理
match是sync_code_signing
actoin的别名
lane :grant do |options| register_devices(devices_file: "./devices.txt") match( git_url: "git@xxx/certificates.git", type: "development", force_for_new_devices: true, app_identifier: ["org.reactjs.native.example.TryWithReactNative"] ) end 复制代码
若是证书已经搞定,下面就要使用build_app(gym)
打开发包进行测试了
lane :beta do sync_code_signing(type: "development") # see code signing guide for more information build_app(scheme: "TryWithReactNative") upload_to_testflight slack(message: "Successfully distributed a new beta build") end 复制代码
打包完成以后,能够上传到预发布平台进行测试。这里有几个推荐:
fastlane插件
# install fastlane add_plugin appcenter # basic usage appcenter_upload( api_token: "<appcenter token>", owner_name: "<appcenter account name of the owner of the app (username or organization URL name)>", owner_type: "user", # Default is user - set to organization for appcenter organizations app_name: "<appcenter app name (as seen in app URL)>", file: "<path to android build binary>", notify_testers: true # Set to false if you don't want to notify testers of your new release (default: `false`) ) 复制代码
fastlane插件
# install fastlane add_plugin pgyer # basic usage lane :beta do gym pgyer( api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", ) end 复制代码
相似于开发打包过程,不过这里是要上传到苹果app store中,在此以前记得切换生产发布包的provisioning profiles
lane :release do capture_screenshots # generate new screenshots for the App Store sync_code_signing(type: "appstore") # see code signing guide for more information build_app(scheme: "TryWithReactNative") upload_to_app_store # upload your app to App Store Connect slack(message: "Successfully uploaded a new App Store build") end 复制代码
至此,整个App从注册、打包到发布就已经彻底连成一条线了。对于新手小白来讲确时是不太容易,至于最后关于fastlane
讲解的相关部分,由于本身并无我的帐号,采用的是公司生成的证书,因此也没办法亲自操做截图,若是有纰漏,敬请谅解。