Reputation: 5804
macOS Sierra, Xcode 8.2.
I want to run the Xcode iOS simulator in a sandbox so I can limit network connectivity for applications I'm testing.
Based on what I saw here, I created a sandbox file like this:
(version 1)
(allow default)
(deny network*)
Then I ran the simulator like this: sandbox-exec -f ~/Desktop/block_network.sb /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator
It seems that this doesn't properly connect Simulator to whatever other processes are managing it. The sim launches but says the device can't be found, and running in Xcode just opens up a different simulator. I also see this error in my terminal: CoreSimulatorService connection became invalid. Simulator services will no longer be available.
Any ideas?
I also tried removing (deny network*)
from the sb file so everything is allowed; same problem.
Upvotes: 0
Views: 931
Reputation: 17249
This is very much unsupported but the problem is most likely the mach ports needed are being blocked by the sandbox.
You can try:
(allow mach-lookup)
(allow mach-register)
(allow distributed-notification-post)
(allow file-read* (regex #";^/[^/]+/CoreSimulator/[^/]+$"))
Look at the logs for sandbox violations then add exceptions as needed.
Upvotes: 1