iOS application launches and automatically gets closed

Problem:
Successfully created WebDriver Agent in xcode,
When i try to run my code, the ios application launches and automatically gets closed.
Please help me with the solution.

Environment

Xcode version = 8.3.3
OSX 10.12.6
Appium version 1.6.4
simulator : iPhone SE 10.3

Successfully created webdriver agent in xcode, When i Run the Appium server, the ipa file (tried with .app file also) gets launched and automatically getting closed.

Below is my code

       DesiredCapabilities cap= new DesiredCapabilities();
	
    
	cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.IOS);
     	cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
  	cap.setCapability(MobileCapabilityType.PLATFORM_VERSION,"10.3");
	cap.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone SE");
            cap.setCapability(MobileCapabilityType.UDID,"813f6a5691bc091cb6653dc09176a107be108193");
        cap.setCapability("bundleId","com.dynamiteclothing.loyalty.dev");
            cap.setCapability(MobileCapabilityType.APP,"/Users/testusers/Desktop/dynamite.ipa");
             IOSDriver driver = new driver(new URL("http://0.0.0.0:4723/wd/hub"),cap);
	cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");

Appium logs

[Appium] Welcome to Appium v1.6.4
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“automationName”:“XCUITest”,“bundleId”:“com.dynamiteclothing.loyalty.dev”,“platformName”:“iOS”,“deviceName”:“iPhone SE”,“platformVersion”:“10.3”}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{“automationName”:“XCUITest”,“bundleId”:“com.dynamiteclothing.loyalty.dev”,“platformName”:“iOS”,“deviceName”:“iPhone SE”,“platformVersion”:“10.3”},null,null,null,null]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1505558554236 (16:12:34 GMT+0530 (IST))
[Appium] Creating new XCUITestDriver (v2.27.2) session
[Appium] Capabilities:
[Appium] automationName: ‘XCUITest’
[Appium] bundleId: ‘com.dynamiteclothing.loyalty.dev’
[Appium] platformName: ‘iOS’
[Appium] deviceName: ‘iPhone SE’
[Appium] platformVersion: ‘10.3’
[debug] [XCUITest] XCUITestDriver version: 2.27.2
[BaseDriver] Session created with session id: 7f722999-3e44-4ab1-bb62-78c75d5b2fff
[debug] [XCUITest] Xcode version set to ‘8.3.3’ (tools v8.3.2.0.1.1492020469)
[debug] [XCUITest] iOS SDK Version set to ‘10.3’
[debug] [BaseDriver] Event ‘xcodeDetailsRetrieved’ logged at 1505558554921 (16:12:34 GMT+0530 (IST))
[iOSSim] Constructing iOS simulator for Xcode version 8.3.3 with udid ‘F53C801A-D1FD-48A5-9910-2776673DE3A5’
[XCUITest] Determining device to run tests on: udid: ‘F53C801A-D1FD-48A5-9910-2776673DE3A5’, real device: false
[debug] [BaseDriver] Event ‘appConfigured’ logged at 1505558555750 (16:12:35 GMT+0530 (IST))
[debug] [BaseDriver] Event ‘resetStarted’ logged at 1505558555751 (16:12:35 GMT+0530 (IST))
[XCUITest] Path must be a string. Received undefined
[XCUITest] Reset: could not scrub application with id “com.dynamiteclothing.loyalty.dev”. Leaving as is.
[debug] [BaseDriver] Event ‘resetComplete’ logged at 1505558555834 (16:12:35 GMT+0530 (IST))
[debug] [iOSLog] Starting iOS 10.3 simulator log capture
[debug] [iOSLog] System log path: /Users/testuser/Library/Logs/CoreSimulator/F53C801A-D1FD-48A5-9910-2776673DE3A5/system.log
[debug] [BaseDriver] Event ‘logCaptureStarted’ logged at 1505558555983 (16:12:35 GMT+0530 (IST))
[XCUITest] Setting up simulator
[debug] [iOS] No reason to set locale
[debug] [iOS] No iOS / app preferences to set
[XCUITest] Simulator with udid ‘F53C801A-D1FD-48A5-9910-2776673DE3A5’ not booted. Booting up now
[debug] [iOSSim] Killing all iOS Simulators
[debug] [iOSSim] Simulator is not running. Continuing…
[iOSSim] Starting simulator with command: open -Fn /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID F53C801A-D1FD-48A5-9910-2776673DE3A5 -ConnectHardwareKeyboard 0
[iOSSim] Simulator booted in 46469ms
[debug] [BaseDriver] Event ‘simStarted’ logged at 1505558602578 (16:13:22 GMT+0530 (IST))
[debug] [BaseDriver] Event ‘appInstalled’ logged at 1505558602578 (16:13:22 GMT+0530 (IST))
[debug] [BaseDriver] Event ‘wdaStartAttempted’ logged at 1505558602580 (16:13:22 GMT+0530 (IST))
[XCUITest] Using WDA path: ‘/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent’
[XCUITest] Using WDA agent: ‘/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj’
[XCUITest] Launching WebDriverAgent on the device
[debug] [XCUITest] Carthage found: ‘/usr/local/bin/carthage’
[debug] [XCUITest] Killing hanging processes
[debug] [XCUITest] Beginning test with command ‘xcodebuild build-for-testing test-without-building -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=F53C801A-D1FD-48A5-9910-2776673DE3A5 -configuration Debug IPHONEOS_DEPLOYMENT_TARGET=10.3’ in directory ‘/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent’
[debug] [XCUITest] Output from xcodebuild will not be logged
[debug] [XCUITest] Waiting up to 60000ms for WebDriverAgent to start
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [XCUITest] Log file for xcodebuild test: /Users/testuser/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Logs/Test/F9620691-B4F7-4971-B9A3-89863D0D8DDC/Session-WebDriverAgentRunner-2017-09-16_161331-UuT3NR.log
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8100/status] with no body
[debug] [JSONWP Proxy] Got response with status 200: “{\n “value” : {\n “state” : “success”,\n “os” : {\n “name” : “iOS”,\n “version” : “10.3.1”\n },\n “ios” : {\n “simulatorVersion” : “10.3.1”,\n “ip” : “192.168.1.104”\n },\n “build” : {\n “time” : “Sep 12 2017 12:04:15”\n }\n },\n “sessionId” : “202DD193-C28A-49BC-AE97-549CE8741456”,\n “status” : 0\n}”
[debug] [XCUITest] WebDriverAgent running on ip ‘192.168.1.104’
[debug] [XCUITest] WebDriverAgent successfully started after 16949ms
[debug] [BaseDriver] Event ‘wdaSessionAttempted’ logged at 1505558619664 (16:13:39 GMT+0530 (IST))
[debug] [XCUITest] Sending createSession command to WDA
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {“desiredCapabilities”:{“bundleId”:“com.dynamiteclothing.loyalty.dev”,“arguments”:[],“environment”:{},“shouldWaitForQuiescence”:true,“shouldUseTestManagerForVisibilityDetection”:false,“maxTypingFrequency”:60,“shouldUseSingletonTestManager”:true}}
[debug] [JSONWP Proxy] Got response with status 200: {“value”:“Failed to launch com.dynamiteclothing.loyalty.dev application”,“sessionId”:“202DD193-C28A-49BC-AE97-549CE8741456”,“status”:13}
[debug] [XCUITest] Failed to create WDA session. Retrying…
[debug] [BaseDriver] Event ‘wdaSessionAttempted’ logged at 1505558862184 (16:17:42 GMT+0530 (IST))
[debug] [XCUITest] Sending createSession command to WDA
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {“desiredCapabilities”:{“bundleId”:“com.dynamiteclothing.loyalty.dev”,“arguments”:[],“environment”:{},“shouldWaitForQuiescence”:true,“shouldUseTestManagerForVisibilityDetection”:false,“maxTypingFrequency”:60,“shouldUseSingletonTestManager”:true}}
[debug] [JSONWP Proxy] Got response with status 200: {“value”:“Failed to launch com.dynamiteclothing.loyalty.dev application”,“sessionId”:“202DD193-C28A-49BC-AE97-549CE8741456”,“status”:13}
[debug] [XCUITest] Failed to create WDA session. Retrying…
[debug] [BaseDriver] Event ‘wdaSessionAttempted’ logged at 1505559102153 (16:21:42 GMT+0530 (IST))
[debug] [XCUITest] Sending createSession command to WDA
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {“desiredCapabilities”:{“bundleId”:“com.dynamiteclothing.loyalty.dev”,“arguments”:[],“environment”:{},“shouldWaitForQuiescence”:true,“shouldUseTestManagerForVisibilityDetection”:false,“maxTypingFrequency”:60,“shouldUseSingletonTestManager”:true}}
[HTTP] <-- POST /wd/hub/session - - ms - -
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“automationName”:“XCUITest”,“bundleId”:“com.dynamiteclothing.loyalty.dev”,“platformName”:“iOS”,“deviceName”:“iPhone SE”,“platformVersion”:“10.3”}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{“automationName”:“XCUITest”,“bundleId”:“com.dynamiteclothing.loyalty.dev”,“platformName”:“iOS”,“deviceName”:“iPhone SE”,“platformVersion”:“10.3”},null,null,null,null]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1505559153667 (16:22:33 GMT+0530 (IST))

Hi Divya, can you share your .app file path?

It should be something like this, please use the .app file from this path if you are not doing so. You will have a similar path, check it out.

/Users/venkat/Library/Developer/Xcode/DerivedData/FMS-cdcodtufovxnhifzcpu/Build/Products/Debug-iphonesimulator/FMS.app'

If the .app path was right, then I have a question for you - Is the ‘WebDriverAgent’ app getting deleted from your real iPhone device once the test case fails?

If that’s not getting deleted, can you delete this capability and try again? I’m not using this in my automation suite.

cap.setCapability("bundleId","com.dynamiteclothing.loyalty.dev");

Hi Venktesh, I have changed the file .app path as u mentioned …
it goes like this
/Users/testuser/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphonesimulator/dynamite.app

nothing has changed in the execution, Again the app launches and gets closed. WebDriverAgent app will be in the simulator once i run the code, and In eclipse execution is not getting terminated at all.

If i remove bundle Id capability then i wont be able to run the code. i am getting following appium error logs

DivyaT:~ testuser$ appium
[Appium] Welcome to Appium v1.6.4
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“automationName”:“XCUITest”,“platformName”:“iOS”,“deviceName”:“iPhone SE”,“platformVersion”:“10.3”}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{“automationName”:“XCUITest”,“platformName”:“iOS”,“deviceName”:“iPhone SE”,“platformVersion”:“10.3”},null,null,null,null]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1505799789609 (11:13:09 GMT+0530 (IST))
[Appium] Creating new XCUITestDriver (v2.27.2) session
[Appium] Capabilities:
[Appium] automationName: ‘XCUITest’
[Appium] platformName: ‘iOS’
[Appium] deviceName: ‘iPhone SE’
[Appium] platformVersion: ‘10.3’
[debug] [XCUITest] XCUITestDriver version: 2.27.2
[XCUITest] Error: The desired capabilities must include either an app or a bundleId for iOS
at Object.wrappedLogger.errorAndThrow (…/…/lib/logging.js:63:13)
at XCUITestDriver.validateDesiredCaps (…/…/lib/driver.js:738:11)
at XCUITestDriver.callee$0$0$ (…/…/…/…/lib/basedriver/commands/session.js:14:8)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.callee$0$0 [as createSession] (…/…/…/…/lib/basedriver/commands/session.js:8:46)
at XCUITestDriver.createSession$ (…/…/lib/driver.js:113:21)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.createSession (…/…/lib/driver.js:185:21)
at AppiumDriver.createSession$ (…/…/lib/appium.js:183:43)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at AppiumDriver.createSession (…/…/lib/appium.js:183:31)
at …/…/…/lib/basedriver/driver.js:218:24
at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:248:10)
at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
Error: The desired capabilities must include either an app or a bundleId for iOS
at Object.wrappedLogger.errorAndThrow (…/…/lib/logging.js:63:13)
at XCUITestDriver.validateDesiredCaps (…/…/lib/driver.js:738:11)
at XCUITestDriver.callee$0$0$ (…/…/…/…/lib/basedriver/commands/session.js:14:8)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.callee$0$0 [as createSession] (…/…/…/…/lib/basedriver/commands/session.js:8:46)
at XCUITestDriver.createSession$ (…/…/lib/driver.js:113:21)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.createSession (…/…/lib/driver.js:185:21)
at AppiumDriver.createSession$ (…/…/lib/appium.js:183:43)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at AppiumDriver.createSession (…/…/lib/appium.js:183:31)
at …/…/…/lib/basedriver/driver.js:218:24
at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:248:10)
at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
[XCUITest] Error: The desired capabilities must include either an app or a bundleId for iOS
at Object.wrappedLogger.errorAndThrow (…/…/lib/logging.js:63:13)
at XCUITestDriver.validateDesiredCaps (…/…/lib/driver.js:738:11)
at XCUITestDriver.callee$0$0$ (…/…/…/…/lib/basedriver/commands/session.js:14:8)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.callee$0$0 [as createSession] (…/…/…/…/lib/basedriver/commands/session.js:8:46)
at XCUITestDriver.createSession$ (…/…/lib/driver.js:113:21)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.createSession (…/…/lib/driver.js:185:21)
at AppiumDriver.createSession$ (…/…/lib/appium.js:183:43)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at AppiumDriver.createSession (…/…/lib/appium.js:183:31)
at …/…/…/lib/basedriver/driver.js:218:24
at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:248:10)
at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
Error: The desired capabilities must include either an app or a bundleId for iOS
at Object.wrappedLogger.errorAndThrow (…/…/lib/logging.js:63:13)
at XCUITestDriver.validateDesiredCaps (…/…/lib/driver.js:738:11)
at XCUITestDriver.callee$0$0$ (…/…/…/…/lib/basedriver/commands/session.js:14:8)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.callee$0$0 [as createSession] (…/…/…/…/lib/basedriver/commands/session.js:8:46)
at XCUITestDriver.createSession$ (…/…/lib/driver.js:113:21)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.createSession (…/…/lib/driver.js:185:21)
at AppiumDriver.createSession$ (…/…/lib/appium.js:183:43)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at AppiumDriver.createSession (…/…/lib/appium.js:183:31)
at …/…/…/lib/basedriver/driver.js:218:24
at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:248:10)
at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
[debug] [XCUITest] Not clearing log files. Use clearSystemFiles capability to turn on.
[MJSONWP] Encountered internal error running command: Error: The desired capabilities must include either an app or a bundleId for iOS
at Object.wrappedLogger.errorAndThrow (…/…/lib/logging.js:63:13)
at XCUITestDriver.validateDesiredCaps (…/…/lib/driver.js:738:11)
at XCUITestDriver.callee$0$0$ (…/…/…/…/lib/basedriver/commands/session.js:14:8)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.callee$0$0 [as createSession] (…/…/…/…/lib/basedriver/commands/session.js:8:46)
at XCUITestDriver.createSession$ (…/…/lib/driver.js:113:21)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at XCUITestDriver.createSession (…/…/lib/driver.js:185:21)
at AppiumDriver.createSession$ (…/…/lib/appium.js:183:43)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
at AppiumDriver.createSession (…/…/lib/appium.js:183:31)
at …/…/…/lib/basedriver/driver.js:218:24
at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/promise.js:248:10)
at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
[HTTP] <-- POST /wd/hub/session 500 106 ms - 210

Ok, not sure why that happens - please put back the bundle id.

Check if this link helps:
https://github.com/appium/appium/issues/7348

Pasting this solution from the above link:

i had same issue on my simulator, and that what i do:

go to your project home dir
$ xcodebuild -showsdks
copy required iOS Simulator SDK
build the simulator package:
if you are using xcodeproj:
$ xcodebuild -arch i386 -sdk iphonesimulator{iosSimulatorSdkVersionThatYouChoise}
if you are using workspace:
$ xcodebuild -arch i386 -sdk iphonesimulator{iosSimulatorSdkVersionThatYouChoise} -workspace [projectName].xcworkspace -scheme [projectName]

.app you can find in ~/Developer/Xcode/DerivedData/[yourAppName]/Build/products/Debug-iphonesimulator/[yourApp].app

when i run test with this .app - application start correctly

im using:
appium 1.6.3
os x el capitan 10.11.6
iphone SE simulator 10.2
xcode 8.2.1

Also there is a new version of Appium v1.7.0 update to that and clean & build the app freshly from your Xcode and try.

Issue is fixed, the app was not debug permission enabled,
now its working fine

Thanks