guard-xcodebuild automatically and selectively runs your tests when your Xcode files are modified
Add this line to your application's Gemfile:
gem 'guard-xcodebuild'
And then bundle it:
$ bundle
Or install the gem:
$ gem install guard-xcodebuild
- Ruby >2
- xcodebuild
- Guard 2.x
-
Make sure you have Xcode / xcodebuild installed
-
Create an
.xcodebuild-args
file in your project root passing the parameters relevant to your project. It's a simple JSON value where you can pass key value pairs. Here's an example:
{
"workspace": "YourProject.xcworkspace",
"scheme": "YourSchemeName",
"configuration": "Debug",
"sdk": "iphonesimulator",
"destination": "'platform=iOS Simulator,name=iPhone 7 Plus'"
}
- Configure your Guardfile
directories %w(YourApp YourAppTests) \
.select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
guard 'xcodebuild' do
watch(/(.*).(m|swift)/)
end
- Run
bundle exec guard
By default, xcodebuild tries to determine your target based on Xcode naming conventions
If necessary, you can specify your target by passing the test_target
parameter in your
Guardfile.
guard 'xcodebuild', :test_target => 'YourAppTests' do
watch(...)
end
Xcodebuild will check for all files under the current folder for matching patterns. You can specify particular folder or array of folders, as test path.
guard 'xcodebuild', :test_paths => 'YourAppTests' do
watch(...)
end
guard 'xcodebuild', :test_paths => ['YourAppUITests', 'YourAppTests'] do
watch(...)
end
You can also pass any of the standard xcodebuild options using the :args
option.
Note that this will be appended to any arguments specified in the .xcodebuild-args file
and that (currently) duplicates are not accepted
guard 'xcodebuild', :args => 'CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO' do
watch(...)
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request