Upgrading an Old Project to XCTest

Episode #94 | 14 minutes | published on November 7, 2013
Subscribers Only
In this episode I upgrade the sample app created way back in Episode 4 using Kiwi to Xcode 5 and XCTest. Along the way, we're greeted with a number of warnings & errors that we have to address to get the Kiwi tests to run with XCTest.

Episode Links

Refactor to XCTest vs Adding a New Test Target

Under the Edit menu there is a refactoring option to Refactor to XCTest. In my experience this doesn't work properly and it creates a dependency on a dylib for XCTest that the app cannot link with.

Instead, create a new Unit Test target underneath the iOS category. It's trivial to switch Target Membership for the tests in the old target.

Creating a Podfile

We need to create a changes to the Podfile. We need to tell it where to find the project file (since it is not in the same directory as the Podfile. Next is to use a Kiwi sub-spec that depends on XCTest instead of SenTestingKit.

platform :ios, '7.0'
xcodeproject "GuessTheNumber/GuessTheNumber.xcodeproj"

target :GuessTheNumberXCTests, :exclusive => true do
  pod 'Kiwi/XCTest'

Fixing an issue with mismatched architectures

When working with Pod targets, it's advised not to make changes to settings (like architecture) because the next time you run pod install it will overwrite those changes. Instead, we can leverage a post install hook in our Podfile:

post_install do |installer|
  installer.project.targets.each do |target|
    puts "Processing target: #{target.name}..."
    target.build_configurations.each do |config|
      config.build_settings['ARCHS'] = "$(ARCHS_STANDARD_32_BIT)"
blog comments powered by Disqus