10

With the latest changes to xcode 6, it looks like the .app file and document folder no longer resides in the same folder in the iPhone simulator directory.

Previously, we can access the directory and .app file at

/Users/me/Library/Application Support/iPhone Simulator/7.1/Applications/SomeCrpyticNumber 

but in Xcode 6, the simulator directory is completely different:

~/Library/Developer/CoreSimulator/Devices/CrypticNumber1/data/Containers/Bundle/CrypticNumber2/MyApp.app 

and

~/Library/Developer/CoreSimulator/Devices/CrypticNumber1/data/Containers/Data/CrypticNumber3/Documents 

where CryptNumber 1,2, and 3 are all different. Is there a way where I can get the corresponding Documents folder after I find the folder that contains the .app file? I"m having trouble with this.

why...?

If I built the app on an iOS 7 simulator, the documents directory and .app file are in the same folder atleast like before, but iOS 8 separates them.

The only solution I can think of right now is to pair up 2 folders that have the latest creation/modification dates.

Edit:

on a side note, this tool is very useful for finding your simulator folders on xcode 6 now: http://simpholders.com/

1
  • try this Commented Nov 28, 2014 at 11:51

3 Answers 3

10

This has been bugging me as well. I've not been able to solve it 100% but I created a quick and dirty app to help a bit. I can always find the device directory, but I've not yet found a way to track down the bundle / sandbox directories reliably. Source: https://github.com/somegeekintn/SimDirs

Edit: Went ahead and started scanning mobile_installation.log to find additional locations. Seems to find everything now.

Sign up to request clarification or add additional context in comments.

3 Comments

That looks great. I'm also doing something similar to what you have except I don't have a GUI :) Right now, I'll just use simulator_app="$(find "~/Library/Developer/CoreSimulator/Devices" -name "$project_name.app")" full_path_to_app="$( dirname "$simulator_app" )" to find the directory for the app, but I would assume we would want to match the creation date of this folder with another folder to find the bundle directory.
You may also want to root around in data/Library/Logs/MobileInstallation/mobile_installation.log.0. It appears to records app install and uninstall information. Has to be a more permanent record of this somewhere you'd think.
I'm using a script that matches the bundle ID with the one in .com.apple.mobile_container_manager.metadata.plist - seems to be reliable enough.
1

I faced the same issue when I stored the full path using CoreData. When retrieving the full path, it return null because the document folder UUID is different every time the app restarts. Following is my resolution:

  1. Make sure storing only the relative path of the document / file in CoreData. E.g. store "Files/image.jpg" instead of "/Users/yourname/.../Applications/UUID/Document/Files/image.jpg".
  2. Use the following to retrieve the app document location:

    [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

  3. Concatenate both #2 and #1 to get the full path of the document / file you want to retrieve.
You can refer to Apple Developer Note: https://developer.apple.com/library/ios/technotes/tn2406/_index.html

Comments

1

There is a great plugin for Xcode, that allows you to open the directory for any app you want. It's called ZLGotoSandboxPlugin, and you can install it via Alcatraz. This plugin adds a special submenu to the Xcode's "File" menu (I've hidden several app names there): The plugin menu.

I find it rather convenient.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.