ICloudDocumentSync
Integrate iCloud into iOS document projects with one-line code methods. Sync, upload, manage, and remove documents from iCloud quickly and easily. Helps to make iCloud "just work" for developers too.
Install / Use
/learn @nenosinc/ICloudDocumentSyncREADME
iCloud Document Sync makes it easy for developers to integrate the iCloud document storage APIs into iOS applications. This is how iCloud document-storage and management should've been out of the box from Apple. Integrate iCloud into iOS (OS X coming soon) Objective-C document projects with one-line code methods. Sync, upload, manage, and remove documents to and from iCloud with only a few lines of code (compared to the hundreds of lines and hours that it usually takes). Get iCloud up and running in your iOS app in only a few minutes.
If you like the project, please star it on GitHub! Watch the project on GitHub for updates. If you use iCloud Document Sync in your app, send an email to hello[at]nenos.one or let us know on Twitter @nenosapp.
Project Features
iCloud Document Sync is a great way to use iCloud document storage in your iOS app. Below are a few key project features and highlights.
- Sync, Upload, Read, Write, Share, Save, Remove, and Edit any iCloud document in only one line of code.
- Just drag and drop the iCloud Framework (
iCloud.framework) into your project and you can begin using iCloud - no complicated setup - Access in-depth documentation with docsets, code comments, and verbose logging
- Useful delegate methods and properties let you access and manage advanced iCloud features
- Manage any kind of file with iCloud through use of NSData
- iOS Sample-app to illustrate how easy it is to use iCloud Document Sync
- Frequent updates to the project based on user issues and requests
- Easily contribute to the project
Table of Contents
Project Information
Learn more about the project requirements, licensing, and contributions.
Requirements
Requires Xcode 5.0.1+ for use in any iOS Project. Requires a minimum of iOS 6.0 as the deployment target.
| Current Build Target | Earliest Supported Build Target | Earliest Compatible Build Target | |:--------------------: |:-------------------------------: |:--------------------------------: | | iOS 8.1 | iOS 7.0 | iOS 6.0 | | Xcode 6.1.1 | Xcode 5.1.1 | Xcode 5.0.1 | | LLVM 6.0 | LLVM 5.0 | LLVM 5.0 |
REQUIREMENTS NOTE
Supported means that the library has been tested with this version. Compatible means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.
License
This project is licensed under the MIT License. See the full iCloud Document Sync license here.
Attribution is not required, but it appreciated. We have spent a lot of time, energy, and resources working on this project - so a little Thanks! (or something to that affect) would be much appreciated. If you use iCloud Document Sync in your app, send an email to contact@iraremedia.com or let us know on Twitter @iRareMedia.
Contributions
Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub. Learn more about contributing to the project here.
Sample App
The iOS Sample App included with this project demonstrates how to use many of the features in iCloud Document Sync. You can refer to the sample app for an understanding of how to use and setup iCloud Document Sync. The app should work with iCloud as-is (you may need to provide your own Bundle ID though).
<img width=100% src="https://raw.github.com/iRareMedia/iCloudDocumentSync/master/iCloud%20App%20-%20iOS/AppBanner.png"/>Installation
Adding iCloud Document Sync to your project is easy. There are multiple ways to add iCloud Document Sync to your project. Choose the process below which best suits your needs. Follow the steps to get everything up and running in only a few minutes.
CocoaPods Setup
The easiest way to install iCloud Document Sync is to use CocoaPods. To do so, simply add the following line to your Podfile:
pod 'iCloudDocumentSync'
Framework Setup
The iCloud.framework can be retrieved in two different ways:
- Clone the project to your computer and build the Framework target. The
iCloud.frameworkfile will be copied to the project directory. Drag and drop the.frameworkfile into your project. - Download your preferred iCloud Document Sync Framework release from the Project Releases section. Frameworks are available as far back as version 7.0. Unzip then drag and drop the
.frameworkfile into your project.
Traditional Setup
Drag and drop the iCloud folder into your Xcode project. When you do so, check the "Copy items into destination group's folder" box. Delete the iCloud-Prefix.pch file.
Swift Project Setup
To use iCloud Document Sync in a Swift project, you must create a bridging header.
If you already have a bridging header, simply import iCloud.h (use the #import <iCloud/iCloud.h> syntax when importing the framework, otherwise use #import "iCloud.h").
If you do not already have a bridging header, install iCloud Document Sync into your project using any of the above processes. When adding the files to Xcode, you will be prompted to create a bridging header - create one. Then, import iCloud Document Sync (see paragraph above).
Setup
After installing iCloud Document Sync, it only takes a few lines of code to get it up an running.
-
Import iCloud (see relevant install instructions above) to your header file(s).
-
Subscribe to the
<iCloudDelegate>delegate. -
Set the delegate and optionally enable verbose logging:
[[iCloud sharedCloud] setDelegate:self]; // Set this if you plan to use the delegate [[iCloud sharedCloud] setVerboseLogging:YES]; // We want detailed feedback about what's going on with iCloud, this is OFF by default
-
Setup iCloud when your app starts. It is crucial that you call this method before doing any document handling operations. You can either pass a specific Ubiquity Container ID (see your entitlements file) or
nilto use the first Ubiquity Container ID in your entitlements.[[iCloud sharedCloud] setupiCloudDocumentSyncWithUbiquityContainer:nil];
-
It is recommended that the first call to
iCloudissetDelegate, this way all subsequent operations and method calls can interact with the delegate and provide appropriate information.
Documentation
Key methods, properties, types, and delegate methods available on the iCloud class are documented below. If you're using Xcode 5 with iCloud Document Sync, documentation is available directly within Xcode (just Option-Click any method for Quick Help). For more advanced documentation please install the docset included with this project. This will allow you to view iCloud Document Sync documentation inside of Xcode's Organizer Window. Additional documentation can also be found on the Wiki page (including how to register your app for iCloud, iCloud fundamentals, etc.).
Methods
There are many methods available on iCloud Document Sync. The most important / highlight methods are documented below. All other methods are documented in the docset and with in-code comments.
Checking for iCloud Availability
iCloud Document Sync checks for iCloud availability before performing any iCloud-related operations. Any iCloud Document Sync methods may return prematurely and without warning if iCloud is unavailable. Therefore, you should always check if iCloud is available before performing any iCloud operations.
BOOL cloudIsAvailable = [[iCloud sharedCloud] checkCloudAvailability];
if (cloudIsAvailable) {
//YES
}
This checks if iCloud is available by looking for the application's ubiquity token. It returns a boolean value; YES if iCloud is available, and NO if it is not. Check the log / documentation for details on why it may not be available. You can also check for the availability of the iCloud ubiquity container by calling the following method:
BOOL cloudContainerIsAvailable = [[iCloud sharedCloud] checkCloudUbiquityContainer];
The checkCloudAvailability method will call the iCloudAvailabilityDidChangeToState: withUbiquityToken: withUbiquityContainer: delegate method.
Syncing Documents
To get iCloud Document Sync to initialize for the first time, and continue to update when there are changes you'll need to initialize iCloud. By initializing iCloud, it will start syncing with iCloud for the first time and in the future.
[[iCloud sharedCloud] init];
You can manually fetch changes from iCloud too:
[[iCloud sharedCloud] updateFiles];
iCloud Document Sync will automatically detect ch
