Why is a new project with the same app ID still designated a new location? - ios

We have created a new project with the same app ID, but this is designated a different folder in isolated storage. Why is this?
file:///Users/houman/Library/Developer/CoreSimulator/Devices/FBFFFF1E-B5C8-4541-AB4B-ED1657D43EB9/data/Containers/Data/Application/EB3A549F-1604-4E5C-8FBE-3076A3D581E5/Documents/
file:///Users/houman/Library/Developer/CoreSimulator/Devices/FBFFFF1E-B5C8-4541-AB4B-ED1657D43EB9/data/Containers/Data/Application/22E1E792-1F4F-4F05-B7D9-F61AD3624EE9/Documents/
Even though the apps share the same ID.
Since they don’t share the same location, no core data migration can take place.
Any advice please?
Update:
We have two apps in the AppStore and would like to combine the functionality. Hence the idea is to use the appID of the other app to push a new release from a separate project. We have the appID and right certificates, but the isolated storage seems to depend on something else than just appid. Without that a migration of existing data to the new system won't be possible. Alternatively we could copy and paste all files into the other project and go through lots of pain. That might make it possible.

I have seen this on my end - I believe (and could be wrong) that each simulator you run in gets its own folder on the disk. If you switch for iPhone 5 to iPhone 6s for example you may end up with a different folder.
I always actually (when running in the simulator) print out the on-disk location so that I can take a look at the sqlite file if i need to and recently (as of xcode7) i've noticed this directory change between runs - however in my case i tracked it down to changing simulator versions.

Mainly for security reasons. Every iOS application is placed in an application sandbox.
This not only refer to an application's sandbox directory in the file system, granting security by limiting the access to user data stored on the device, system services, and hardware.

Related

Application UUID changes with app update in iOS

I am storing path of downloaded file in sqlite db and when I update the app, its UUID changes but data doesn't get moved to new container. So the path is essentially invalid now. I checked if files still exist using iExplorer and they do.
platform.Is("iOS"){
this.localdirectory = this.file.dataDirectory+filename;
}
else
{
this.localdirectory = this.file.externalDataDirectory+filename;
}
A better approach to store UUIDs that need to be persistent between App installs would be to use the Keychain.
The keychain will not only persist between updates - but also between app installations. In fact - you can even remove the app altogether and it's still there.
Only completely setting up the device from scratch will actually give you a new value.
There is a gotcha (depending on how you build you Keychain domain) that different Provisioning profiles might get a new keychain (but old one still remains).
I do suggest using an open source to manage the keychain itself btw. It's really ... how should I put it ... different than a lot of modern code and conventions.
Also note - you can even use iCloud keychain in case you want to share across devices , and Appgroups to share among apps on the same phone.

iOS, config files and sandboxing

My understanding is that because of sandboxing, it isn't possible to view any text file (ie config file) associated with an iOS app using another app. Something quite simple with Android. Am I mistaken?
I am trying to implement a text config file with a Unity iOS app that gets loaded and parsed once when the application boots.
This config file would also be able to be edited and saved manually on that actual iOS device.
(addendum)
In Unity there is PersistentDataPath which resolves to /var/mobile/Container/Data/Application/foo/Documents
Is there an iOS supported file explorer app that will allow me view and edit files in this location (without jailbreaking)?
Use can check iOS App Groups. It allows multiple apps access to shared containers and allow interprocess communication. There is no so much documentation about this, but maybe that's what you're looking for. At least you can share NSUserDefaults between the apps.
NSUserDefaults it's a most simple way to save any (not big) configurations for your app. For manual editing: if your app on the device signed with developer certificate, you can connect through any iOS supported file explorer app and edit it. But after release, from App Store, your app installed in restricted/private path, so it's not possible, if only you don't have a jailbreak.
Initial configuration you can put into your app bundle, and at the first run just copy them to NSUserDefaults.
Short answer: There are utilities such as iExplorer - https://macroplant.com - that allow "file manager" type access. However...
Long answer: If your app requires users to buy (or get) other software to modify configuration files, the chances of Apple approving it are slim to none.
The appropriate thing to do is to provide a User Interface in your own app which allows the user to modify / update the settings.

iOS File Retrieval - NSDocumentDirectory

I am working on a library with a very verbose logger module that, on iOS, writes xml logs to NSDocumentDirectory in a consistent file tree. I want to come up with a way for the user of this library to easily access these logs.
I know it is simple to programatically retrieve files from this directory, but is it possible to access this directory on an iOS physical device in any way from outside Xcode to retrieve these logs? I feel like I have seen it somewhere before, something in the manner of extracting the .ipa file and going into the package contents, but I could be wrong.
---------------------------------------------------------EDIT------------------------------------------------------------------
This (Browse the files created on a device by the IOS application I'm developing, on workstation?) is how to do it with Xcode on a device, but I have to assume that there is some way we can create that gets the logs off of a device for a user.
is it possible to access this directory on an iOS physical device in any way from outside Xcode to retrieve these logs?
It is possible to expose the Documents directory by enabling iTunes file sharing. When file sharing is enabled through this method, the contents of Documents directory would be visible to the user in iTunes, which can also be exported. The documents would also be visible for export through some third party desktop apps like iExplorer.
Here is the link to Apple documentation. You may also refer this thread to understand how this is done.
If you're using a simulator (apparently your task doesn't seem to need te real device) you are in luck.
You should go to a folder similar to this one:
/Users/[YOUR_USER_NAME]/Library/Developer/CoreSimulator/Devices/[RANDOM_HASH_YOU_SHOULD_DISCOVER]/data/Containers/Data/Application/[RANDOM_HASH_2_YOU_SHOULD_ALSO_DISCOVER]
Once there, with finder, you'll get the "documents" folder of the simulator and the app you're trying to retrieve your logs from.
You might say: I don't know which 2 RANDOM_HASHES should I go to.
Yes, you're right. If you have MANY simulators installed and or being used, it might be tricky to discover which one is the one you're trying to debug.
The same thing with your APP, your app will live in another RANDOM_HASH folder, and you should browse them, one by one, and then discover your documents folder.
Someone needed to solve this "mess" and created a Xcode Alcatraz Extension that leads you to the exact live simulator and APP you're debugging in any given moment, and then you don't need to guess which 2 random_hash paths you need to navigate to.
If Xcode + Alcartaz plugin extension manager is somewhat out of your reach, you might need to google it. It's not a difficult process.
PS: That magical Alcatraz Extension is named "XCodeWay" (in case you are brave enough to install Alcatraz onto your copy of XCode).
EDIT: Useful link to get Alcatraz: http://alcatraz.io/ Follow its easy instructions and you're done.
EDIT2: If Xcode cannot be used, then the last question in this other thread might come in handy: Browse the files created on a device by the IOS application I'm developing, on workstation?
(Still, an external application in your users machine will be needed )

Is there a way to not erase the documents directory when uninstalling the app?

I'm developing an AIR app for iPad, and I found that when I uninstall the app, the documents directory data gets erased, is there a way to keep this data even when I delete the app or this behavior is regulated by iOS and there is nothing I can do about it?.
Thanks.
No you cant
From The iOS Environment
For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.
So you delete the application all the content regarding that particular app gets deleted.
as soon app get uninstalled the document directory folder also get deleted with that. Although you will not able to access that folder from other apps so there is no need to keep that.

IOS Enterprise Distribution update keep user data?

I'm making an iPad app which will be distributed from my own web server using Enterprise Distribution Program.
The app itself checks for a newer version on the server and calls itms-services in IOS to update itself. This works perfect.
The app bundle contains a directory with resources like images and movies.
Apple claims that updates will keep the users data if the bundle-identifier is the same.
From: http://help.apple.com/iosdeployment-apps/mac/1.1/#app43ad802c
If you want users to keep the app’s data stored on their device, make sure the new version uses the same bundle-identifier as the one it’s replacing, and tell users not to delete their old version before installing the new one. The new version will replace the old one and keep data stored on the device, if the bundle-identifiers match.
When running the app from Xcode directly to my connected iPad, I can remove the folder with my resources, run the app again, and the folder remains in the bundle on my iPad.
This behavior is what i look for. I'm planning on adding more folders with new resources with new updates. Since the resources are quite heavy, I don't want users to have to download bigger and bigger archives. I want to add just the new stuff.
The problem arises when I make a new archive without the folder and update the app from my web server as users would. Then the folder seems to be deleted.
Any experience with this?
The bundle that you install is always overwritten by the new bundle that you install. The user data referred to in the documentation is the data stored in the Documents and Library folders of the file system. If you wish to be sure that the old bundle files will always be available, you can copy them from the bundle to the Library/Caches folder of the application.
One thing worth mentioning is that the way to ensure that the ad hoc installation overwrites the current bundle is to make sure that you change the bundle version.
hope this helped :)

Resources