Xcode Device Simulator Files - ios

I have been clearing some space from my drive and noticed that there are 183 folders inside my Developer>CoreSimulator>Devices folder. Are all of these required or are some of these simulators for older versions of iOS. When I look inside some of the folders they contain a file called device.plist that says the Sim Runtime is iOS-8-4. Is there any way to remove these old files?
Thanks

~/Library/Developer/CoreSimulator
Core Simulator folder is familiar for many Xcode users. It’s simulator’s territory; thats where it stores app data. It’s obvious that you can toss the older version simulator folder/folders if you no longer support your apps for those versions. And, it’s safer to use ‘Reset content and Settings’ option from menu to delete all of your app data in a Simulator.
Tip:
Objective-C
[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
Swift
NSFileManager.defaultManager().URLsForDirectory(NSDocumentDirectory, inDomains: NSUserDomainMask).lastObject()
Will print the full path to the document directory folder.

Related

App creating files while iPhone is locked

I am struggling with this issue.
My app need to create, while in background, some file. It creates a temporary file (in the temporary folder), then creates a folder inside /Documents, with some files in it.
When my application is compiled in debug, it works. When I compile it in release, and only when passcode is activated, only the first set of files gets created. The second set sees only the creation of the folder inside Documents, but no file can be created, nor in temporary folder nor in Documents/newcreatedfolder.
This happens only when the application is compiled in release, and with the pass code on.
I guess it has to do with data protection and the impossibility to create new files while the phone is locked. Is there some entitlement that can give my application the possibility to create and write to new files while in background and locked?
Files are locked by standard iOS file protection policy, so after the phone is locked all files are encrypted. My solution was this, since I don't need security on those files:
[[NSFileManager defaultManager] setAttributes:#{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:[GlobalProvider tmpFolder] error:NULL];
[[NSFileManager defaultManager] setAttributes:#{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:[GlobalProvider documentsFolder] error:NULL];

missing some folders in iPhone simulator?

I am developing an iOS project. There, I am having to upload images to to PHP server. So I choose some images from gallery in simulator for check up. Selected image is stored inside simulator. But I couldn't find that folder. So image is going empty to server. How to find that folders?
That image stored path is below
User/Guest/Library/developer/core simulator/devices/1ABD8156-4A55-4189--BDCD-DA6F7CSB2229/data/containers/data/applications/1559E24-9738-447D-8888-EEC9E29D4D39/Documents/Photo.jpg
But here I can found until
User/Guest/Library/developer/core simulator/devices/1ABD8156-4A55-4189--BDCD-DA6F7CSB2229/data/containers/data/applications/
How can I solve this. Please help me.
Note: i am using xamarin studio for development.
This would get u the simulator directory.
[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

iCloud documents no longer in Mobile Documents folder?

I have an app that creates a file in the iCloud documents folder. It is working fine, in that the devices that the app is installed on can access and update the file successfully. In my code, a NSLog of the file path gives me:
///private/var/mobile/Library/Mobile%20Documents/iCloud~my-company-name~appname/Documents/document_name
As part of my testing, I need to be able to view this file from my mac. Previously, I was able to do this by looking in my library/Mobile documents folder at the respective app folder.
However, I can't see the app folder in there. Any ideas why this would now not be showing up or pointers to configuration settings I could check? (I'm on Xcode 6.1, mac is Yosemite and all devices are iOS8).
Finder now treats this as a 'special' folder, so actively prevents you browsing the structure. You can do this if you use Terminal instead.

Link to iOS Simulator file system from Xcode

I seem to remember a way to get to the iOS Simulator file system from within the Xcode 6.0 or iOS Simulator GUI, but I can not find this anywhere any more. Anyone know if such a link still exists in beta 5 or later?
BTW I know the simulated file system is now located in ~/Library/Developer/CoreSimulator/Devices/*/data/Containers/Data/Application/*/ (previously ~/Library/Application Support/iPhone Simulator/*/Applications/*/). I'm looking for a link directly from Xcode, e.g. on some Schemes page.
The location of the iOS 8 Simulator has changed from previous versions. Plus, every time you run the app from Xcode the location changes.
The easiest way to beta direct URL in Xcode is perhaps like this:
#if TARGET_IPHONE_SIMULATOR
// where are you?
NSLog(#"Documents Directory: %#", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
#endif
When you open a Finder window to that location and keep it open, it updates automatically to the new location when you run your app again.
Further reading: http://pinkstone.co.uk/where-is-the-documents-directory-for-the-ios-8-simulator/
As the previous answer explains the location changes all the time so it's not possible to have a link.
You can use the method above to print it to the console or save a small file upon start up that you can then search for.
Because I missed the convenience of the link I wrapped this into a small OS X app Simulator Data Finder and made it available. The website should be self explanatory how to use either for objective c or swift

IOS 5.1 Backup / Restore App file from Documents Directory to / from iCloud

I have created a database (IOS 5.1) with XCode 4.3.3 for the iPad and have set it up so that the user can backup and restore the database file (*.sqlite) to DropBox. Everything works fine...
Now I would like to do the same process but, set it up for iCloud. Looking for the following function:
Tap a button to backup the *.sqlite file from the Apps Document Directory up to iCloud at users preference.
Tap a button to copy the *.sqlite file down from iCloud to the Apps Document Directory.
I have been struggling trying to find the solution, any help will be greatly appreciated.
For moving any file to and from icloud you can use this code below.
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:your iCloudURL destinationURL:localDirectoryURL error:&errorsss];
only thing is if you are moving to icloud the code should be :
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:localDirectoryURL destinationURL:your_iCloudURL error:&errorsss];
and if you are getting it from iCloud to Apps Documents directory
[[[NSFileManager alloc]init] setUbiquitous:NO itemAtURL:your_iCloudURL destinationURL:localDirectoryURL error:&errorsss];

Resources