JetBrains AppCode如何启动iOS模拟器?

我只是看着JetBrains的App Code IDE,它似乎能够启动iOS模拟器并在其中运行应用程序。

当我不得不自动部署我的项目时,我不得不求助于Applescript和GUI自动化。

他们似乎正在使用一个叫做“simlauncher”的封闭工具。 我不知道它背后的魔法是什么。

更新:

  1. 在看活动监视器,我看到osascript从模拟器启动之前从simlauncher启动。 它可以再次成为Applescript吗? 我以为iOS Simulator.app不是脚本的。
  2. iOS模拟器似乎是由launchd启动,所以simlauncher绝对不是自己启动它。 此外,simlauncher只保留到实际应用程序正在模拟器中运行。 他们正在投票吗?
  3. 对于设备构build,他们正在使用AMDeviceService,这可能是Apple Mobile Device Service的一个版本。 这是一个来自jail破解SDK的技术吗?

模拟器上的'ps'输出的更多信息:

plumenator 26404 12.9 1.3 290172 52772 ?? SX 8:56PM 0:03.62 /Users/plumenator/Library/Application Support/iPhone Simulator/4.3.2/Applications/817A280D-1F74-4755-B848-B04EC8A24ADA/xxx.app/xxx plumenator 26395 2.3 0.3 444208 13560 ?? S 8:56PM 0:00.72 /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator -SessionOnLaunch NO plumenator 26402 1.4 0.8 318320 33052 ?? Us 8:56PM 0:00.86 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/CoreServices/SpringBoard.app/SpringBoard -SBDisableAutoDim YES -SBAutoLockTime -1 -SBAutoDimTime -1 -SBDontLockAfterCrash YES -SBDidShowReorderText YES -SBFakeBars YES -SBDontAnimateAppleDown YES -SBEnableDoubleHeightToggling YES plumenator 26406 0.0 0.4 2466496 15792 ?? Ss 8:56PM 0:00.16 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin --arch i386 --interp=mi1 -q plumenator 26401 0.0 0.1 106584 5688 ?? S 8:56PM 0:00.30 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/libexec/lsd plumenator 26400 0.0 0.1 105228 4204 ?? S 8:56PM 0:00.13 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/libexec/installd -t 30 plumenator 26399 0.0 0.3 223488 11464 ?? Ss 8:56PM 0:00.15 /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/SimulatorBridge 26395 

现在我想这只是根据pid对命令进行sorting并执行它们的问题。 🙂

但是,有一个问题。 所有这些二进制文件都指向模拟器平台根目录中的dylib。 当我直接运行它们时,它们在'/'中查找。

有没有办法在运行命令之前设置dylib的path? 这看起来很有希望: http : //sacredsoftware.net/svn/misc/StemLibProjects/eaglshell/tags/2.1.0/Makefile

https://github.com/BlueFrogGaming/icuke也有很好的信息。

AppCode使用一个特殊的包装来做到这一点,你在控制台中注意到:

 /Applications/AppCode-108.379.app/bin/simlauncher 4.3 debug iphone <PATH_TO_APP> <STDOUT> <STDERR> 

simlauncher是一个没有logging/不友好的mach-o二进制文件…但这里是一个快速分析:

  • 要启动模拟器,它使用一个私人的苹果框架( otool -L simlauncher ):

     /Applications/AppCode-108.379.app/bin/simlauncher: @rpath/iPhoneSimulatorRemoteClient.framework/Versions/A/iPhoneSimulatorRemoteClient (compatibility version 1.0.0, current version 12.0.0) 
  • 这个框架与Xcode捆绑在一起:

     <XCODE_PATH>/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/iPhoneSimulatorRemoteClient.framework 
  • 和类似的使用( class-dump simlauncher )( DTiPhoneSimulator*来自苹果框架):

     @protocol DTiPhoneSimulatorSessionDelegate - (void)session:(id)arg1 didEndWithError:(id)arg2; - (void)session:(id)arg1 didStart:(BOOL)arg2 withError:(id)arg3; @end @interface Launcher : NSObject <DTiPhoneSimulatorSessionDelegate> { DTiPhoneSimulatorSession *mySession; } - (int)launch:(id)arg1 sdkVersion:(id)arg2 wait:(BOOL)arg3 device:(int)arg4 sout:(id)arg5 eout:(id)arg6 argument:(id)arg7 env:(id)arg8; - (void)session:(id)arg1 didEndWithError:(id)arg2; - (void)session:(id)arg1 didStart:(BOOL)arg2 withError:(id)arg3; @end 

关于其他二进制AMDeviceService我只是可以说它使用ProtocolBuffers为了我想与MobileDevice服务进行通信…再次,无证材料…

快速的结论,对不起,没有简单的方法来启动iPhoneSimulator使用JetBrains的方式,除非扭转苹果私有/没有logging的API …像Jetbrains人做的,我喜欢他们的工具,他们是顶级枪,不能等待应用代码是金子,已经在每天工作:)

编辑:从JetBrains的员工看下面的答案… @JetBrains,将很高兴有某种AMDeviceServicelogging自动化一些东西…;)

你想要什么自动化? 安装应用程序并在模拟器或设备中启动它?

关于“3”:

AMDeviceService只是一些守护进程,负责与设备的任何交互。 它只使用/System/Library/PrivateFrameworks/MobileDevice库(它是私有的)。 它不知道任何/Developer东西(当然,如果你不打算在设备上进行debugging)。

此服务在设备上部署应用程序,安装开发人员图像,浏览设备上的应用程序并启动debugging服务器。

它使用基于Google Protocol Buffers的协议与AppCode进行通信。 不是苹果的东西。

不是100%确定这是你的问题是关于,但我能够运行一个任意的模拟器编译的应用程序的文件夹,我在桌面上(例如)在模拟器中与terminal中的以下行(全部一行,用适当的值代替你的系统):

  /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone \ Simulator.app/Contents/MacOS/iPhone \ Simulator -SimulateApplication 
 / Users / myusername / Desktop / [字母数字应用目录名称] /MyCompiledAppProject.app/MyCompiledAppProject 

最后一个“MyCompiledAppProject”文件是以.app结尾的软件包内的实际二进制文件(你需要用鼠标右键单击.app文件并select“Show Package Contents”才能看到它)。 这将启动模拟器,如果它尚未打开。 它可以很容易地打包在一个AppleScript中,将新编译的应用程序位置作为文件参数,并且不需要Xcode打开或使用xcodebuild。

iphonesim项目为您提供iOS应用程序的命令行启动器。 我相信它包装了你想要的东西。

我想我在某处读到他们依靠Xcode为他们做这种事情。 但这不是很具体,我不知道我在哪里阅读。 也许他们正在脚本编写Xcode来启动和部署,而不是直接模拟器?

通过电话差距类似的项目是在https://github.com/phonegap/ios-sim