calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 368 forks source link

Cannot connect to DeviceAgent service #1406

Open Tjmoronez opened 5 years ago

Tjmoronez commented 5 years ago

This is my first time running UI tests with calabash and I am running into an issue with the DeviceAgent. iOS - 11.4.1 Xcode - 10.1 MacOS - Mojave calabash-cucumber- 0.21.8

running start_test_server_in_background in calabash-ios console is giving me the error Could not connect to the DeviceAgent service.

calabash-ios 0.21.8> start_test_server_in_background SHELL: xcrun simctl list devices --json SHELL: xcrun instruments -s devices DEBUG: HTTP: get http://192.168.1.8:27753/1.0/health {:retries=>1, :timeout=>0.5} DEBUG: HTTP: get http://192.168.1.8:27753/1.0/health {:retries=>1, :timeout=>0.5} DEBUG: Waiting for DeviceAgent to launch... SHELL: /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/bin/iOSDeviceManager install /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app --device-id 15ccaf277cf790a6b781e27a8b3180dd8ccc3d0d DEBUG: Took 4.935408 seconds to install DeviceAgent SHELL: xcrun xcodebuild test-without-building -xctestrun /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app/PlugIns/DeviceAgent.xctest/DeviceAgent-device.xctestrun -destination id=15ccaf277cf790a6b781e27a8b3180dd8ccc3d0d -derivedDataPath /Users/me/.run-loop/DeviceAgent/DerivedData >& /Users/me/.run-loop/DeviceAgent/current.log DEBUG: HTTP: get http://192.168.1.8:27753/1.0/health {:retries=>1800, :timeout=>180.0} Traceback (most recent call last): 12: from /usr/local/bin/irb:11:in <main>' 11: from (irb):1 10: from /usr/local/lib/ruby/gems/2.5.0/gems/calabash-cucumber-0.21.8/lib/calabash-cucumber/core.rb:1576:instart_test_server_in_background' 9: from /usr/local/lib/ruby/gems/2.5.0/gems/calabash-cucumber-0.21.8/lib/calabash-cucumber/launcher.rb:365:in relaunch' 8: from /usr/local/lib/ruby/gems/2.5.0/gems/calabash-cucumber-0.21.8/lib/calabash-cucumber/launcher.rb:412:innew_run_loop' 7: from /usr/local/lib/ruby/gems/2.5.0/gems/calabash-cucumber-0.21.8/lib/calabash-cucumber/launcher.rb:412:in times' 6: from /usr/local/lib/ruby/gems/2.5.0/gems/calabash-cucumber-0.21.8/lib/calabash-cucumber/launcher.rb:414:inblock in new_run_loop' 5: from /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop.rb:113:in run' 4: from /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/client.rb:184:inrun' 3: from /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/client.rb:313:in launch' 2: from /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/client.rb:1476:inlaunch_cbx_runner' 1: from /usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/client.rb:1485:in `rescue in launch_cbx_runner' RuntimeError (

Could not connect to the DeviceAgent service.

device: #<Device: My iPhone (11.4.1) 15ccaf277cf790a6b781e27a8b3180dd8ccc3d0d> url: http://192.168.1.8:27753/

To diagnose the problem tail the launcher log file:

$ tail -1000 -F /Users/me/.calabash/iOSDeviceManager/logs/current.log

) calabash-ios 0.21.8>

The logs files don't display anything that looks useful:

2019-02-21 16:05:54.502 DEBUG FBControlCoreLogger:281 | Attempting to load missing framework DTGraphKit.framework 2019-02-21 16:05:54.503 DEBUG FBControlCoreLogger:281 | DTGraphKit.framework could not be loaded from fallback directory /Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/Developer/../Frameworks 2019-02-21 16:05:54.503 DEBUG FBControlCoreLogger:281 | DTGraphKit: Loading from /Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/SharedFrameworks/DTGraphKit.framework 2019-02-21 16:05:54.505 DEBUG FBControlCoreLogger:281 | DTGraphKit: Successfully loaded 2019-02-21 16:05:54.505 DEBUG FBControlCoreLogger:281 | DTGraphKit.framework has been loaded from fallback directory '/Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/Developer/../SharedFrameworks', re-attempting to load IDEKit 2019-02-21 16:05:54.522 DEBUG FBControlCoreLogger:281 | IDEKit: Successfully loaded 2019-02-21 16:05:54.522 DEBUG FBControlCoreLogger:281 | IDESourceEditor: Loading from /Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/PlugIns/IDESourceEditor.ideplugin 2019-02-21 16:05:54.524 DEBUG FBControlCoreLogger:281 | IDESourceEditor: Successfully loaded 2019-02-21 16:05:54.524 DEBUG FBControlCoreLogger:281 | DFRSupportKit: Loading from /Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/Frameworks/DFRSupportKit.framework 2019-02-21 16:05:54.525 DEBUG FBControlCoreLogger:281 | DFRSupportKit: Successfully loaded 2019-02-21 16:05:54.525 DEBUG FBControlCoreLogger:281 | DVTKit: Loading from /Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/SharedFrameworks/DVTKit.framework 2019-02-21 16:05:54.526 DEBUG FBControlCoreLogger:281 | DVTKit: Successfully loaded 2019-02-21 16:05:54.526 DEBUG FBControlCoreLogger:281 | DebugHierarchyFoundation: Loading from /Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/SharedFrameworks/DebugHierarchyFoundation.framework 2019-02-21 16:05:54.528 DEBUG FBControlCoreLogger:281 | DebugHierarchyFoundation: Successfully loaded 2019-02-21 16:05:54.528 DEBUG FBControlCoreLogger:281 | DebugHierarchyKit: Loading from /Users/thomas/Applications/Xcode/10.1/Xcode.app/Contents/SharedFrameworks/DebugHierarchyKit.framework 2019-02-21 16:05:54.529 DEBUG FBControlCoreLogger:281 | DebugHierarchyKit: Successfully loaded 2019-02-21 16:05:54.530 DEBUG FBControlCoreLogger:281 | Loaded All Private Frameworks [DTXConnectionServices, IDEFoundation, IDEiOSSupportCore, IBAutolayoutFoundation, IDEKit, IDESourceEditor, DFRSupportKit, DVTKit, DebugHierarchyFoundation, DebugHierarchyKit]

Any help would be appreciated, thank you

JoeSSS commented 5 years ago

Hey, does Calabash run against Simulator on your machine?

Tjmoronez commented 5 years ago

@JoeSSS Yes it does.

JoeSSS commented 5 years ago

nice. then your ENV is fine :) I wonder if it is because of older iOS version. Do you have a phone with iOS 12.1 maybe?

Am Fr., 22. Feb. 2019 um 08:29 Uhr schrieb Tjmoronez < notifications@github.com>:

@JoeSSS https://github.com/JoeSSS Yes it does.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/calabash/calabash-ios/issues/1406#issuecomment-466301472, or mute the thread https://github.com/notifications/unsubscribe-auth/ARTqPKg6aLfb2Ijgf51Mw8eK-KcVoCYfks5vP5xbgaJpZM4bImrp .

Tjmoronez commented 5 years ago

@JoeSSS I get the same error on a ios phone with 12.1 as well.

I should have included this in original post, I see run-loop install the DeviceAgent app on my phone, but then I see no indication that my app or DeviceAgent opens. I just run into the time out on: DEBUG: HTTP: get http://192.168.1.8:27753/1.0/health {:retries=>1800, :timeout=>180.0}

JoeSSS commented 5 years ago

Just to make sure.. your devices are in the same network, app is installed and all the prerequisites from https://github.com/calabash/calabash-ios/wiki/Testing-on-Physical-Devices#2-configuring-your-device are met?

Tjmoronez commented 5 years ago

Yes, all those prerequisites are met.

Additional info, after looking into

/Users/me/.run-loop/DeviceAgent/DerivedData >& /Users/me/.run-loop/DeviceAgent/current.log

When start_test_server_in_background runs xcrun xcodebuild test-without-building -xctestrun /Users/me/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/run_loop-4.1.0/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app/PlugIns/DeviceAgent.xctest/DeviceAgent-device.xctestrun -destination id=15ccaf277cf790a6b781e27a8b3180dd8ccc3d0d -derivedDataPath /Users/me/.run-loop/DeviceAgent/DerivedData I am seeing the following error:


2019-02-25 12:07:37.769 xcodebuild[33249:960085] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2019-02-25 12:07:37.769 xcodebuild[33249:960085] [MT] IDETestOperationsObserverDebug: 13.614 sec, +13.614 sec -- end
2019-02-25 12:07:37.769 xcodebuild[33249:960085] 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, NSUnderlyingError=0x7fd673363a30 {Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Test runner exited before starting test execution." UserInfo={NSLocalizedDescription=Test runner exited before starting test execution., NSLocalizedRecoverySuggestion=If you believe this error represents a bug, please attach the result bundle at /Users/me/.run-loop/DeviceAgent/DerivedData/Logs/Test/Test-Transient Testing-2019.02.25_12-07-24--0800.xcresult}}}

Testing failed:
    Runner (327) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying error: Test runner exited before starting test execution.))
** TEST EXECUTE FAILED **```
Tjmoronez commented 5 years ago

I am also seeing a code signing error when I dive deeper into logs:

2019-02-26 14:46:20.213 DeviceAgent-Runner[269:7562] Running tests...
2019-02-26 14:46:20.283 DeviceAgent-Runner[269:7562] The bundle “DeviceAgent” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2019-02-26 14:46:20.283 DeviceAgent-Runner[269:7562] (dlopen_preflight(/var/containers/Bundle/Application/8A1420FD-1447-4764-B6A5-5F893144EE46/DeviceAgent-Runner.app/PlugIns/DeviceAgent.xctest/DeviceAgent): no suitable image found.  Did find:
    /var/containers/Bundle/Application/8A1420FD-1447-4764-B6A5-5F893144EE46/DeviceAgent-Runner.app/PlugIns/DeviceAgent.xctest/DeviceAgent: code signature invalid for '/var/containers/Bundle/Application/8A1420FD-1447-4764-B6A5-5F893144EE46/DeviceAgent-Runner.app/PlugIns/DeviceAgent.xctest/DeviceAgent'
)
JoeSSS commented 5 years ago

From different logs I see different Ruby versions that are used. I think officially the tool supports Ruby 2.3.1. Can you try to change to this one?

Tjmoronez commented 5 years ago

Same results for ruby 2.3.1, logs stating: code signature invalid for DeviceAgent, I should be able to code sign this with my apple dev cert correct?

jmoody commented 5 years ago

Sadly, 2.3.x is the supported version. Calabash is not ready for 2.4 or 2.5

/usr/local/lib/ruby/gems/2.5.0/gems/run_loop-4.1.0/

Is that directory and the directories under it writeable without sudo? run-loop needs to expand the DeviceAgent-Runner.app.zip.

The code signing problem needs to be addressed.

Try using iOSDeviceManager to resign or install the DeviceAgent-Runner.app.