JetBrains AppCode 如何启动 iOS 模拟器?

发布于 2024-11-10 13:21:10 字数 2627 浏览 3 评论 0原文

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

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

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

更新:

  1. 在查看活动监视器时,我发现 osascript 在模拟器启动之前从 simlauncher 启动。会不会又是Applescript?我认为 iOS Simulator.app 不可编写脚本。
  2. iOS Simulator 似乎是由 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

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

但有一个问题。所有这些二进制文件都引用模拟器平台根目录中存在的 dylib。当我直接运行它们时,它们会查找“/”中的内容。

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

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

I just looked at JetBrains's App Code IDE and it seems to be able to launch the iOS Simulator and run applications in it.

When I had to automate the deployment of my projects I had to resort to Applescript and GUI automation.

They seem to be using a closed tool called 'simlauncher'. I wonder what the magic behind it could be.

Update:

  1. On looking at Activity Monitor, I see that osascript gets launched from simlauncher before the simulator is launched. Could it be Applescript again? I thought iOS Simulator.app was not scriptable.
  2. iOS Simulator seems to be launched by launchd, so simlauncher is definitely not launching it by itself. Also, simlauncher stays only until the actual application is running in the simulator. They're polling for it perhaps?
  3. For device builds, they're using AMDeviceService, which is probably a version of Apple Mobile Device Service. Is this a technique from the jail broken SDK?

A little more info on the simulator from the output of '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

Now I suppose it's just a matter of sorting the commands according to the pid and executing them. :-)

There's a problem, though. All these binaries refer to dylibs present in the simulator platform's root. When I run them directly, they look for those in '/'.

Is there a way to set the path for dylibs before running a command? This looks promising: http://sacredsoftware.net/svn/misc/StemLibProjects/eaglshell/tags/2.1.0/Makefile

https://github.com/BlueFrogGaming/icuke has good info too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

等风来 2024-11-17 13:21:10

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(兼容版本1.0.0,当前版本12.0.0)
    
  • 此框架与 Xcode 捆绑在一起:

    /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;
    @结尾
    
    @interface Launcher : NSObject ; {
        DTiPhoneSimulatorSession *mySession;
    }
    
    - (int)launch:(id)arg1 sdkVersion:(id)arg2 wait:(BOOL)arg3 设备:(int)arg4 sout:(id)arg5 eout:(id)arg6 参数:(id)arg7 env:(id )arg8;
    - (void)会话:(id)arg1 didEndWithError:(id)arg2;
    - (void)session:(id)arg1 didStart:(BOOL)arg2 withError:(id)arg3;
    
    @结尾
    

关于其他二进制AMDeviceService 我只能说它使用 ProtocolBuffers 来进行通信使用 MobileDevice 服务...再次,未记录的东西...

快速结论,抱歉,没有简单的方法使用 JetBrains 方式启动 iPhoneSimulator,除非反转 Apple 私有/未记录的 API...就像 Jetbrains 的人所做的那样,我喜欢他们的工具,他们是顶级枪手,迫不及待地将应用程序代码变成黄金,每天都在努力:)

编辑:请参阅下面来自 JetBrains 员工的答案...@JetBrains,非常高兴有某种AMDeviceService记录来自动化一些东西......;)

AppCode use a special wrapper to do this, that you noticed in its console :

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

simlauncher is a non documented / not friendly mach-o binary... But here is a quick analysis of it:

  • To launch simulator it uses a private Apple framework (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)
    
  • This framework is bundled with Xcode:

    <XCODE_PATH>/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/iPhoneSimulatorRemoteClient.framework
    
  • And is used like that (class-dump simlauncher) (DTiPhoneSimulator* are from 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
    

About the other binary AMDeviceService I just can say it uses ProtocolBuffers in order I guess to communicate with MobileDevice service... Once again, undocumented stuff...

Quick conclusion, sorry, there is no easy way to launch iPhoneSimulator using the JetBrains way, unless reversing Apple privates/not documented APIs... like Jetbrains folks did, I love their tools, they are top guns, can't wait appcode to be gold, already working on it everyday :)

EDIT: See answer below from a JetBrains employee... @JetBrains, would be great to have some sort of AMDeviceService documented to automate some stuff... ;)

初吻给了烟 2024-11-17 13:21:10

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

关于“3”:

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

该服务在设备上部署应用程序、安装开发人员映像、浏览设备上的应用程序并启动调试服务器。

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

What exactly do you want to automate? Installing app and launching it in simulator or device?

About "3":

AMDeviceService is just some daemon which is responsible for any interaction with device. It uses only /System/Library/PrivateFrameworks/MobileDevice.framework library(it's private). It doesn't know about any /Developer stuff (of course if you are not going to debug on device).

This service deploys app on device, mounts developer image, browses apps on device and starts debugserver.

It uses Google Protocol Buffers based protocol to communicate with AppCode. Not Apple-stuff.

仙女山的月亮 2024-11-17 13:21:10

不能 100% 确定这就是您的问题,但我可以运行任意模拟器编译的应用程序,其文件夹位于模拟器的桌面上(例如),并在终端中使用以下行(全部一行) ,替换适合您系统的值):

/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication 
/Users/myusername/Desktop/[the alphanumeric app directory name]/MyCompiledAppProject.app/MyCompiledAppProject

其中最后一个“MyCompiledAppProject”文件是包内以 .app 结尾的实际二进制文件(您必须按住 Ctrl 键单击 .app 文件并选择“显示包”内容”来查看)。如果模拟器尚未打开,这将启动模拟器。它可以轻松地打包在 AppleScript 中,该 AppleScript 将新编译的应用程序位置作为文件参数,并且不需要打开 Xcode 或使用 xcodebuild。

Not 100% sure this is what your question is about, but I'm able to run an arbitrary Simulator-compiled app whose folder I have on the Desktop (for instance) in the Simulator with the following line in the terminal (all one line, substituting appropriate values for your system):

/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication 
/Users/myusername/Desktop/[the alphanumeric app directory name]/MyCompiledAppProject.app/MyCompiledAppProject

Where that last "MyCompiledAppProject" file is the actual binary that is inside of the package which ends with .app (you'll have to control-click on the .app file and select "Show Package Contents" to see it). This will launch the Simulator if it isn't already open. It could easily be packaged in an AppleScript that takes the newly-compiled app location as a file argument and doesn't require Xcode to be open or xcodebuild to be used.

深居我梦 2024-11-17 13:21:10

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

The iphonesim project gives you a command-line launcher for iOS apps. I believe it packages up what you want.

把时间冻结 2024-11-17 13:21:10

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

I think I read somewhere that they rely on Xcode to do this sort of thing for them. But it wasn't very specific, and I don't know where I read it. Maybe they're scripting Xcode to launch and deploy, instead of the simulator directly?

ㄖ落Θ余辉 2024-11-17 13:21:10

电话差距的类似项目位于 https://github.com/phonegap/ios-sim

Similar project by phone gap is at https://github.com/phonegap/ios-sim.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文