Skip to content

Instantly share code, notes, and snippets.

@mtitolo
Last active December 18, 2015 17:09
Show Gist options
  • Save mtitolo/f5283c54e300d88d9418 to your computer and use it in GitHub Desktop.
Save mtitolo/f5283c54e300d88d9418 to your computer and use it in GitHub Desktop.
CocoaPods & Pre-Build actions for Xcode CI

To run pod install as a pre-build action for your target using RVM, follow these easy steps.

  1. Duplicate your main scheme, and make sure it's shared
  2. Navigate to the Edit Build section of your new scheme
  3. Uncheck Find Implicit Dependencies (otherwise Xcode will stop the build when the workspace contents change)
  4. Go into the Pre-actions subsection
  5. Add a new run script with the following content:
source "$HOME/.rvm/scripts/rvm"
rvm use ruby-1.9.3-p194 # whichever version of Ruby you installed the cocoapods gem to
cd ${SRCROOT}
pod install
  1. Change the Shell to /usr/bin/env bash and make sure to Provide Build Settings from your target
  2. Click OK
  3. Switch to the new scheme, and build!

To run pod install as a pre-build action for your target using the system Ruby, follow these easy steps.

  1. Duplicate your main scheme, and make sure it's shared
  2. Navigate to the Edit Build section of your new scheme
  3. Uncheck Find Implicit Dependencies (otherwise Xcode will stop the build when the workspace contents change)
  4. Go into the Pre-actions subsection
  5. Add a new run script with the following content:
cd ${SRCROOT}
pod install
  1. Click OK
  2. Switch to the new scheme, and build!

##So you want to use CocoaPods with the new CI stuff in OS X Server?

###Updates for DP4+ Including GM#### Unless you check in your Pods folder, this won't work in DP4+ due to some compiler bugs. See this post on the dev forums which has a link to a summary, and a radar to dupe. Please dupe the radar posted if you would like to use CocoaPods with Bots.

###Instructions < DP4 Unlike other CI systems you may be familiar with, the Xcode CI on OS X Server doesn't have the concept of build steps.

So if you want to run pod install before each build, you need to add it as a pre-build action on your scheme.

These are the instructions for setting this up when you have CocoaPods installed on the system Ruby, and using RVM.

Note: To get this working as of the current state of OS X Server and Xcode 5, your project can no longer find implicit dependencies. You need to explicitly add dependencies to your project. (rdar://14221932)

###Instructions DP4+ You need to check in your Pods folder. If you don't want to do this, please see the dev forum post in the update above.

@irace
Copy link

irace commented Jun 27, 2013

I'm using the system Ruby. No, we do not check Pods or .xcworkspace into source control, they are both generated by the CocoaPods tool at pod install time.

@mtitolo
Copy link
Author

mtitolo commented Jun 27, 2013

You need to check in the generated .xcworkspace for this to work, and setup the Bot to build that file.

@irace
Copy link

irace commented Jun 27, 2013

Interesting. Out of curiosity, is checking in the .xcworkspace file something that you or other CocoaPods users actually find to be useful, or something done begrudgingly simply to make the Bot work? I've never considered checking it in until now.

Also, what exactly do you mean when you say "setup the Bot to build that file"?

@mtitolo
Copy link
Author

mtitolo commented Jun 27, 2013

After pod install is run the first time, that file is unlikely to change. A .xcworksapce file is just XML that references one or more .xcodeproj files. Not sure about the other team members, but of all the CocoaPods files I only check in the .xcworkspace, Podfile, and Podfile.lock.

If you have your .xcworkspace open, when creating a Bot it should automatically setup to build that file. If you created your bot and it's not looking at the right .xcoworkspace, you can change which .xcodeproj or .xcworkspace is used to build in Bot Settings (so you don't have to go through and recreate it, which IMHO is a PITA).

@mtitolo
Copy link
Author

mtitolo commented Jun 27, 2013

FYI I'm having trouble getting this working again after upgrading to DP2.

@stigi
Copy link

stigi commented Jul 9, 2013

@mtitolo Any news for DP3? I'm just about trying to set this up and would like to know if I should bother doing so, or if it will still be failing in DP3 anyways.

@mtitolo
Copy link
Author

mtitolo commented Jul 10, 2013

@stigi I'm not able to get this running on DP3 either. There are 2 bugs with dependencies currently causing this, and I have radars for them.

@twc-rhedin
Copy link

@mtitolo We're prepping a new server to use Bots + Cocoapods etc with XCode DP4... do you know if this issue still exists? XCode CI looks interesting, but if I can't use Cocoapods, it's a deal-breaker.

@mtitolo
Copy link
Author

mtitolo commented Aug 7, 2013

@twc-rhedin DP4 and DP5 still have issues. If you'd like it to work, please dupe: https://devforums.apple.com/message/861279#861279

@swizzlr
Copy link

swizzlr commented Aug 28, 2013

I'm getting a Mini tomorrow to use as a server. I'll let you all know how I fare.

@swizzlr
Copy link

swizzlr commented Sep 1, 2013

Okay, the problem I'm experiencing is that teamsserver user can't write to its home directory, so pod setup falls over.

My hacky workaround is committing everything. Not ideal.

@mtitolo
Copy link
Author

mtitolo commented Sep 10, 2013

Yep, as of right now committing everything is the only way for this to work. I wrote up a summary on the CocoaPods Google Group on how it currently works with Bots.

Copy link

ghost commented Sep 11, 2013

@mtitiolo: Do you have it already tested with the yesterdays released Gold Master?

@ketzusaka
Copy link

I got it working with Find Implicit Dependencies checked. I installed RVM in a multi-user setting, though. You also have to be sure to include environment variables in your build script.

@mtitolo
Copy link
Author

mtitolo commented Oct 3, 2013

@ketzusaka can you post what your settings are? I'm still getting Build Canceled when the workspace contents change.

@Dimillian
Copy link

I just setup a server today, what I got is ld: library not found for -lPods at the end of the build phase, just before launching the simulator...

@mtitolo
Copy link
Author

mtitolo commented Oct 16, 2013

@Dimillian that sounds like the 64-bit architecture problem. Check you have ONLY_ACTIVE_ARCHS=NO

@andrewtheis
Copy link

@mtitolo What's the best way to get this working right now without checking the Pods/ folder? Is it to add the pod install pre-build script? I'm trying to sort through these threads but there doesn't seem to be a definitive answer for Xcode 5.0+

@ketzusaka Interested in your solution as well.

@mtitolo
Copy link
Author

mtitolo commented Oct 23, 2013

@andrewtheis I have some instructions I was sent by someone who got them kind of working, but haven't had the time to try them, and these instructions were posted on the Google Group this AM. If you'd like to take a look/help, ping me michele@cocoapods.org

@jbyung-zz
Copy link

hi @mtitolo has there been any update regarding this issue so far? I'm getting the same issue in XCode 6 (when I attempt to integrate XCode CI in my OSX project. My project is in a workspace and is using cocopods). The only workaround that I've found so far is by committing all the pods files and all the workspace files to the repository in order to get it to build. The pre-action (set up in a scheme) or the before-trigger in the bot doesnt work with "pod install". Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment