Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode UI testing on Travis for OSX with Xcode Helper Accessibility

How can I configure Travis to run my UI XCTest cases for OSX? The Travis test fails because, on OSX, Xcode Helper requires permission to use Accessibility for the test instance. Is there any way to configure the Travis instance to grant permission for Xcode Helper to use Accessibility prior to running xcodebuild?

I'm using the latest Xcode 7.2 Travis configuration with OSX 10.11.1, and I'm running my tests using xcodebuild as a Travis script because xctool does not yet support running UI tests. If you try to use xctool, you'll get an error that the testing bundle does not contain an executable.

I believe other folks have run UI tests on Travis for iOS because they are run in the simulator and don't require Xcode Helper to have Accessibility permissions.

Here is my .travis.yml file (slightly obfuscated):

osx_image: xcode7.2
language: objective-c
xcode_workspace: MyApp.xcworkspace
xcode_scheme: MyAppUITests

jdk:
  - oraclejdk8

install:
  - pod install
  - gem install xcpretty --no-rdoc --no-ri --no-document --quiet
  - xcodebuild -workspace MyApp.xcworkspace -scheme MyAppUITests -destination 'platform=OS X,arch=x86_64' clean build | xcpretty -c || true

script:
  - xcodebuild -workspace MyApp.xcworkspace -scheme MyAppUITests -destination 'platform=OS X,arch=x86_64' test
like image 391
Dan Wexler Avatar asked Dec 11 '15 19:12

Dan Wexler


1 Answers

I have found the secret sauce to fix this issue. Add the following incantation to your .travis.yml in the install: section:

  - sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "INSERT INTO access VALUES ('kTCCServiceAccessibility','com.apple.dt.Xcode-Helper',0,1,1,NULL,NULL);"

This adds an entry to the access database used to determine Accessibility permissions. Ba-bam!

like image 130
Dan Wexler Avatar answered Oct 15 '22 21:10

Dan Wexler