3

As we know, in xcode6 or xcode7, app documents path will change for every run project, like below

/Users/jakey/Library/Developer/CoreSimulator/Devices/0149D36B-A46E-4326-BF59-AFEF7D2CA8B2/data/Containers/Data/Application/FDCA4FAF-4940-485B-A6B6-5CEE4C75B72F/Documents

but I'm often use some tools such as navicat to access document's. sqlite, If every time run the path changed, navicat can not connection db normally.

Tushar
  • 4,280
  • 5
  • 24
  • 39
skyfox
  • 41
  • 3

3 Answers3

3

This is not possible. Every time you hit Build & Run, your app is re-installed, so its container is changed.

With Xcode 7, there's a new simctl subcommand that might be helpful for you:

$ xcrun simctl get_app_container --help
Usage: simctl get_app_container <device> <app identifier>

You might want to make an alias like:

alias cdmyapp='cd $(xcrun simctl get_app_container booted com.mycompany.myapp)'

Then you can just run 'cdmyapp' from Terminal.app to enter your app's container.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
0

I'm afraid this isn't possible. I imagine you would want to save files within your document directory. That is strictly within the path you've mentioned and changes.

Shamas S
  • 7,507
  • 10
  • 46
  • 58
0

Old question but I want to share my solution in case it helps someone in future.

You can use the ln(aka link) command to create some hard links that keep track with latest iOS simulator sandbox files.

For example, you can create a "SimulatorDB" folder on your Desktop, then run your application and get the latest Core Data sqlite file's path inside Sandbox, then run these 3 commands to create 3 hard links:

ln /{your-app-container-path}/Library/Application\ Support/App.sqlite ~/Desktop/SimulatorDB/App.sqlite
ln /{your-app-container-path}/Library/Application\ Support/App.sqlite-shm ~/Desktop/SimulatorDB/App.sqlite-shm
ln /{your-app-container-path}/Library/Application\ Support/App.sqlite-wal ~/Desktop/SimulatorDB/App.sqlite-wal

Then config your DB browser software to connect ~/Desktop/SimulatorDB/App.sqlite directly.

Notes: This works fine only on small amount of files, if you need to keep track on a sandbox folder with many files, the APFS seems not supporting this operation: https://github.com/selkhateeb/hardlink/issues/31#issuecomment-332993819

There is some tools for create hard link on directory in macOS, but I haven't try them yet: What is the Unix command to create a hardlink to a directory in OS X?

小广东
  • 1,151
  • 12
  • 20