calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Unity3D support #1137

Open stopiccot opened 8 years ago

stopiccot commented 8 years ago

After successfully using calabash to test Xamarin.Form apps I'm investigating if something similar could be done with Unity3D projects. I've found an old discussion (https://groups.google.com/forum/#!topic/calabash-ios/zli81OM28Fo). Can you please update on current state of Unity3D support?

jmoody commented 8 years ago

There is no plan to support Unity 3D at this time.

stopiccot commented 8 years ago

Ok. That's completely understandable. But any kind of help would be nice. Even thoughts have this could be done if you had time for that. And do you have that OpenGL example still?

stopiccot commented 8 years ago

Btw, is there any run_loop documentation?

jmoody commented 8 years ago

I dont have the OpenGL example. I have looked for numerous times and resigned myself to the fact that it is gone.

The idea to create a custom HTTP route using the LPRoute.h header in the calabash.framework. That route would be custom to your app. You would have to write an API that made sense to automate your app.

run-loop

Since this is mostly an internal tool, there is no formal documentation. Most classes, however are documented with yard format - although not very fastidiously. Anything with # @!visibility private can change at any time, regardless of its (ruby) visibility.

stopiccot commented 8 years ago

Thanks for response.

Btw I've already have some troubles with run_loop. I've created empty Unity 3D project and exported Xcode project from it. App runs in simulator without any problems.

But running app via calabash doesn't work. App installs but crashes on startup with this crash log:

0   libsystem_c.dylib               0x0000000107b14f92 strlen + 18
1   libsystem_c.dylib               0x0000000107b5ac14 __vfprintf + 5713
2   libsystem_c.dylib               0x0000000107b82745 __v2printf + 609
3   libsystem_c.dylib               0x0000000107b595ae vfprintf + 89
4   com.stopiccot.UnityRunLoop      0x0000000100991ba7 printf_consolev(LogType, char const*, __va_list_tag*) + 122 (LogAssert.cpp:753)
5   com.stopiccot.UnityRunLoop      0x0000000100991c81 printf_console + 159 (LogAssert.cpp:826)
6   com.stopiccot.UnityRunLoop      0x000000010091c11d PlayerConnection::InitializeListenSocket(ServerSocket&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) + 51 (PlayerConnection.cpp:234)
7   com.stopiccot.UnityRunLoop      0x000000010091bcd5 PlayerConnection::CreateListenSocket() + 69 (PlayerConnection.cpp:226)
8   com.stopiccot.UnityRunLoop      0x000000010091b7b2 PlayerConnection::PlayerConnection(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned short, bool) + 480 (PlayerConnection.cpp:112)
9   com.stopiccot.UnityRunLoop      0x000000010091c221 PlayerConnection::Initialize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 205 (PlayerConnection.cpp:315)
10  com.stopiccot.UnityRunLoop      0x00000001008be69e InitializeEngineNoGraphics() + 46 (SaveAndLoadHelper.cpp:186)
11  com.stopiccot.UnityRunLoop      0x00000001008a8cfd PlayerInitEngineNoGraphics(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 55 (Player.cpp:409)
12  com.stopiccot.UnityRunLoop      0x0000000100d16c62 UnityInitApplicationNoGraphics + 284 (LibEntryPoint.mm:189)
13  com.stopiccot.UnityRunLoop      0x000000010042834a -[UnityAppController application:didFinishLaunchingWithOptions:] + 370 (UnityAppController.mm:234)
14  com.apple.UIKit                 0x00000001050a89ac -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
15  com.apple.UIKit                 0x00000001050a9c0d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
16  com.apple.UIKit                 0x00000001050b0568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769
17  com.apple.UIKit                 0x00000001050ad714 -[UIApplication workspaceDidEndTransaction:] + 188
18  com.apple.FrontBoardServices    0x0000000108e478c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19  com.apple.FrontBoardServices    0x0000000108e47741 -[FBSSerialQueue _performNext] + 178
20  com.apple.FrontBoardServices    0x0000000108e47aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21  com.apple.CoreFoundation        0x0000000106c80301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22  com.apple.CoreFoundation        0x0000000106c7622c __CFRunLoopDoSources0 + 556
23  com.apple.CoreFoundation        0x0000000106c756e3 __CFRunLoopRun + 867
24  com.apple.CoreFoundation        0x0000000106c750f8 CFRunLoopRunSpecific + 488
25  com.apple.UIKit                 0x00000001050acf21 -[UIApplication _run] + 402
26  com.apple.UIKit                 0x00000001050b1f09 UIApplicationMain + 171
27  com.stopiccot.UnityRunLoop      0x00000001004131ed main + 141 (main.mm:32)
28  libdyld.dylib                   0x0000000107acb92d start + 1

Seems like app fails to open a socket when started by calabash. After some investigation it turned out that running app via xcrun instruments causes startup crash but running app via xcrun simctl launch booted <bundle_id> works fine. Any reasons behind that?

jmoody commented 8 years ago

Xcode 8?

stopiccot commented 8 years ago

No, Xcode 7.3.1, Unity 3D 5.4.0p1

stopiccot commented 8 years ago

Here is my features/support/env.rb file:

require 'calabash-cucumber'
require 'calabash-cucumber/launcher'
require 'calabash-cucumber/cucumber'
require 'calabash-cucumber/calabash_steps'

calabash_launcher = Calabash::Cucumber::Launcher.new

app_path = "./IOS/build/Release-iphonesimulator/UnityRunLoop.app"

options = {
  app: app_path,
  device_target: "iPhone 6 (9.3)",
  device: "iPhone 6 (9.3)"
}

ENV["APP_BUNDLE_PATH"] = app_path

calabash_launcher.relaunch(options)

I start app by running:

DEBUG=1 VERBOSE=1 cucumber
jmoody commented 8 years ago
# not a valid key, but it not the problem
device_target:

I think your -cal target is missing the cpp linker flags?

Other than that, I dont know why it would fail. I dont see the LPServer process mentioned in the crash report.

stopiccot commented 8 years ago

The thing is that it's not even calabash/run_loop related. If I run xcrun instruments ... from terminal and app crashes on start. If I run xcrun simctl launch booted ... it does not. So it's somehow related to Apple tooling. I just had a thought that given your expertise with Apple tools you may know that there is some well-known limitations of xcrun instuments approach.

stopiccot commented 8 years ago

So... Any ideas about xcrun instruments limitations?

jmoody commented 8 years ago

I don't have an ideas. 🎱

stopiccot commented 8 years ago

Ok. I've asked Unity guys too so maybe they can help. Anyway please dont close this issue yet in case I have more questions in future.

amugana commented 7 years ago

@stopiccot let me know if u find some solutions, i'm looking into it also, unity test automation for ios/android