# \[Jenkins] 4. Integration with XCode

(1.) Go to **Jenkins Configuration -> System Setting** page, find '**Xcode Builder** ', input your Team Name and Team ID.

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1oUbSb10jGhpntgeL%2Fimage.png?alt=media\&token=49daa89f-488b-4d61-b8c5-fd1f794a784b)

next, input your Keychain Name and path, you can find **login.keychain-db** under bellow path, the password is the same as what to login your computer.

```
~/Library/Keychains
```

the Keychain Name is your Apple certification title in the Keychain Access App

​

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1oZh3wYtAwhGFAXIy%2Fimage.png?alt=media\&token=2f25f6cb-73ec-42d9-8b35-e5136e04753c)

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1obwirOuzJNl9008-%2Fimage.png?alt=media\&token=f1f45a0f-f794-4c9a-9183-05afe24df3ad)

(2.) Go to **Jenkins Configuration -> Keychains and Provisioning Profiles Management** page, upload your Login keychain and Provisioning Profiles

you can find **login.keychain-db** under bellow path, the password is the same as what to login your computer.

```
~/Library/Keychains
```

change your **login.keychain-db** file name to **login.keychain**, the Code Signing Identity is the same as your Apple certification title title: **iPhone Distribution: Chih-Hao Chen (AD2LB8H35R)**

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1okQAL9Jc-jRfTImQ%2Fimage.png?alt=media\&token=b0828982-5cde-4a2f-bb55-2f61a774f0b1)

upload provisioning profiles of your project, and input the folder path of where you keep the provisioning profiles.

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1op0pUzQ8VP2TwCtj%2Fimage.png?alt=media\&token=97ed1dee-2a79-45df-b49e-2df66cf6a72b)

&#x20;(3.) Go to **Your** **Project -> Configuration -> Build environment** page, check **Keychains and Code Signing Identities** checkbox and select your keychain

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1oshISXsaxnBmOxPo%2Fimage.png?alt=media\&token=fd0760d3-e3d6-46a5-b540-cbee42890e42)

next, check **Mobile Provisioning Profiles** checkbox and select your provisioning profiles

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1ow1aBSzIDeZLkdki%2Fimage.png?alt=media\&token=50640cf6-8474-4c5f-afa3-a86657d81f04)

​

(4.) Go to **Your** **Project -> Configuration -> Build** page, insert **XCode** setting, input your Development team name and target name, the target name is the same as the target in your XCode project.

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1p-7JCO6NNNJp2uRe%2Fimage.png?alt=media\&token=7c907a9e-aa31-4360-91cc-2163949fb159)

next,

* input the **Configuration** column (**Release** or **Debug**)
* input the **Xcode Schema File** column, if you don't use cocoapod in your project, it will be your target name, or......you should google it again.
* **check** the **Generate Archive?** check box.
* **uncheck** the **Pack application, build and sign .ipa?** check box. (for XCode 9 or later)

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1p2nrzYZWYYa_M7lP%2Fimage.png?alt=media\&token=95c2367a-4455-49c7-88f9-d9a196a39de9)

​

(5.) Go to **Your** **Project -> Configuration -> Build -> Code signing & OS X keychain options page,** check the **Unlock Keychain?** check box and select your keychain

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1p7MXdqLmvAU9ldzN%2Fimage.png?alt=media\&token=b8008636-f78a-41b4-bb79-be843b6b3787)

​

(6.) Go to **Your** **Project -> Configuration -> Build** page, insert **a Shell** setting.

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1pAcGPQxJ8ROKqj8l%2Fimage.png?alt=media\&token=5bcb1f3b-a485-43c9-99f8-638e1816f27d)

input below command to export ipa file or your project

```
  xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/Release-iphoneos/PasswordKeeper.xcarchive -exportPath ${WORKSPACE}/build -exportOptionsPlist ${WORKSPACE}/ExportOptions.plist    
```

**Parameters:**

**-archivePath:** you can go to **`/Users/Shared/Jenkins/Home/workspace/yourProject`** directory to find **yourProject.xcarchive**

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1pFqz2H6w0hkF9pyg%2Fimage.png?alt=media\&token=4421c33b-5fee-4bfe-aefb-431df10cec5c)

**​**

**-exportPath:** the output ipa file path

**-exportOptionsPlist:** at first time, you should manual build **Archive** by Xcode and export **archive folder**, you will find an **ExportOptions.plist** file in the folder. Copy the **ExportOptions.plist to** **`/Users/Shared/Jenkins/Home/workspace/yourProject`** directory

![export archive files](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1pKFLzJNh8WprfttA%2Fimage.png?alt=media\&token=6a2289c6-421d-43ff-a43e-0cb79f9807db)

![find ExportOptions.plist in the archive folder](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1pR6g2-BGmvJpwz7N%2Fimage.png?alt=media\&token=9b55f154-237a-4e22-acab-15d02078e93b)

​

![Copy the ExportOptions.plist to /Users/Shared/Jenkins/Home/workspace/yourProject directory](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1pZW8uQn5MmrbnNci%2Fimage.png?alt=media\&token=9311c507-2ae8-49a7-9280-b0d09fa4293a)

(7.) Finally, build your project and you will find the **ipa file at** the export Path

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LI1oGnrtrzyVjxVccjd%2F-LI1peOrT1XKiCw9-xTU%2Fimage.png?alt=media\&token=72a58317-b5cf-4913-b3c8-0a261e44d793)
