Appium setup for IOS

Before Starting Just watch this youtube video for configuring Appium for Automating iOS applications: Configure Appium For iOS

Pre-Requisite:

There are some of the basic pre-requisites for Appium 1.6.3 to work with IOS 10 to setup for automating test cases.

  1. Mac Os > 10.11 (Not possible in windows)
  2. Xcode > 8.1
  3. IOS 10

Setting up environment:

Some of the steps listed for setting up appium 1.6.3

SR Steps Solution/Commands
1. Install HomeBrew ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
2. Install Node JS brew install node
3. Install Lib-imobile-device brew install libimobiledevice –HEAD
4. install ideviceinstaller brew install ideviceinstaller
5. carthage brew install carthage
6. Install Ios-Deploy npm install -g ios-deploy
7. Install Xcpretty gem install xcpretty

Lastly download and install Appium using npm, Command: “npm install -g appium@beta“. This command will download and install latest beta build. If you need latest appium build just dont include @beta with command.

After that there few configurations for setting up appium.

Manual Configuration:

There are some manual configuration for webdriver to setup and install on device:

  1. Open terminal go to node_modules/appium-xcuitest-driver/WebDriverAgent (this path is relative to your appium installation). Run following commands
    1. mkdir -p Resources/WebDriverAgent.bundle
    2. sh ./Scripts/bootstrap.sh -d
  2. Now open WebDriverAgent.xcodeproj in Xcode. Select your development team for the WebDriverAgentLib, WebDriverAgentRunner and integration Apps targets. This should also auto select Signing Certificate. Now there is trick while tweaking these targets. Please check this link.
  3. Build WebDriverAgent once to verify all above steps worked.
    1. xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=' test

Now start appium on command line using “appium -p <PORT>” and throwing commands through your script.

Configure Appium For iOS

Please comment for any kind of related queries.

22 thoughts on “Appium setup for IOS

  1. Tried that, but the build failed; getting error:

    writeDictToFile:1269 open failed for /var/folders/gs/m_njf64s07d92mjswbdzwmfdz6j_p5/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/a191494beafc14681e6afe480157b603/8b95415e64460b5733064725d58afd4d80794ccb/ManifestCache.plist : No such file or directory
    MDMCacheDirectoryManifest:1364 writeDictToFile failed to write to /var/folders/gs/m_njf64s07d92mjswbdzwmfdz6j_p5/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/a191494beafc14681e6afe480157b603/8b95415e64460b5733064725d58afd4d80794ccb/ManifestCache.plist : No such file or directory
    2017-02-09 14:00:26.068 xcodebuild[19390:572628] Error Domain=com.apple.dtdevicekit Code=-402620394 "The executable was signed with invalid entitlements." UserInfo={NSLocalizedFailureReason=The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016)., com.apple.dtdevicekit.stacktrace=(
    	0   DTDeviceKitBase                     0x0000000117db837b DTDKCreateNSError + 113
    	1   DTDeviceKitBase                     0x0000000117db8ab9 DTDK_AMDErrorToNSError + 791
    	2   DTDeviceKitBase                     0x0000000117df89df __90-[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 158
    	3   DVTFoundation                       0x000000010e601989 DVTInvokeWithStrongOwnership + 75
    	4   DTDeviceKitBase                     0x0000000117df8725 -[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1181
    	5   IDEiOSSupportCore                   0x0000000117ceee1f __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.336 + 4597
    	6   DVTFoundation                       0x000000010e725cb7 __DVTDispatchAsync_block_invoke + 827
    	7   libdispatch.dylib                   0x00007fff9a26693d _dispatch_call_block_and_release + 12
    	8   libdispatch.dylib                   0x00007fff9a25b40b _dispatch_client_callout + 8
    	9   libdispatch.dylib                   0x00007fff9a26003b _dispatch_queue_drain + 754
    	10  libdispatch.dylib                   0x00007fff9a266707 _dispatch_queue_invoke + 549
    	11  libdispatch.dylib                   0x00007fff9a25ed53 _dispatch_root_queue_drain + 538
    	12  libdispatch.dylib                   0x00007fff9a25eb00 _dispatch_worker_thread3 + 91
    	13  libsystem_pthread.dylib             0x00007fff8da584de _pthread_wqthread + 1129
    	14  libsystem_pthread.dylib             0x00007fff8da56341 start_wqthread + 13
    ), NSLocalizedRecoverySuggestion=The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016)., NSLocalizedDescription=The executable was signed with invalid entitlements.}
    2017-02-09 14:00:26.069 xcodebuild[19390:572628] Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}
    

    Like

  2. Hi Followed the steps which you mentioned but appium log is coming this errro

    [Xcode] 2017-06-04 15:08:14.994 xcodebuild[12928:83831] Error Domain=com.apple.platform.iphoneos Code=-12 “Unable to launch com.apple.test.WebDriverAgentRunner-Runner” UserInfo={NSLocalizedDescription=Unable to launch com.apple.test.WebDriverAgentRunner-Runner, NSUnderlyingError=0x7f8f612aba60 {Error Domain=DTXMessage Code=1 “(null)” UserInfo={DTXExceptionKey=The operation couldn’t be completed. Unable to launch com.apple.test.WebDriverAgentRunner-Runner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. : Failed to launch process with bundle identifier ‘com.apple.test.WebDriverAgentRunner-Runner’}}}
    [Xcode]
    [Xcode] 2017-06-04 15:08:14.994 xcodebuild[12928:83831] Error Domain=IDETestOperationsObserverErrorDomain Code=6 “Early unexpected exit, operation never finished bootstrapping – no restart will be attempted” UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping – no restart will be attempted}
    [Xcode]
    [Xcode] TEST EXECUTE FAILED
    [Xcode]
    [Xcode]
    [XCUITest] xcodebuild exited with code ’65’ and signal ‘null’
    [debug] [BaseDriver] Event ‘wdaStartFailed’ logged at 1496578095048 (15:08:15 GMT+0300 (+03))
    [debug] [XCUITest] Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
    [debug] [XCUITest] Quitting and uninstalling WebDriverAgent, then retrying

    Can you please help?

    Thanks,
    Sanjay

    Like

  3. As you can see in logs ” it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. ”
    So there are two reasons for failure:
    1. Invalid code signature: Open WebDriverAgent.xcodeproj and check 3 given targets are signed?
    2. Profile not trusted: But for that WebDriver app must get installed in your device, then you can trust certificates in your device. Settings>General>Device Management> Trust Certificates

    Like

  4. Hi…
    I want to ask about the second step ” there is trick while tweaking these targets. Please check this link.”
    For product bundle id, it should be “com.facebook.test.xxxxx” or it should be changed to our own bundle id?

    Thank you,

    Like

  5. Hi…
    I want to ask about the second step ” there is trick while tweaking these targets. Please check this link.”
    For product bundle id, it should be “com.facebook.test.xxxxx” or it should be changed to our own bundle id?

    Thank you,

    Like

  6. xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=’ test

    After I run this command, it hangs here

    Test Suite ‘All tests’ started at 2017-11-29 15:34:36.889
    Test Suite ‘WebDriverAgentRunner.xctest’ started at 2017-11-29 15:34:36.892
    Test Suite ‘UITestingUITests’ started at 2017-11-29 15:34:36.893
    Test Case ‘-[UITestingUITests testRunner]’ started.
    t = 0.00s Start Test at 2017-11-29 15:34:36.898
    t = 0.01s Set Up
    2017-11-29 15:34:36.923991+0530 WebDriverAgentRunner-Runner[365:16913] Built at Nov 29 2017 15:34:11
    2017-11-29 15:34:36.977462+0530 WebDriverAgentRunner-Runner[365:16913] ServerURLHere->http://192.168.15.35:0<-ServerURLHere

    and doesn't move forward, please help.

    Liked by 1 person

  7. Throwing below error, its already signed with a developer account:
    [WebDriverAgent][39m xcodebuild exited with code ’70’ and signal ‘null’

    Need help

    Like

  8. Is there a way to get around needing an Apple Developer Account? I keep getting this in Xcode when trying to setup the WebDriverAgentRunner/Signing & Capabilities:

    Communication with Apple failed
    Your team has no devices from which to generate a provisioning profile. Connect a device to use or manually add device IDs in Certificates, Identifiers & Profiles. https://developer.apple.com/account/

    Like

Leave a comment