JetBrains AppCode如何启动iOS模拟器?

问题描述

| 我只是看了JetBrains的App Code IDE,它似乎能够启动iOS Simulator并在其中运行应用程序。 当我不得不自动化项目的部署时,我不得不求助于Applescript和GUI自动化。 他们似乎正在使用名为“'simlauncher \”的封闭工具。我想知道背后的魔力是什么。 更新: 通过查看活动监视器,我发现在启动模拟器之前,已从simlauncher启动了osascript。可以再次成为Applescript吗?我认为iOS Simulator.app无法编写脚本。 iOS Simulator似乎是通过启动来启动的,因此simlauncher绝对不是自己启动的。此外,simlauncher只会保留到实际的应用程序在模拟器中运行之前。他们正在为此投票吗? 对于设备版本,他们使用的是AMDeviceService,这可能是Apple Mobile Device Service的一个版本。这是越狱的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排序命令并执行它们的问题。 :-) 不过有一个问题。所有这些二进制文件都引用了模拟器平台根目录中的dylib。当我直接运行它们时,它们会在\'/ \'中查找它们。 有没有一种方法可以在运行命令之前为dylib设置路径?这看起来很有希望: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
是未记录的/不友好的mach-o二进制...但是这里是对它的快速分析: 要启动模拟器,它使用私有的Apple框架(
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*
来自Apple Framework):
@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
关于其他二进制文件“ 9”,我只能说它使用ProtocolBuffer以便与“ 10”服务进行通信...再一次,是未公开的文件... 快速结论,很抱歉,没有简单的方法可以使用JetBrains方式启动iPhoneSimulator,除非逆转Apple私有/未记录的API……就像Jetbrains的人那样,我喜欢他们的工具,他们是顶尖的枪手,迫不及待地等待appcode成为黄金,每天都在努力:) 编辑:请参阅下面来自JetBrains员工的答案... @JetBrains,非常高兴能有某种形式的to9ѭ文档来使某些东西自动化...;)     ,        您到底想自动化什么?安装应用程序并在模拟器或设备中启动它? 关于“ 3”:
AMDeviceService
只是一个守护进程,负责与设备进行任何交互。它仅使用
/System/Library/PrivateFrameworks/MobileDevice
.framework库(是私有的)。它不知道任何ѭ14的内容(当然,如果您不打算在设备上进行调试)。 此服务在设备上部署应用程序,挂载开发人员映像,浏览设备上的应用程序并启动debugserver。 它使用基于Google协议缓冲区的协议与AppCode通信。不是苹果的东西。     ,        并非100%肯定这是您的问题所在,但是我可以运行一个任意的Simulator编译的应用程序,该应用程序在我的Desktop中(例如)在Simulator中的文件夹中,并且在终端中有以下行(所有一个)行,为您的系统替换适当的值): /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone \\ Simulator.app/Contents/MacOS/iPhone \\ Simulator -SimulateApplication / Users / myusername / Desktop / [字母数字应用程序目录名称] /MyCompiledAppProject.app/MyCompiledAppProject 最后一个\“ MyCompiledAppProject \”文件是以.app结尾的程序包内部的实际二进制文件(您必须按住Control键并单击.app文件,然后选择\“ Show Package Contents \”以查看它)。如果尚未打开模拟器,它将启动模拟器。它可以很容易地打包在AppleScript中,该AppleScript将新编译的应用程序位置作为文件参数,并且不需要打开Xcode或使用xcodebuild。     ,        iphonesim项目为您提供iOS应用程序的命令行启动器。我相信它可以打包您想要的东西。     ,        我想我读过某个地方,他们依靠Xcode为他们做这种事情。但这不是很具体,我也不知道在哪里读。也许他们正在编写Xcode脚本来启动和部署,而不是直接使用模拟器?     ,通过电话缺口进行的类似项目位于https://github.com/phonegap/ios-sim。