Goal for this setup:
- Run unit tests and feature tests for your iOS app whenever a commit gets pushed to master.
- Enable your devs and PM to deploy the latest passing build to staging whenever they want.
First off, if you are interested in CI just to run your unit tests (or XCTest based feature tests), I recommend checking out XCode CI Server. It is easy to set up, integrates with XCode for build alerts and is generally pretty neat. However XCode CI is not very extensible. As soon as you have to run feature tests using a none XCTest framework, or want to archive your .ipa, you need something else. After having used Jenkins on a number of projects I wanted to see what all the fuss was about over in TeamCity land.buy diazepam online without prescription
Quick opinion on TeamCity: It is great. If you have even the simplest release pipeline (like the one I will describe in this post) it is a better experience than Jenkins. Also, while it is a paid-for product, most of the time the free license can fit your project.
First Stop: Unit Tests
- Create a project in TeamCity
- Add a Build Configuration
- Configure your source code repository settings
- I recommend setting “VCS checkout mode” to “Automatically on Agent” to resolve issues with symlinks as mentioned in this post.
- In the build steps section, select “Auto Detect Build Steps”
- TeamCity will detect your .xcodeproj
- It is okay if you use an .xcworkspace and it doesn’t see it. There is a workaround below
- Select “Use This” on the xcodeproj you want to run the tests for
- Add a “VCS Trigger” in the trigger section so builds occur automatically
Workaround for those who use an .xcworkspace
- Edit the settings on your “Xcode Project” build step
- Choose the scheme you want to build
- Change the “Path to the project or workspace” to your .xcworkspace
- Do not do anything else. If you hit “Check/Reparse Project” it will probably not detect your scheme.
- I mean, you should hit save, but nothing else.
At this point you should be able to have nice green builds you can be happy about all day long.
Second Stop: Exporting your .ipa as an Artifact
- Add a command line build step to your project
- Use the following commands as your “Custom Script”
soma online no prescription
xcodebuild -workspace <AppName>/<AppName>.xcworkspace -scheme <PrimarySchemeName> archive -archivePath <AppName>.xcarchive provigil online pharmacy
xcodebuild -exportArchive -exportFormat ipa -archivePath <AppName>.xcarchive -exportPath <AppName> -exportProvisioningProfile <AcceptanceProvisioningProfileName>
- Use the following commands as your “Custom Script” soma online no prescription
- In the "General Settings" of you Build Configuration, add "<AppName>.ipa" to the "Artifact Paths" section. This will save your IPA as a Build Artifact.
Now for every successful build you can retrieve a deployable artifact from TeamCity. I would recommend running those commands manually on the command line and trying to deploy the .ipa before putting it in your TeamCity configuration, as getting your Provisioning Profiles in order can sometimes be painful.
Last Stop: Deploying to HockeyAppativan online no prescription
HockeyApp is a great way to manage deployments to different groups of users. A great feature of it is its simple API!buy ambien without prescription
We chose to have the following build be a manual kick off, albeit one we use multiple times a day. With a single setting change you can make it automatic.
- Under your "Project Settings" (the level above your "Build Configuration") add a new "Build Configuration".
- You should not have a need to add your code repository
- Under "Dependencies" select "Add new artifact dependency"
- For "Depend on", select the "Build Configuration" we created in the previous steps
- For "Get artifacts from", I recommend "Last successful build", but there are many interesting choices here that can fit different scenarios. ("Last pinned build" seems particularly useful for giving power to your PM)
- For "Artifact rules" keep it simple for now and choose what we entered in the "Artifact Paths" field of the previous "Build Configuration". For instance: <AppName>.ipa
- "Clean destination paths before downloading artifacts" is recommended, because I get scared of somehow uploading old assets if file names change
- Add a new "Command Line" build step
- Use the following command to push your App to HockeyApp (as taken from their documentation)
buy klonopin online
set -x curl \ -F "status=2" \ -F "notify=0" \ -F "notes=Build %build.counter%" \ -F "notes_type=0" \ -F "ipa=@<AppName>.ipa" \ -H "X-HockeyAppToken: <API_Token_From_HockeyApp>" \ https://rink.hockeyapp.net/api/2/apps/upload
- Rejoice! You have now uploaded your app!
There are numerous ways to handle all of the steps above, but this seemed to the best way to leverage the power of TeamCity and not create additional dependencies. As you can see this also leaves open many additional abilities. For instance, if your acceptance environment relies on a Fake/Mock API server, you could deploy it by adding an additional step to your HockeyApp build configuration. If you have feature tests to run, you can add them as an additional build step to the first "Build Configuration" we created.
Be sure to radiate your CI's build and deploy status using any number of tools, for instance Project Monitor.