Skip to content

Commit

Permalink
Version 7.4
Browse files Browse the repository at this point in the history
Fixed a bug that caused crashes when iCloud was not properly setup
(fixes #58). Fixes a bug where the initialization process was skipped,
please call setupiCloudDocumentSyncWithUbiquityContainer: when starting
iCloud Document Sync from now on.
  • Loading branch information
Sam Spencer committed Jan 17, 2015
1 parent aa91751 commit f9f83e7
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 113 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Expand Up @@ -3,7 +3,7 @@ It is also appreciated if you let the original developers know if you're using t

The MIT License (MIT)

Copyright (c) 2014 iRare Media
Copyright (c) 2015 iRare Media

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
17 changes: 10 additions & 7 deletions README.md
Expand Up @@ -40,9 +40,9 @@ Requires Xcode 5.0.1+ for use in any iOS Project. Requires a minimum of iOS 6.0

| Current Build Target | Earliest Supported Build Target | Earliest Compatible Build Target |
|:--------------------: |:-------------------------------: |:--------------------------------: |
| iOS 7.1 | iOS 7.0 | iOS 6.0 |
| Xcode 5.1.1 | Xcode 5.1.1 | Xcode 5.0.1 |
| LLVM 5.0 | LLVM 5.0 | LLVM 5.0 |
| 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.
Expand Down Expand Up @@ -87,11 +87,14 @@ If you do not already have a bridging header, install iCloud Document Sync into
After installing iCloud Document Sync, it only takes a few lines of code to get it up an running.
1. Import iCloud (see relevant install instructions above) to your header file(s).
2. Subscribe to the `<iCloudDelegate>` delegate.
3. Setup iCloud when your app starts:

3. 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
4. The first call to `iCloud` will trigger a file sync, therefore it is crucial that the first operation is a call to `setDelegate:`.
[[iCloud sharedCloud] setVerboseLogging:YES]; // We want detailed feedback about what's going on with iCloud, this is OFF by default
4. 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 `nil` to use the first Ubiquity Container ID in your entitlements.

[[iCloud sharedCloud] setupiCloudDocumentSyncWithUbiquityContainer:nil];
5. It is recommended that the first call to `iCloud` is `setDelegate`, 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](https://developer.apple.com/technologies/tools/whats-new.html) 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.).
Expand Down
24 changes: 16 additions & 8 deletions iCloud App - iOS/iCloud App.xcodeproj/project.pbxproj
Expand Up @@ -83,6 +83,7 @@
99FB117C1842A34900406254 /* ShareViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = "<group>"; };
99FB117F1842A6A100406254 /* TLTransitionAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TLTransitionAnimator.h; sourceTree = "<group>"; };
99FB11801842A6A100406254 /* TLTransitionAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TLTransitionAnimator.m; sourceTree = "<group>"; };
A6BACC6C1A6AEB6000EAABCF /* libiCloud.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libiCloud.a; path = "../../../../../Library/Developer/Xcode/DerivedData/iCloud-czvouwccqemjyoaohcvbhcgaovtb/Build/Products/Debug-iphoneos/libiCloud.a"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -144,6 +145,7 @@
99E85AFF182DC9280039FC97 /* Frameworks */ = {
isa = PBXGroup;
children = (
A6BACC6C1A6AEB6000EAABCF /* libiCloud.a */,
04EBBBFC184C9402009022D1 /* iCloud.framework */,
99E85B00182DC9280039FC97 /* Foundation.framework */,
99E85B02182DC9280039FC97 /* CoreGraphics.framework */,
Expand Down Expand Up @@ -463,8 +465,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_ENTITLEMENTS = "iCloud App/iCloud App.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_IDENTITY = "iOS Development: iRare Media (4N75L7CCKZ)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iOS Development: iRare Media (4N75L7CCKZ)";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"${GROUP_DIR}/",
Expand All @@ -473,9 +475,12 @@
GCC_PREFIX_HEADER = "iCloud App/iCloud App-Prefix.pch";
INFOPLIST_FILE = "iCloud App/iCloud App-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/iCloud-czvouwccqemjyoaohcvbhcgaovtb/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE = "c256d79e-a01e-4748-8d7f-cbb9cc4fc838";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
Expand All @@ -487,8 +492,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_ENTITLEMENTS = "iCloud App/iCloud App.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_IDENTITY = "iOS Development: iRare Media (4N75L7CCKZ)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iOS Development: iRare Media (4N75L7CCKZ)";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"${GROUP_DIR}/",
Expand All @@ -497,9 +502,12 @@
GCC_PREFIX_HEADER = "iCloud App/iCloud App-Prefix.pch";
INFOPLIST_FILE = "iCloud App/iCloud App-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = "$(inherited)";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/iCloud-czvouwccqemjyoaohcvbhcgaovtb/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE = "c256d79e-a01e-4748-8d7f-cbb9cc4fc838";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
Expand Down
2 changes: 1 addition & 1 deletion iCloud App - iOS/iCloud App/AppDelegate.h
Expand Up @@ -3,7 +3,7 @@
// iCloud App
//
// Created by iRare Media on 11/8/13.
// Copyright (c) 2014 iRare Media. All rights reserved.
// Copyright (c) 2015 iRare Media. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion iCloud App - iOS/iCloud App/AppDelegate.m
Expand Up @@ -3,7 +3,7 @@
// iCloud App
//
// Created by iRare Media on 11/8/13.
// Copyright (c) 2014 iRare Media. All rights reserved.
// Copyright (c) 2015 iRare Media. All rights reserved.
//

#import "AppDelegate.h"
Expand Down
14 changes: 11 additions & 3 deletions iCloud App - iOS/iCloud App/ListViewController.m
Expand Up @@ -33,9 +33,9 @@ - (void)viewDidLoad {
[super viewDidLoad];

// Setup iCloud
iCloud *cloud = [iCloud sharedCloud]; // This will help to begin the sync process and register for document updates
[cloud setDelegate:self]; // Set this if you plan to use the delegate
[cloud setVerboseLogging:YES]; // We want detailed feedback about what's going on with iCloud, this is OFF by default
[[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
[[iCloud sharedCloud] setupiCloudDocumentSyncWithUbiquityContainer:nil]; // You must call this setup method before performing any document operations

// Setup File List
if (fileNameList == nil) fileNameList = [NSMutableArray array];
Expand Down Expand Up @@ -73,6 +73,10 @@ - (void)didReceiveMemoryWarning {
// Dispose of any resources that can be recreated.
}

- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}

- (BOOL)appIsRunningForFirstTime {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) {
// App already launched
Expand All @@ -87,6 +91,10 @@ - (BOOL)appIsRunningForFirstTime {

#pragma mark - iCloud Methods

- (void)iCloudDidFinishInitializingWitUbiquityToken:(id)cloudToken withUbiquityContainer:(NSURL *)ubiquityContainer {
NSLog(@"Ubiquity container initialized. You may proceed to perform document operations.");
}

- (void)iCloudAvailabilityDidChangeToState:(BOOL)cloudIsAvailable withUbiquityToken:(id)ubiquityToken withUbiquityContainer:(NSURL *)ubiquityContainer {
if (!cloudIsAvailable) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"iCloud Unavailable" message:@"iCloud is no longer available. Make sure that you are signed into a valid iCloud account." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
Expand Down
4 changes: 2 additions & 2 deletions iCloud App - iOS/iCloud App/iCloud App-Info.plist
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.iRare-Media.${PRODUCT_NAME:rfc1034identifier}</string>
<string>com.iRare-Media.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down Expand Up @@ -48,6 +48,6 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<true/>
</dict>
</plist>
10 changes: 9 additions & 1 deletion iCloud App - iOS/iCloud App/iCloud App.entitlements
Expand Up @@ -2,9 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.$(CFBundleIdentifier)</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
</array>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>$(TeamIdentifierPrefix)com.iRare-Media.iCloud-App</string>
<string>iCloud.$(CFBundleIdentifier)</string>
</array>
</dict>
</plist>
Expand Up @@ -10,29 +10,29 @@
<string>iCloud</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>5B39CF46-AD9B-430A-B5E1-A191D1E620EB</key>
<key>11AB555C3762CCB6F74F596FCCF1E2E073ACA741</key>
<string>https://github.com/iRareMedia/iCloudDocumentSync.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>iCloud.xcodeproj/project.xcworkspace</string>
<string>iCloud.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>5B39CF46-AD9B-430A-B5E1-A191D1E620EB</key>
<key>11AB555C3762CCB6F74F596FCCF1E2E073ACA741</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/iRareMedia/iCloudDocumentSync.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>5B39CF46-AD9B-430A-B5E1-A191D1E620EB</string>
<string>11AB555C3762CCB6F74F596FCCF1E2E073ACA741</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>5B39CF46-AD9B-430A-B5E1-A191D1E620EB</string>
<string>11AB555C3762CCB6F74F596FCCF1E2E073ACA741</string>
<key>IDESourceControlWCCName</key>
<string>iCloudDocumentSync</string>
</dict>
Expand Down
15 changes: 13 additions & 2 deletions iCloud/iCloud.h
Expand Up @@ -2,7 +2,7 @@
// iCloud.h
// iCloud Document Sync
//
// Created by iRare Media. Last updated January 2014.
// Created by iRare Media. Last updated January 2015.
// Available on GitHub. Licensed under MIT with Attribution.
//

Expand Down Expand Up @@ -57,6 +57,15 @@ NS_CLASS_AVAILABLE_IOS(6_0) @interface iCloud : NSObject
@return The shared instance of iCloud */
+ (instancetype)sharedCloud;

/** Setup iCloud Document Sync and begin the initial document syncing process.
@discussion You \b must call this method before using iCloud Document Sync to avoid potential issues with syncing. This setup process ensures that all variables are initialized. A preliminary file sync will be performed when this method is called.
@param containerID The fully-qualified container identifier for an iCloud container directory. The string you specify must not contain wildcards and must be of the form <TEAMID>.<CONTAINER>, where <TEAMID> is your development team ID and <CONTAINER> is the bundle identifier of the container you want to access.
The container identifiers for your app must be declared in the com.apple.developer.ubiquity-container-identifiers array of the .entitlements property list file in your Xcode project.
If you specify nil for this parameter, this method uses the first container listed in the com.apple.developer.ubiquity-container-identifiers entitlement array. */
- (void)setupiCloudDocumentSyncWithUbiquityContainer:(NSString *)containerID;



/** @name Delegate */
Expand Down Expand Up @@ -113,7 +122,9 @@ NS_CLASS_AVAILABLE_IOS(6_0) @interface iCloud : NSObject

/** Retrieve the current application's ubiquitous documents directory URL
@return An NSURL with the iCloud ubiquitous documents directory URL for the current app. May return nil if iCloud is not properly setup or available. */
@warning If iCloud is not properly setup, this method will return the local (non-ubiquitous) documents directory. This may cause other document handling methods to return nil values. Ensure that iCloud is properly setup \b before calling any document handling methods.
@return An NSURL with the iCloud ubiquitous documents directory URL for the current app. Returns the local documents directory if iCloud is not properly setup or available. */
- (NSURL *)ubiquitousDocumentsDirectoryURL;


Expand Down

0 comments on commit f9f83e7

Please sign in to comment.