Xcode UI testing on Travis for OSX with Xcode Helper Accessibility
Asked Answered
P

1

8

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
Paver answered 11/12, 2015 at 19:59 Comment(1)
For anyone finding this page through Google: unfortunately it no longer works. Since MacOS 10.12 the accessibility database is protected by SIP, so the sqlite3 command fails with a "read-only file" error. I haven't been able to find a workaround.Camiecamila
P
15

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!

Paver answered 11/12, 2015 at 23:11 Comment(2)
A horrible hack, love itHarman
no longer works.Oglesby

© 2022 - 2024 — McMap. All rights reserved.