JetBrains AppCode如何启动iOS模拟器?

Plu*_*tor 17 automation simulator ios appcode

我只看了JetBrains的应用程序代码IDE,它似乎能够启动iOS模拟器并在其中运行应用程序.

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

他们似乎正在使用一种名为"simlauncher"的封闭工具.我想知道它背后的魔力是什么.

更新:

  1. 在查看Activity Monitor时,我看到osascript在模拟器启动之前从simlauncher启动.它可以再次成为Applescript吗?我以为iOS Simulator.app不是可编写脚本的.
  2. iOS模拟器似乎是由launchd发布的,所以simlauncher肯定不是自己发布的.此外,simlauncher仅在实际应用程序在模拟器中运行之前保持不变.他们也许正在为它进行投票?
  3. 对于设备构建,他们使用的是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
Run Code Online (Sandbox Code Playgroud)

现在我想这只是根据pid对命令进行排序并执行它们的问题.:-)

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

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

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

Vin*_*rci 25

AppCode使用一个特殊的包装器来执行此操作,您在其控制台中注意到:

/Applications/AppCode-108.379.app/bin/simlauncher 4.3 debug iphone <PATH_TO_APP> <STDOUT> <STDERR>
Run Code Online (Sandbox Code Playgroud)

simlauncher 是一个没有文件记录/不友好的机器人二进制......但这里有一个快速分析它:

  • 要启动模拟器,它使用私有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)
    
    Run Code Online (Sandbox Code Playgroud)
  • 这个框架与Xcode捆绑在一起:

    <XCODE_PATH>/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/iPhoneSimulatorRemoteClient.framework
    
    Run Code Online (Sandbox Code Playgroud)
  • 就像那样(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
    
    Run Code Online (Sandbox Code Playgroud)

关于其他二进制文件,AMDeviceService我只能说它使用ProtocolBuffers以便我想与MobileDevice服务进行通信......再一次,没有文档的东西......

快速的结论,对不起,没有简单的方法来使用JetBrains方式启动iPhoneSimulator,除非逆转Apple私有/未记录的API ...像Jetbrains的人一样,我喜欢他们的工具,他们是顶级枪,不能等待appcode到是黄金,每天都在努力:)

编辑:请参阅以下JetBrains员工的答案... @JetBrains,如果有某种AMDeviceService记录可以自动化某些东西会很棒......;)

  • +1很棒的分析!我在哪里可以学习这样的逆向工程?另外,AppCode长期依赖这个是个好主意吗?Apple可以随时更改它. (2认同)

小智 11

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

关于"3":

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

此服务在设备上部署应用程序,安装开发人员映像,浏览设备上的应用程序并启动debugserver.

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