title: Continuous Integration & Deployment - Xcode 6.1, OS X Server 4, Testflight, Cocoapods
body: <p>With the recent release of Apple software, I could not find any up-to-date solutions for continuous integration &amp; deployment using the new Xcode 6.1, OS X Server 4, and TestFlight (Apple's alpha/beta distribution platform).  After hours of frustration, I was able to get everything working smoothly. I share this in hopes that I might save some of you from having to do the same.</p>
  
  <p>This post is an updated version of Matt Vlasach's blog post found <a href="http://matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/">here</a>.</p>
  
  <p>Anyway, here are the steps...</p>
  
  <p><strong>1. Create and Share New Scheme</strong></p>
  
  <ul>
  <li>Open project in Xcode</li>
  <li>Navigate to the top bar and choose Product > Scheme > Manage Schemes</li>
  <li>Create new scheme, and click the "shared" checkmark</li>
  </ul>
  
  <p><strong>2. Configure Scheme Archive Post-action</strong></p>
  
  <ul>
  <li>Navigate to the top bar and choose Product > Scheme > Manage Schemes</li>
  <li>Select the new scheme and click edit</li>
  <li>Expand the "Archive" dropdown, and select "Post-actions"</li>
  <li>Click the '+' at the bottom to create a “New Run Shell Script” action</li>
  <li>Copy <a href="https://gist.github.com/justinokamoto/9bbe8837081e1aa88041">this</a> script and edit the 5 values enclosed in "&lt;>" tags to match your environment</li>
  </ul>
  
  <p><strong>3. Install Distribution Identity and Provisioning Profiles onto OS X Server</strong></p>
  
  <p>NOTE: These steps should be done on the Mac running OS X Server</p>
  
  <ul>
  <li>If you do not have a valid distribution certificate installed, create (or export) a distribution certificate to your keychain</li>
  <li>The certificate will default to the "login" category in the keychain, simply drag the certificate to the "System" category (located on the sidebar of the Keychain Access app)</li>
  <li>Copy desired provisioning profiles to /Library/Developer/XcodeServer/ProvisioningProfiles/
  <ul>
  <li>Note: You will need to change the folder permissions to access it</li>
  <li>Reminder: Be sure that the provision profiles have been signed with the distribution certificate installed on your machine</li>
  </ul></li>
  </ul>
  
  <p><strong>4. Change Code Signing Resource Rules Path</strong></p>
  
  <p>NOTE: This step is a workaround for an Xcode problem that seems to have been reintroduced in Xcode 6.1</p>
  
  <ul>
  <li>Open project in Xcode</li>
  <li>Navigate to Build Settings</li>
  <li>In the Code Signing section, add <code>$(SDKROOT)/ResourceRules.plist</code> to "Code Signing Resource Rules Path"</li>
  </ul>
  
  <p><strong>5. Commit Changes to Remote Repository</strong></p>
  
  <ul>
  <li>Commit and push changes to remote repository</li>
  </ul>
  
  <p><strong>6. Create and Configure Xcode Bot</strong></p>
  
  <p>NOTE: These steps should be done on the Mac running OS X Server.  Also, if you use SSH to access your project's git repository, there are a multitude of resources that guide you through additional steps in order for your Xcode bot to be allowed access to your repo.</p>
  
  <ul>
  <li>Clone project from remote repository (if needed) and open in Xcode</li>
  <li>Navigate to the top bar and choose Product > Create bot...</li>
  <li>Select the scheme you created</li>
  <li>Enter credentials for accessing the project's repository (if needed)</li>
  <li>Choose desired schedule frequency, actions, etc. and create bot</li>
  </ul>
  
  <p>After you have finished these steps, you should see the bot run an integration, which should clone your project from the remote repository, build it, and upload it to TestFlight!</p>
  
  <p><strong>NOTE:</strong> If you are using <strong>CocoaPods</strong>, when creating the new scheme, make sure the target is set to the workspace.  Also, since Xcode bots and CocoaPods still do not play well together, do not have any files related to CocoaPods in your .gitignore.  There are solutions out there to prevent having to track all these files in your repository, but I have yet to find a reliable solution.</p>