Where on my machine is the iPhone simulator installed?
I'm been trying to find where a test application I run in the simulator is stor开发者_运维技巧ed.
Simulator: ~/Library/Application Support/iPhone Simulator/
You can browse simulator files from that directory in Mac OS X.
Update for Xcode 4.4: While the iPhone simulator is still in the same place, Apple has included a shortcut to the iPhone Simulator at:
/Applications/Xcode.app/Contents/Applications
Changes since Xcode 4.3.1
Please note that the new version of Xcode is now available on the Mac App Store. Hence all the stuff that used to come with an installer is now packaged into Xcode.app
.
Therefore the iOS Simulator binary is located here:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/
The Apps installed in the simulator along with other configuration files are still here:
~/Library/Application Support/iPhone Simulator/
Here is an extract from the current release notes of Xcode 4.3.1
What's new in Xcode 4.3.1
Xcode is now distributed as an application, rather than as an installer. This change enables Xcode to be updated directly from the Mac App Store.
As of Xcode 6 and iOS 8 you’ll find it here:
~/Library/Developer/CoreSimulator/Devices/{cryptic number}/data/Containers/Data/Application/{cryptic number}/
or you can get it from below code execution:
NSLog(@"Documents Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
Xcode 6 -> /Users/{YOUR NAME}/Library/Developer/CoreSimulator/Devices/{DEVICE ID}/data/Containers/Data/Application/{APPLICATION ID}/
Or print it out in Xcode console
#if TARGET_IPHONE_SIMULATOR
NSLog(@"Documents Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
#endif
The actual Simulator application itself is located at /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator
To find the most recent install of your application in the simulator, you can use this command:
find "/Users/$USER/Library/Application Support/iPhone Simulator" -type d -name 'YourAppName.app' -print0 | xargs -0 ls -td | head -1
Don't forget to replace YourAppName with the name of your app!
In Xcode 6, iOS Simulator.app is located in this location:
/Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app
With the introduction of CoreSimulator in Xcode 6, each simulated device now has its own data. Previous versions had all devices share the same data for each version of iOS.
Devices are located in ~/Library/Developer/CoreSimulator/Devices. Logs are located in ~/Library/Logs/CoreSimulator
Note that ~/Library/Developer/CoreSimulator/Devices//data/Library/Logs is a symlink to ~/Library/Logs/CoreSimulator/.
CoreSimualtor will create an initial set of devices on first use (and after installation of older simulator runtimes). You can add or delete new devices from within Xcode.app or from the command line using 'xcrun simctl create' or 'xcrun simctl delete'
As of 4.3.2 of Xcode for Lion, the iOS simulator is located in the contents of the app package... If you right click on xcode.app and click "Show package contents" then navigate to Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications there you will find the iOS Simulator app... Just drag it to your dock and there you go... Or you can make an Alias and drag that to your desktop (or wherever you want) for easy access to the simulator... Why Apple decided to bury it in the package, I have no clue.
In X-Code 4.2
The Photos of the iPhone simulator are stored in
/Users/user_name/Library/Application Support/iPhone Simulator/5.0/Media/DCIM/100APPLE
On El Capitan and Xcode 7.2 and 7.3 I found the Simulators here:
/Applications/Xcode.app/Contents/Developer/Applications/
- Simulator
- Simulator (Watch)
From xCode 8.0 the simulator .app is located in
/Applications/Xcode.app/Contents/Developer/Applications
For xcode 7, you'll find it at here
/Users/{USERNAME}/Library/Developer/CoreSimulator/Devices/{CRIPTIC NUMBER}/data/Containers/Data/Application/{CRIPTIC NUMBER}/Documents/
or execute the code below in your xcode project
Objective C
NSLog(@"Documents Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
Swift
print(applicationDocumentsDirectory.path)
The top answer is correct for location of the simulator app. But there is a secondary location where the example apps (and your app builds) are stored for the simulator to access. This is:
~/Library/Developer/CoreSimulator/Devices
Each subdir is a device ID. You can find where your app is by looking in each of these dirs at data/Containers/Bundle/Application/{app_id}
I found the easiest way to find it programmatically. Run the app and put NSLog() for [NSBundle MainBundle], it will show you the whole path of the app running in simulator.
A super simple and sexy way is to use Apple Script:
property findtype : quoted form of "kMDItemContentType = \"com.apple.application-bundle\""
set simulatorFolder to POSIX path of (path to application support folder from user domain) & "iPhone Simulator/"
set appFiles to paragraphs of (do shell script "mdfind -onlyin " & quoted form of simulatorFolder & " " & findtype)
if appFiles is not {} then
set mostRecentApp to item 1 of appFiles
tell application "Finder" to reveal ((POSIX file mostRecentApp) as alias)
tell application "Finder" to activate
end if
Paste this into Apple Script Editor and export it as a Mac app. Then you can just run the app whenever you need a Finder window open in the sandbox. The code is courtesy StefanK at MacScripter.
It took me a while, but I just found mine at /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app
All of these paths keep getting outdated with each Xcode release
精彩评论