The Road to Enterprise DevOps: Building an iOS Project

1. Install the certificate management plugin Keychains and Provisioning Profiles Management

Keychains and Provisioning Profiles Management is a management plugin for managing local keychains and iOS certificates

Manage Jenkins -> Manage Plugins

picture

After installation, you need to restart the Tomcat service. Otherwise the plugin will not take effect\

2. 配置 Keychains and Provisioning Profiles Management

Manage Jenkins -> Uncategorized

picture

Get the login.keychain file\

cd ~/Library/Keychains
复制代码

picture

Upload the keychain file, because there is no login.keychain file in macOS10.12 and later systems, only the login.keychain-db file, you can make a copy, then delete -db , or you can create a shortcut named login.keychain ie Can. After uploading, the following configuration will appear\

picture

  • Fill in the login password of the current macOS user in the Password field
  • Code Signing Identity Fill in the identifier of the relevant certificate

At present, a debugging certificate and an Ad Hoc release certificate are configured on the computer. Of course, an App Store release certificate is required later. The operation process is the same, and you can handle it yourself later. Go to Keychain Access -> login, find your iPhone Developer and iPhone Distribution certificates, select one of them, then copy the identifier, fill in this location, and save it.

This operation step can be understood as Jenkins has the right to use your computer (login.keychain file) to obtain the certificate (certificate identifier) ​​for debugging and publishing iOS applications.

picture

然后拿到调试证书和 Ad Hoc 证书对应的 .mobileprovision 文件,建议去 Apple 开发者后台去下载,也可以去到 /Users/{username}/Library/MobileDevice/Provisioning Profiles 这个路径下去找;但是如果配置文件太多的话,很难分辨是哪个文件,而且这个地方的名称都是 UUID 值标记的。拿到对应的 .mobileprovision 文件,同样的位置点击上传,出现以下页面:\

picture

会自动识别出 .mobileprovision 文件的 UUID 值。对于 Provisioning Profiles Directory Path,根据 macOS 当前登录的用户名的不同\

/Users/{username}/Library/MobileDevice/Provisioning Profiles
复制代码

这个操作步骤,可以理解为 Jenkins 可以读取位于 /Users/{username}/Library/MobileDevice/Provisioning Profiles 目录下的配置文件,同时知道应该读取那个对应的配置文件(识别 UUID 值)。保存好了之后,整个 iOS 工程项目相关的证书和配置文件都配置好了。

picture

3. 安装 xcode 构建插件 Xcode integration

Manage Jenkins -> Manage Plugins

picture

安装完之后,需要重启一下 Tomcat 服务。否则插件不生效

4. 构建ipk

  • 新建Item

picture

  • 配置代码仓库

picture

  • 添加 Xcode 构建

picture

  • 填写 Development Team ID

picture

**如何获取Team ID,登录苹果后台 developer.apple.com**\

picture

  • 点击 Setting

picture

  • 勾选 Clean before build,意思就是在构造之前先进行环境清理工作

picture

  • 勾选 Generate Archive

picture

勾选后,Xcode Schema File 输入域会提示 When outputting archive or IPA, you need to specify a scheme。如果使用 workspace;而不是project此项必填。与target类似,填写需要构建的schema。\

  • 勾选 Pack application, build and sign .ipa,表示需要生成ipa文件

picture

然后填写以下内容\

picture

Export method:打包方式,包括development、ad-hoc、enterprise 和 app-store 四种方式\

ipa filename pattern:ipa文件的命名规则,如果不填写默认规则是target-version-build,例如xxx-1.0.0-2.ipa。可以使用 V E R S I O N {VERSION} 、 {BUILD_DATE} (yyyy.MM.dd)等系统内置变量值来组合最终的名称,也可以写一个固定的名称。注意不需要填写 .ipa 后缀,Jenkins会自动帮加上。

Output directory:建议不清楚的不要填写,它表示 ipa 输出目录,是一个相对路径,相对于CONFIGURATION_BUILD_DIR 这个默认的 Build 目录或者修改之后的 Build 目录。

6. Code signing & OS X keychain options 配置

  • 点击 Code signing setting...

picture

  • 选择 Read from Xcode Project 和勾选 Unlock Keychain

picture

勾选 Unlock Keychain 后\

picture

Keychain path:填写 login.keychain 文件的路径。意思是找到 login.keychain(登陆钥匙串)。login.keychain文件的路径一般是

${HOME}/Library/Keychains/login.keychain
复制代码

Keychain password:keychain密码

IPA签名的时候,需要 Mac 电脑当前登录的用户授予权限。建议选中,并在“Keychain password”中,输入 Mac 电脑当前用户登录的密码。

7. Advanced Xcode build options 配置

  • 点击 Advanced build settings

picture

然后填写以下内容\

picture

Xcode Project Directory:该目录是指明了包含 xcodeproj 文件的目录\

Xcode Project File:如果需要构建一个 project;而不是一个 workspace 的话则指定文件的名称(后缀名为 xcodeproj 的文件)

Build output directory:该参数只是指明了最终需要产生的动态包。ipa、app 等文件默认路径为所编译的xcodeproj 所在目录,如主项目和 POD 项目整合后,则会在主项目的和 POD 项目的 XCODEPROJ 所在目录(编译产生的相关文件所在目录,默认为 CONFIGURATION)

One parameter that is also very commonly used is OBJROOT. This parameter is the directory where .a and .hmap files are generated. The default path is the directory where the compiled xcodeproj is located. The directory where the XCODEPROJ of the project is located. For the relationship between the three paths of OBJROOT, CONFIGURATION_BUILD_DIR and SYMROOT, you can view the official documentation.

8. Collect ipk results

picture

The constructed ipk package is generally located in the build directory. E.g\

build/**/*.ipk
复制代码

Guess you like

Origin juejin.im/post/7078308793897123847