Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65" Iphone6 Simulator - xcode

I am trying to run the Amazon app on an iPhone 6 simulator using Xcode.
The app is getting installed in the iPhone Simulator, but not able to interact with its elements.
Appium version - 1.7.2
Xcode Version 9.2
Platform Mac- 10.12.6
Downloaded the app - i.e. xxx.app.ipa
Logs:
[Xcode] 2018-02-13 21:23:08.009 xcodebuild[9868:75242] Error Domain=IDEFoundationErrorDomain Code=1 "Cannot launch simulated executable: no file found at /Applications/Xcode.app/Contents/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app" UserInfo={NSLocalizedDescription=Cannot launch simulated executable: no file found at /Applications/Xcode.app/Contents/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app} [Xcode] 2018-02-13 21:23:08.009 xcodebuild[9868:75242]
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] 2018-02-13 21:23:08.010 xcodebuild[9868:75259] Connection peer refused channel request for "dtxproxy:XCTestManager_IDEInterface:XCTestManager_DaemonConnectionInterface"; channel canceled
[Xcode] ** TEST EXECUTE FAILED ** [Xcode] [Xcode] 2018-02-13 21:23:08.011 xcodebuild[9868:75318] Error saving test log:
Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={NSFilePath=/Applications/Xcode.app/Contents/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Logs/Test/921A213D-B7E4-4994-9443-F73DDE5FBD4D.xcactivitylog, NSLocalizedDescription=No such file or directory} | User info: { [Xcode] NSFilePath = "/Applications/Xcode.app/Contents/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Logs/Test/921A213D-B7E4-4994-9443-F73DDE5FBD4D.xcactivitylog"; [Xcode] NSLocalizedDescription = "No such file or directory"; [Xcode] } [Xcode]
[XCUITest] xcodebuild exited with code '65' and signal 'null' [BaseDriver] Event 'wdaStartFailed' logged at 1518585788035 (21:23:08 GMT-0800 (PST)) [XCUITest] Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". [XCUITest] Quitting and uninstalling WebDriverAgent, then retrying [XCUITest] Shutting down sub-processes [XCUITest] Removing WDA application from device [XCUITest] Error: Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". at XCUITestDriver.quitAndUninstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:375:13) at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at Error: Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". at XCUITestDriver.quitAndUninstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:375:13) at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as next at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at [XCUITest] Not clearing log files. Use clearSystemFiles capability to turn on. [XCUITest] Killing running processes 'xcodebuild.B720A212-489B-4A48-BBDB-7119C9763406, B720A212-489B-4A48-BBDB-7119C9763406.*XCTRunner' for the device B720A212-489B-4A48-BBDB-7119C9763406... [XCUITest] 'pgrep -nif xcodebuild.*B720A212-489B-4A48-BBDB-7119C9763406' didn't detect any matching processes. Return code: 1 [XCUITest] 'pgrep -nif B720A212-489B-4A48-BBDB-7119C9763406.XCTRunner' didn't detect any matching processes. Return code: 1 [XCUITest] Deleting simulator created for this run (udid: 'B720A212-489B-4A48-BBDB-7119C9763406') [iOSLog] Stopping iOS log capture

It's saying it can't find the WebDriver app. Can you confirm its existence in /Applications/Xcode.app/Contents/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Build/Products/Debug-iphonesimulator/?
If it doesn't exist, there is something wrong with your Appium install so I'd recommend reinstalling npm uninstall -g appium and npm install -g appium. Probably safe to do that anyway.
Also make sure you restart your device and uninstalling any existing WebDriver app on the device.

Error clear shows -- /Applications/Xcode.app/Contents/Developer/Xcode/DerivedData/WebDriverAgent-dikkwtrisltbeobjmfvpthwwekvs/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app}
Webdriver agent need to be successfully running on device
Try to configure Webdriver agent and Developer ID ::
Open the existing the WebDriver Agent (double click on WebDriverAgent.xcodeproj)
On top of Xcode you File > New> File , then you will an pop up something like this
Select OSX->.Other-> Select Configuration settings file.
Paste the following things in newly created file.
DEVELOPMENT_TEAM = xxxxxxxxx
CODE_SIGN_IDENTITY = iPhone Developer
Development team is Team ID which your developer should be able to provide . Dont change the CODE_SIGN_IDENTITY.
In device.propoerties file add this
xcodeConfigFile=/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Config.xcconfig
In ConfigCapa.java file add this
capabilities.setCapability(“xcodeConfigFile”,emulatorProp.getProperty(“xcodeConfigFile”));
Open terminal go to
$ cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/
$ mkdir -p Resources/WebDriverAgent.bundle
sh ./Scripts/bootstrap.sh –d
Go to terminal type
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=DeviceID’ test Last line on build output above command should be Listening on USB. Then you are all set!
brew install libimobiledevice –HEAD
To run appium type appium &
To find version type appium — v

Related

Automated testing on real IOS device fails because Appium inspector can't connect to the device. (Xcodebuild failed with code 65 & 66)

i have a problem with I was not able to get rid of for the past days.
My goal is to start an automated test, for an app that is already downloaded on the device, from my Mac on my iPhone.
I started with installing:
Node.js
Java JDK & JAVA_HOME variable
Appium & Appium inspector
Xcode & Xcode Command Line Tools
Appium driver (xcuitest & UIAutomation)
In the next step in entered my Desired Capabilities in the Appium inspector:
platformName : ios
appium:platformVersion : 16.1
appium:deviceName: iPhone 11 pro
appium:bundleId :
appium:automationName : XCUITest
appium:udid: <udid from my devic
appium:xCodeOrgId :
appium:xCodeSigningId : iPhone Developer
After entering these information I moved on and opened the WebDriverAgent.xcodeproj and signed in with my free Developer Account (Apple ID) and assigned a Team to WebDriverAgentLib, WebDriverAgentRunner, all Integrationtests and the IntegrationApp. The Firestone worked but the last three failed with the Error:
Failed to create provisioning Profile. The app ID "com.facebook.WebDriverAgentRuner" can not be registered to your development team. Change your bunde identifier to a unique String to try again.
and
No profiles for 'com.facebook.WebDriverAgentRunner' were found. Xcode couldn't find any iOS App Development provisioning profiles matching 'com.facebook.WebDriverAgentRunner'.
After reviewing the Problem I came up with following a few tutorials without any luck.
I tried to create a profiling Profile, but most ways I found were with the free version or just wouldn't work.
So i changed the bundle identifiers, even though it's not a beautiful solution and was able to trust the computer and install an app with Xcode.
But when I try to start a session with Appium inspector after I started the Appium server in Visual Studio Code it still fails with the Error:
In Appium inspector:
Error
Failed to create session. An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65 xcodebuild error message: . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
In Visual Studio Code:
[debug] [XCUITestDriver#f4dc (e98a8edb)] Matched '/status' to command name 'getStatus'
[debug] [XCUITestDriver#f4dc (e98a8edb)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body
[debug] [iProxy#00008030:8100] Connection was refused to port 8100
[XCUITestDriver#f4dc (e98a8edb)] socket hang up
[Xcode] xcodebuild exited with code '65' and signal 'null'
[debug] [XCUITestDriver#f4dc (e98a8edb)] Event 'wdaStartFailed' logged at 1674136358245 (14:52:38 GMT+0100 (Mitteleuropäische Normalzeit))
[debug] [XCUITestDriver#f4dc (e98a8edb)] Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
[debug] [XCUITestDriver#f4dc (e98a8edb)] xcodebuild error message:
[debug] [XCUITestDriver#f4dc (e98a8edb)] . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[XCUITestDriver#f4dc (e98a8edb)] Quitting and uninstalling WebDriverAgent
[XCUITestDriver#f4dc (e98a8edb)] Shutting down sub-processes
[debug] [WebDriverAgent] Successfully reset '/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj/project.pbxproj' with bundle id 'com.facebook.WebDriverAgentRunner'
[debug] [XCUITestDriver#f4dc (e98a8edb)] No WDAs on the device.
[XCUITestDriver#f4dc (e98a8edb)] {}
[DevCon Factory] Releasing connections for 00008030-0005298C0C45802E device on any port number
[DevCon Factory] Found cached connections to release: ["00008030-0005298C0C45802E:8100"]
[DevCon Factory] Releasing the listener for '00008030-0005298C0C45802E:8100'
[debug] [iProxy#00008030:8100] Closing the connection
[debug] [DevCon Factory] Cached connections count: 0
[debug] [XCUITestDriver#f4dc (e98a8edb)] Not clearing log files. U`clearSystemFiles` capability to turn on.
[iProxy#00008030:8100] The connection has been closed
[debug] [AppiumDriver#567d] Event 'newSessionStarted' logged at 1674136358629 (14:52:38 GMT+0100 (Mitteleuropäische Normalzeit))
[debug] [AppiumDriver#567d] Encountered internal error running command: Error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
[debug] [AppiumDriver#567d] xcodebuild error message:
[debug] [AppiumDriver#567d] . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
[debug] [AppiumDriver#567d] at quitAndUninstall (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/lib/driver.js:584:15)
[debug] [AppiumDriver#567d] at /Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/lib/driver.js:619:11
[debug] [AppiumDriver#567d] at wrapped (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:95:13)
[debug] [AppiumDriver#567d] at retry (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:68:13)
[debug] [AppiumDriver#567d] at retryInterval (/Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:105:10)
[debug] [AppiumDriver#567d] at /Users/k.steffens/.appium/node_modules/appium-xcuitest-driver/lib/driver.js:599:7
[HTTP] <-- POST /session 500 14443 ms - 1398
[HTTP]
After this try I even tried to add the bootstrapPath as a desired Capability and the agentPath as a desired Capability, with no luck.
But the error changed a little:
Failed to create session. An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 66 xcodebuild error message: . Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
Is there something I'm doing wrong, or is there better way to do automated testing on real iOS devices?
I would be very happy if you could help me out.
kind regards,
henry

Xcode simulator no crash but real device problems

I run my app in Xcode through the simulator and it builds with no crashes. When I run on real device it successfully builds but I get crash errors. Someone suggested it might be the cordova screen lock but I tried it without and still have problems.
Running on real device: a blinking screen or it keeps reloading the first screen, never to make it to the next one. Please help!
Here are the different lines I am seeing when compared to the simulator:
Metal API Validation Enabled
<UMP SDK> To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = #[ #"___________________________________" ];
THREAD WARNING: ['CDVOrientation'] took '44.751953' ms. Plugin should use a background thread.
[Process] 0x10f003740 - [PID=1655] WebProcessProxy::didClose: (web process 0 crash)
[Process] 0x10f003740 - [PID=1655] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=4
[ProcessSuspension] 0x10e0042a0 - ProcessAssertion: Failed to acquire RBS Background assertion 'ConnectionTerminationWatchdog' for process because PID 0 is invalid
[ProcessSuspension] 0x10e0042a0 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=0, error: (null)
0x150842818 - [pageProxyID=13, webPageID=14, PID=1655] WebPageProxy::processDidTerminate: (pid 1655), reason 4
[assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
[ProcessSuspension] 0x10e004300 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess Background Assertion' for process with PID=1655, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
[Loading] 0x150842818 - [pageProxyID=13, webPageID=14, PID=1655]
WebPageProxy::dispatchProcessDidTerminate: reason=Crash
[XPC] Handle connection with error: Connection interrupted
[Process] 0x10f004110 - [PID=0] WebProcessProxy::didFinishLaunching: Invalid connection identifier (web process failed to launch)
[Process] 0x10f004110 - [PID=0] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=4
[Process] 0x150842818 - [pageProxyID=13, webPageID=14, PID=0] WebPageProxy::processDidTerminate: (pid 0), reason 4
[ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke
[Process] 0x10f0048f0 - [PID=1682] WebProcessProxy::didClose: (web process 0 crash)
[Process] 0x10f0048f0 - [PID=1682] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=4
THREAD WARNING: ['AdMob'] took '30.550049' ms. Plugin should use a background thread.
THREAD WARNING: ['Consent'] took '10.710205' ms. Plugin should use a background thread.
We saw this issue on Xcode 14.2 where web views were not loading.
Our WKWebViews had Content Rule List set.
The root cause was it compiled the Content Rule List to the underlying chipset (non-Intel), instead of respecting the Rosetta.
This issue was not seen when Xcode was launched without Rosetta.

NativeScript UI Autocomplete don't compiled

In my nativescript app, I have a problem about using nativescript ui autocomplete. I compile my mobile application to android apps. It has an error as below
<======-------> 50% CONFIGURING [3s]
<====---------> 35% EXECUTING [13s]
<======-------> 51% EXECUTING [20s]
Exception in thread "main" java.lang.ClassNotFoundException: Class: com.telerik.widget.autocomplete.ShowSuggestionListListener
at org.nativescript.staticbindinggenerator.Generator.getClass(Generator.java:776)
at org.nativescript.staticbindinggenerator.Generator.collectInterfaceMethods(Generator.java:703)
at org.nativescript.staticbindinggenerator.Generator.getPublicApi(Generator.java:227)und 0 errors. Watching for file changes.
at org.nativescript.staticbindinggenerator.Generator.writeBinding(Generator.java:342)
at org.nativescript.staticbindinggenerator.Generator.generateBinding(Generator.java:133)
at org.nativescript.staticbindinggenerator.Generator.processRows(Generator.java:172)
at org.nativescript.staticbindinggenerator.Generator.generateBindings(Generator.java:90)
at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:66)
at org.nativescript.staticbindinggenerator.Main.main(Main.java:47)
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:runSbg'.
Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 25s
10:34:24 - Found 0 errors. Watching for file changes.
Unable to apply changes on device: 192.168.80.101:5555. Error is: Command ./gradlew failed with exit code 1.
Executing after-watch hook from /home/andre/nativescript/TigaRoda/hooks/after-watch/nativescript-dev-typescript.js
Stopping tsc watch
Executing after-watch hook from /home/andre/nativescript/TigaRoda/hooks/after-watch/nativescript-dev-webpack.js
Stopping webpack watch
delete node_modules, platforms, hooks folders and package-lock.json file
run
npm i
rebuild the project ->
tns run android
or
tns build android

Ionic build android failed with 403 Http respose from Gradle, JAVA_HOME not valid

I am using Windows 7X64 machine and trying to build Andriod application using cordova/ionic CLI v1.5.5. I am getting this error that I couldn't solve.
"You may not have the required environment or OS to build this project"
with commands ionic build android and cordova build android. The command ionic platform add android was successful. I am working with Android sdk (API 22) using the Android SDK Manager. I also made sure that PATH variable is correctly set.
Full transcript of process is:
C:\Users\ddevkota\Desktop\freshIonic>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\ddevkota\Desktop\fr
eshIonic\hooks\after_prepare\010_add_platform_class.js C:\Users\ddevkota\Desktop
\freshIonic
add to body class: platform-android
Running command: cmd "/s /c "C:\Users\ddevkota\Desktop\freshIonic\platforms\andr
oid\cordova\build.bat""
ANDROID_HOME=C:\Users\ddevkota\AppData\Local\Android\sdk
JAVA_HOME=C:\Progra~1\Java\jdk1.7.0_15
Running: C:\Users\ddevkota\Desktop\freshIonic\platforms\android\gradlew cdvBuild
Debug -b C:\Users\ddevkota\Desktop\freshIonic\platforms\android\build.gradle -Do
rg.gradle.daemon=true
Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Serv
er returned HTTP response code: 403 for URL: http://services.gradle.org/distribu
tions/gradle-2.2.1-all.zip
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL:
http://services.gradle.org/distributions/gradle-2.2.1-all.zip
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1625)
at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
... 3 more
C:\Users\ddevkota\Desktop\freshIonic\platforms\android\cordova\node_modules\q\q.
js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\ddevkota\Desktop\freshI
onic\platforms\android\gradlew cdvBuildDebug -b C:\Users\ddevkota\Desktop\freshI
onic\platforms\android\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\ddevkota\AppData\Roaming\npm\node_modules
\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Thanks for help in advance.
NOTE: This turns out to be a permission issue in client (403). I connected my machine to different network and it started working. All build process. If you wanna do it manually here is how far I got.
Solution for not Valid JAVA_HOME
After spending days and uninstalling all versions of java, reinstalling only one version and setting up Environment VariableJAVA_HOME as C:\Program Files\Java\jdk1.7.0_15 I solved the problem.
However there was another issue of ionic build android error when downloading gradle.
This was solved as I added gradle to my project offline.
Solution for not Gradle 403 Http response
Do the following:
After downloading gradle from issued link (here is https://services.gradle.org/distributions/gradle-2.2.1-all.zip) paste it in somewhere likes myApp\platforms\android\gradle\gradle-2.2.1-all.zip and in build.js from myApp\platforms\android\cordova\lib\build.js find this:
var distributionUrl = 'distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip';
And replace it with your own file's location:
var distributionUrl = 'distributionUrl=../gradle-2.2.1-all.zip';
Still working on build and will keep on posting the solution. A thread about other issues is created in ionic forum and it is here.
Solution for not Gradle 403 Http response
find distributionUrl variable in:
myapp\platforms\android\cordova\lib\builders\GradleBuilder.js
change http value to https in this line:
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip';

Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain

Running Instruments from the command line gave me this error:
Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 8.) : Failed to launch process with bundle identifier
Any idea what the problem is and how to fix?
In my case I believe it was a provisioning profile issue. Try going into Product/Scheme/Edit Scheme and changing the Profile build configuration from Release to Debug or vice versa - that got it working for me.

Resources