Schlaubischlump / LocationSimulator

MacOS application to spoof / fake / mock your iOS / iPadOS or iPhoneSimulator device location. WatchOS and TvOS are partially supported.
https://schlaubischlump.github.io/LocationSimulator/
GNU General Public License v3.0
2.53k stars 196 forks source link

[BUG] Simulator Support is broken #85

Closed Schlaubischlump closed 3 years ago

Schlaubischlump commented 3 years ago

Describe the bug Apple broke the iOS Simulator support with Xcode 12.5:

[Error]: Could not get port for name: 'com.apple.iphonesimulator.bridge.1339'

Further research shows that the

-(char)findServiceInSession:(void *)arg2 serviceName:(void *)arg3 servicePort:(unsigned int *)arg4 error:(void * *)arg5

method of SimLaunchHostClient fails. I assume Apple somehow disallows accessing the port from inside a sandboxed process or renamed the port ? Which leads to the questions:

  1. Does it help to remove the sandbox ? No, I tried.
  2. How does Xcode do it ?
  3. How does Facebooks idb do it ? Turns out Facebooks idb currently does not support the Simulator bridge in Xcode 12.5. Keep an eye on https://github.com/facebook/idb. I assume Apple somehow changed how the simulator bridge port is named.

Solution It seem like SimDevice now implements the setLocationWithLatitude:andLongitude:error: method. It is therefore no longer necessary to obtain a bridge connection. The solution is therefore:

  1. Add a isConnected attribute
  2. For Xcode 12.4 set the variable to _bridge != NULL for 12.5 set it to true for each device and set it to false when terminating the simulator / the simulator instance was closed
  3. Check if SimDevice implements setLocationWithLatitude:andLongitude:error: inside of - (BOOL)setLocationWithLatitude:(double)latitude andLongitude:(double)longitude
  4. Either delegate the call to the bridge or call the method directly
  5. Implement the reset location by using clearSimulatedLocationWithError: for Xcode 12.5
  6. We can not map the pid to SimDevice anymore. Try to use the bootStatus to detect if the simulator for this specific device was shut down

To Reproduce Try to find a Simulator device.

Expected behavior The Simulator device is detected.

Notes Seems like Apple removed the SimulatorBridge executable ?. If this is the case it is no wonder, that nothing is working anymore.