In Android, if you have root, you can access a folder /data/data/<package name>
In this folder you can find databases or other files for your project.
Is this folder available on iOS if you have Jailbreak?
I did find some root explorers for iOS but I was not able to find that folder.
Android and iOS are completely different operating systems, so you shouldn't expect them to have the same file system layout.
In iOS, typically, apps store their data in a folder named Documents, that is saved in a location next to where the app itself is installed (†).
For example, for 3rd-party (App Store) apps, the app is installed under /var/mobile/Applications/ (†) and then a folder that's named with a unique identifier string. Under that folder, you will find the app at MyAppName.app. On the same level, you'll see a Documents folder, that is automatically created for you. So, a complete folder hierarchy might look like this:
iPhone5:/var/mobile/Applications root# find . -name Netflix.app
./882F75CD-F42D-4532-8C77-D0992192606B/Netflix.app
iPhone5:/var/mobile/Applications root# cd ./882F75CD-F42D-4532-8C77-D0992192606B/
iPhone5:/var/mobile/Applications/882F75CD-F42D-4532-8C77-D0992192606B root# ls
Documents/ Library/ Netflix.app/ StoreKit/ iTunesArtwork iTunesMetadata.plist tmp/
It is important to note that you do not need a jailbroken phone to access this folder. You can install a tool like iBrowse on your computer, and use that to browse the Documents folder of your 3rd-party apps.
However, if you want to be able to browse any folder on the filesystem, you would have to jailbreak the phone, and then could use iBrowse, or just ssh, to get into wherever you like.
Another note is that if you are building a "system" application for a jailbroken device, that will be installed under /Applications/, instead of /var/mobile/Applications/ (†), then you actually do need to manually create a documents folder for your app. See this tutorial for more about that (see bottom of page), or read this answer.
Update (†)
In recent versions of iOS (8+, I believe), the 3rd-party data folders have moved. What was in /var/mobile/Applications/ is now under /var/mobile/Containers/Data/Application/. App bundles and their data/documents folders have been separated on the filesystem.
iOS apps store data locally in different ways like plist(similar to shared_pref in android), NSUserDefaults, Core data(sqlite), Keychain.
Theses files can be found using any file explorer utility under the application folder.
Is this folder available on iOS if you have Jailbreak?
yes. Actually:
if no jailbreak: you could still check it using some file browser tool, like iBrowse
if jailbreak: you can find the app folder more easily
using many tools
eg
ls after ssh
GUI file manage tool
Chinese 爱思助手
Filza
iFile
eg:
Chinese app 抖音 (package id: com.ss.iphone.ugc.Aweme)'s data folder
/private/var/mobile/Containers/Data/Application
6A9AE298-87E8-4C94-8F85-863CA0904022
screenshot
folder structure
Documents/
screenshot
folder structure
Aweme.db
AwemeIM.db
Library/
StoreKit/
SystemData/
tmp/
/private/var/containers/Bundle/Application/F4E9C01C-9B7F-492F-A024-5045F5C26D4C
screenshot
folder structure
Aweme.app
Aweme
BundleMetadata.plist
No, that folder doesn't exist by default under iOS unless you (or somebody else) created it.
Related
in an iOS app, is it possible to share a whole folder, potentially containing sub folders, with another app? On the receiving side, is there a way to import such folder structure?
Or is file handling restricted to flat lists of files & individual files?
In an app I am working on, I want to process structured folders containing files & subfolders, with the folder tree intact - a user should be able to open a folder in my app. Not sure if that's possible, couldn't find an answer, so I guess not.
clarification:
implementing support for the share sheet, it's trivial to enable an app to open specific file types using UTIs. the app will simply show up in the system Share Sheet if a user in another app shares a supported file, and you just handle URLs in the app delegate. This works for multiple files, but is it possible to do it with entire directory structures? Individual files are copied into the target app's container, should be doable with folders as well, hopefully.
I wanted to know, if its possible to change the dependency of some directories.
To be specific:
In the app there are several information/pictures stored in an own-created (from the app after installing) directory called "Library". I cant access this directory from an unjailbroken device. But there is a directory called "Documents" which can be accessed from iTunes.
I want to change the dependency or whatever, so that I can grap or put on files in the "Documents" folder and the app will take them as well from there.
I tried to unzip the file and I had a look into some files but none of them contained a path to those directories. The only file remained was (I guess) the executable compiled file, which I could not encrypt/open/change.
Sorry for bad description - Im not sure how to depict it better.
I'm just new to iOS and am really confused by how files are managed.
In my project, I have set up directories, so I have in xcode:
Supporting Files
. Set 1
..pic0101N.png
..pic0102N.png
. Set 2
..pic0201N.png
..pic0202N.png
etc..
Also in the file structure where my app is (on my Desktop in a folder named FTF), I have a directory named images and a subdirectories for Set 1, Set 2, etc
When I click on an image in Xcode, the full path is listed as: /Users/MyName/Desktop/FTF/FTF/images/Set 1/pic0101N.png
My question is, how do I get a list of all the images in the Set 1 folder?
I've tried the various ways of using:
[NSBundle mainBundle] but, it all boils down to that my path seems to be:
/Users/MyName/Library/Application Support/iPhone Simulator/6.1/Applications/Axxxx1E9-19B3-XXX-XXXX-xxX5xXxX4x9/FTF.app
And that there doesn't seem to be any of my file structure in here, like the files are in there but not in any directories, they all just seem to be a bunch of files in there.
NSArray *namesArray = [[NSBundle mainBundle] pathsForResourcesOfType:#"png" inDirectory:#""];
yields a list of all the PNGS as such:
/Users/MyName/Library/Application Support/iPhone Simulator/6.1/Applications/Axxx81E9-19B3-4B4D-9FD4-XXXXX4499/FTF.app/pic0101N.png
/Users/MyName/Library/Application Support/iPhone Simulator/6.1/Applications/AXX9-19B3-4B4D-9FD4-8x9xx4499/FTF.app/pic0101P.png
I think I must have a fundamental confusion of what is going on. Could someone please help me out?
That's because Xcode is being unhelpful (and/or it assumes that the developer is dumb or something) and whenever you create a group, it's only reflected in the project structure - no corresponding folders are physically created on the filesystem.
If you want to get yourself real folders, that's also possible - refer this question.
What you are looking at is the difference between the Xcode project structure, the MAC OS X file system structure, the iOS app file system structure and what files are actually copied to the app during build.
For a start, having files in a location on Mac OS X doesn't mean they will be in any kind of similar location in the project or the app.
The iOS app is a bundle of contents (link), some of which is not editable and is set by Xcode when building the app and some of which is able to be written to (like the app documents directory). The files that are copied to the app are controlled by the build phases settings in Xcode.
The way you are using NSBundle is the correct way to find and use resources that were copied to the app during the build.
How does one create a read/write folder on the same level as the Documents directory? Is there a way to set the directory used in file sharing on iOS between iTunes and an app, or is it hard coded to the Documents directory?
On a non-jailbroken device, you cannot create a read/write folder on the same level as the Documents directory. Additionally, there is not way to change the directory used in file sharing.
If you need to create files and want to keep them away from file sharing, there are other writable directories that can be used. This SO question & answer deals with that quite well.
I need to know how to copy resources (help files, images, pLists) to the iOS simulator and ultimately device. I recall this was done through Xcode but what is the exact procedure?
Just drag the file to your simulator
For iOS 6, the directory seems to be a bit different. I'm seeing:
~/Library/Application Support/iPhone Simulator/6.0/Applications/your app here/Documents, where 'your app here' is a long string. Fortunately, if you click on each directory, you'll see the name of the app you're building in the child directory. From there, it's straightforward to find the Documents folder.
You can drag your file to simulator or you can right click to file then send->Simulator.
Both work for me.
Just drag your file to the project. It will be copied to your app bundle when the app is installed (on the simulator).
Alternatively, put the file into ~/Library/Application Support/iPhone Simulator/User/Applications/... (if you have the 3.2 SDK.)
From the XCode docs.
A Copy Files build phase allows you to copy files and resources of any type to specific locations as part of the build process. It complements the build phases that copy specific types of files. An example is the Copy Headers build phase, which deals only with header files. You can have as many Copy Files build phases as you need in a target.
For example, using a Copy Files build phase, you can copy fonts to/Library/Fonts. Or, if you’re developing a plug-in, a Copy Files build phase can copy the generated plug-in to the appropriate location. You can have as many Copy Files build phases in a target as you need.
To create a Copy Files build phase:
In the project window, open the target to which you want to add the build phase, and select the build phase after which to add the new build phase.
Choose Project > New Build Phase > New Copy Files Build Phase. Xcode adds the new Copy Files build phase after the build phase selected in the Groups & Files list.
Drag the files you want to copy from the Groups & Files list to the Copy Files build phase.
To configure the new Copy Files build phase, select it and open the Copy Files build phase editor, shown in Figure 2-5.
Just copy files to iCloud Drive. Then open the files app on the simulator and sign into your iCloud account.
Get the folder in the Mac Finder and make an Alias
Yes getting the Path by Xcode, but using the Mac Finder and an Alias to get there, doing the file copy operations, is very smooth and solid.
I get my files into my Simulator units by:
Getting the path by putting a breakpoint in Xcode at (anywhere you like in the app code):
let FilePathName: String = NSTemporaryDirectory()
Using the Mac Finder going to, the simulator unit disk and application location (yes, it is in the Mac). There you find all the local folders of the simulator unit.
The path to the the Device unit and to the Application is like a crypto string and not that easy to separate from many other such in the folders alike, but quickly made.
Finding the folder of your choice, make an Alias, move the alias to the Mac Desktop.
Then you have a smooth way to the simulator units app storage
But an Alias must be made for each simulator unit and app.
The advantage is that you are dealing with the regular tool of Mac Finder folder/Alias and it is quite capable of handling large volumes of files, very smoothly.
You put the files exactly where you want them.
The Alias works like regular Alias works in a Mac.
By some upgrades of Xcode the simulator units are rest and the data has to be re-copied into the units.
The other suggestions are not that bad
Just copy files to iCloud Drive, works very smooth, is a good alternative.
But need to login,
But then the files need to be copied from the iCloud Drive to the simulator units storage, unless you want to use data in the iCloud? (The topic of the question was How can I copy a file to the iOS simulator using Xcode?)
Drag'n drop to the Simulator unit, should be the obviously most smooth way of doing it.
But I find it slow and not really reliable, I found it hanging copying volumes of files
I find also my suggested way giving much better control over the file storage, the desktop Mac is by far more easier to handle data than a phone or tablet?