How does JetBrains AppCode launch the iOS Simulator?

前端 未结 6 1927
故里飘歌
故里飘歌 2021-01-30 18:48

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 pr

相关标签:
6条回答
  • 2021-01-30 19:02

    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... ;)

    0 讨论(0)
  • 2021-01-30 19:04

    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.

    0 讨论(0)
  • 2021-01-30 19:05

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

    0 讨论(0)
  • 2021-01-30 19:09

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

    0 讨论(0)
  • 2021-01-30 19:21

    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?

    0 讨论(0)
  • 2021-01-30 19:22

    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.

    0 讨论(0)
提交回复
热议问题