I want to build an iCloud based app that runs on both the Apple platforms, iOS and Mac. The app will use UIDocument on iOS and NSDocument on Mac to have a document based synchronization model - documents created on iOS will be available on Mac and vice versa.
The particular problem I'm facing is that I want the same iCloud container on both the apps. XCode creates a default container for the app based on the App ID, which has to be different on both the apps because this seems to be an Apple requirement - no two apps can have the same app id even if they are on different platforms.
So I left the default created container alone and added another container on both the Mac app as well as the iOS app. The app seems to work fine, I can create a new file package in both the apps in the correct place, but I'm having 2 issues:
The container does not appear properly in the iCloud settings management screen. In the entitlements section in XCode, I named the container as com.mycompany.myapp.mycontainer in both the apps. In the settings screen in iOS (Settings -> General -> Usage -> Manage Storage -> Show All) my app is listed as "mycontainer" instead of the App's actual name as I expected. Is it possible to supply a name and icon in the App's Info.plist to make it list properly?
My NSMetadataQuery is not working properly. I had made the iOS app with the Empty Application template, so the Info.plist was not properly setup with the CFBundleDocumentTypes key but I figured that out and fixed it. For firing my NSMetadataQuery in the iOS app, I'm using:
[self.queryCloud setPredicate:[NSPredicate predicateWithFormat:#"%K like '*.myextension*'",NSMetadataItemFSNameKey]];
with the search scope set like this:
[self.queryCloud setSearchScopes:[NSArray arrayWithObjects:NSMetadataQueryUbiquitousDocumentsScope, NSMetadataQueryUbiquitousDataScope, nil]];
I run the query after establishing the container's URL, I get the started and finished gathering notifications, but never the update notification from the NSMetadataQuery. Unless I go ahead and create a new document. If I create the document then I get notifications for Update, but only in that session. Next time I start up the app, the same settings don't give me any update notifications from NSMetadataQuery.
What am I doing wrong? Any pointers to articles on creating an iCloud document app targeting both Mac and iOS would be much appreciated! Suggestions, thoughts are most welcome.
I don't know about your NSMetadataQuery issues, but adding a shared iCloud container is easy, as long as you get the gotcha:
Pick one app ID that will be your shared cloud container. Doesn't matter if iOS or Mac OS X, you need to publish this app and it must be approved from the Apple Review Team* before your iCloud container will be available to any other app. e.g.
com.company.myawesomeapp
Note that you must not use a container name after your app ID (com.company.myawesomeapp.cloudcontainer), just use your appID!
Pick a second app ID (doesn't really matter), and create your second app. Open up Xcode and enable iCloud in the Capabilites Pane. Then under "iCloud Container Identifiers", add the identifier of your first (published and approved!) app
com.company.myawesomeapp
That's it!
There's just this one catch and that's the bottom line:
In order to use a container, an app must be available and approved. Before approval no other app may access your container, because technically it only exists as soon as your app is approved. Actually, it doesn't have to be available in the AppStore, it just needs to be approved (can be on developer held release).
You can only use a (shared) iCloud container if your app is published and has been approved.
Related
Can I access other .ipa files present on my iphone via my app and pass it to the backend server.
Will I be able to do that after jailbreak? If not on a non-jailbroken device.
The short answer is NO.
Other than that you can register the app as an app that works with different file types and the user can open them manually. Take a look of different App Extensions types Document Provider and Share.
You can't get exact IPA file.
You can get it's container from XCode if it is your app, In container you will found document directory of app where you might have saved data to get this
Goto xcode -> Device And Simulator -> Select your Device -> choose Application
Press Setting button on bottom and press download container
I am trying to build an app that will allow users to see all pdf files that are on the device (in some kind of a list with a preview) [Regardless of which app it belongs to on the device, all should be shown]. Is there anyway to achieve this?
Sorry but this is not possible on an iOS device because of a feature called sandboxing. Apple does not allow an app to access the sandbox of another app. Each app sits inside a sandbox of its own. This is iOS's security feature. There is no way to go around this feature.
Reference - About App Sandbox
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.
has anybody managed to get iCloud working on tvOS so far?
I am using key-value-storage and it successfully saves everything in iCloud. However, it does not synchronize the data between the iOS-App and the tvOS-App. I am using the same bundle-identifier for both apps.
Has anyone experienced the same issue?
So, it appears that Apple may have an issue here on the tvOS side, because if I follow Apple's instructions on Configuring Common Key-Value Storage for Multiple Apps I can share between and iOS App and a macOS App, but not the tvOS app using exactly the same setup.
Below are my results:
Apple's Instuctions that I used 1st:
So, CloudKit is all about the default Container rather than the App bundle ID directly. So, I setup my Primary iOS app with default container that will become the key-value share container.
Here is my Primary Entitlements file:
I then stored two NSUbiquitousKeyValueStore pairs in the default store and retrieved the values:
NSUbiquitousKeyValueStore.defaultStore().dictionaryRepresentation
So, in my macOS app I enable CloudKit as well, and remove the default container and set it to the Primary iOS apps container. Then in the Entitlements file I manually setup the com.apple.developer.ubiquity-kvstore-identifier to include the Primary App's bundle ID:
Uncheck default container and toggle Primaries:
Here is my Secondary macOS Entitlements file:
Then I run the macOS app and presto, I have the key-value pairs from the primaries default key-value store and retrieved the values easy-peasy:
NSUbiquitousKeyValueStore.defaultStore().dictionaryRepresentation
If I then make the SAME EXACT MODIFICATIONS to my tvOS app, the defaultStore() show as empty and I cannot get it to share with the iOS and macOS app.
Here is my Secondary tsOS Entitlements file:
And no presto, no values:
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.