Skip to content

Commit

Permalink
Fixed Xcode project for Carthage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cobbe committed Sep 27, 2016
1 parent 37a8617 commit 41c81f7
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 95 deletions.
178 changes: 91 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Full documentation [here](http://dropbox.github.io/dropbox-sdk-obj-c/api-docs/la
* [Xcode 8 and iOS 10 bug](#xcode-8-and-ios-10-bug)
* [Get started](#get-started)
* [Register your application](#register-your-application)
* [Obtain an OAuth2 token](#obtain-an-oauth2-token)
* [Obtain an OAuth 2.0 token](#obtain-an-oauth-20-token)
* [SDK distribution](#sdk-distribution)
* [CocoaPods](#cocoapods)
* [Carthage](#carthage)
Expand Down Expand Up @@ -70,9 +70,9 @@ Full documentation [here](http://dropbox.github.io/dropbox-sdk-obj-c/api-docs/la

Before using this SDK, you should register your application in the [Dropbox App Console](https://dropbox.com/developers/apps). This creates a record of your app with Dropbox that will be associated with the API calls you make.

### Obtain an OAuth2 token
### Obtain an OAuth 2.0 token

All requests need to be made with an OAuth2 access token. An OAuth token represents an authenticated link between a Dropbox app and
All requests need to be made with an OAuth 2.0 access token. An OAuth token represents an authenticated link between a Dropbox app and
a Dropbox user account or team.

Once you've created an app, you can go to the App Console and manually generate an access token to authorize your app to access your own Dropbox account.
Expand Down Expand Up @@ -204,9 +204,9 @@ add the following code to your application's `.plist` file:
<string>dbapi-2</string>
</array>
```
This allows the Objective-C SDK to determine if the official Dropbox iOS app is installed on the current device. If it is installed, then the official Dropbox iOS app can be used to programmatically obtain an OAuth2 access token.
This allows the Objective-C SDK to determine if the official Dropbox iOS app is installed on the current device. If it is installed, then the official Dropbox iOS app can be used to programmatically obtain an OAuth 2.0 access token.

Additionally, your application needs to register to handle a unique Dropbox URL scheme for redirect following completion of the OAuth2 authorization flow. This URL scheme should have the format `db-<APP_KEY>`, where `<APP_KEY>` is your
Additionally, your application needs to register to handle a unique Dropbox URL scheme for redirect following completion of the OAuth 2.0 authorization flow. This URL scheme should have the format `db-<APP_KEY>`, where `<APP_KEY>` is your
Dropbox app's app key, which can be found in the [App Console](https://dropbox.com/developers/apps).

You should add the following code to your `.plist` file (but be sure to replace `<APP_KEY>` with your app's app key):
Expand Down Expand Up @@ -235,7 +235,7 @@ After you've made the above changes, your application's `.plist` file should loo

### Handling the authorization flow

There are three methods to programmatically retrieve an OAuth2 access token:
There are three methods to programmatically retrieve an OAuth 2.0 access token:

* **Direct auth** (iOS only): This launches the official Dropbox iOS app (if installed), authenticates via the official app, then redirects back into the SDK
* **In-app webview auth** (iOS, macOS): This opens a pre-built in-app webview for authenticating via the Dropbox authorization page. This is convenient because the user is never redirected outside of your app.
Expand Down Expand Up @@ -382,7 +382,7 @@ Now you're ready to begin making API requests!

## Try some API requests

Once you have obtained an OAuth2 token, you can try some API v2 calls using the Objective-C SDK.
Once you have obtained an OAuth 2.0 token, you can try some API v2 calls using the Objective-C SDK.

### Dropbox client instance

Expand Down Expand Up @@ -424,13 +424,14 @@ Note: Response handlers are required for all endpoints. Progress handlers, on th
#### RPC-style request
```objective-c
[[client.filesRoutes createFolder:@"/test/path"] response:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *routeError, DBError *error) {
if (result) {
NSLog(@"%@\n", result);
} else {
NSLog(@"%@\n%@\n", routeError, error);
}
}];
[[client.filesRoutes createFolder:@"/test/path"]
response:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *routeError, DBError *error) {
if (result) {
NSLog(@"%@\n", result);
} else {
NSLog(@"%@\n%@\n", routeError, error);
}
}];
```

---
Expand Down Expand Up @@ -512,27 +513,28 @@ If at run time you attempt to access a union instance field that is not associat

#### Route-specific errors
```objective-c
[[client.filesRoutes delete_:@"/test/path"] response:^(DBFILESMetadata *result, DBFILESDeleteError *routeError, DBError *error) {
if (result) {
NSLog(@"%@\n", result);
} else {
// Error is with the route specifically (status code 409)
if (routeError) {
if ([routeError isPathLookup]) {
// Can safely access this field
DBFILESLookupError *pathLookup = routeError.pathLookup;
NSLog(@"%@\n", pathLookup);
} else if ([routeError isPathWrite]) {
DBFILESWriteError *pathWrite = routeError.pathWrite;
NSLog(@"%@\n", pathWrite);

// This would cause a runtime error
// DBFILESLookupError *pathLookup = routeError.pathLookup;
[[client.filesRoutes delete_:@"/test/path"]
response:^(DBFILESMetadata *result, DBFILESDeleteError *routeError, DBError *error) {
if (result) {
NSLog(@"%@\n", result);
} else {
// Error is with the route specifically (status code 409)
if (routeError) {
if ([routeError isPathLookup]) {
// Can safely access this field
DBFILESLookupError *pathLookup = routeError.pathLookup;
NSLog(@"%@\n", pathLookup);
} else if ([routeError isPathWrite]) {
DBFILESWriteError *pathWrite = routeError.pathWrite;
NSLog(@"%@\n", pathWrite);

// This would cause a runtime error
// DBFILESLookupError *pathLookup = routeError.pathLookup;
}
}
NSLog(@"%@\n%@\n", routeError, error);
}
NSLog(@"%@\n%@\n", routeError, error);
}
}];
}];
```
---
Expand All @@ -545,37 +547,38 @@ The `DBError` type is a special union type which is similar to the standard API
As with accessing associated values in regular unions, the `as<TAG_STATE>` should only be called after the corresponding `is<TAG_STATE>` method returns true. See below:
```objective-c
[[client.filesRoutes delete_:@"/test/path"] response:^(DBFILESMetadata *result, DBFILESDeleteError *routeError, DBError *error) {
if (result) {
NSLog(@"%@\n", result);
} else {
if (routeError) {
// see handling above
}
// Error not specific to the route (status codes 500, 400, 401, 403, 404, 429)
else {
if ([error isInternalServerError]) {
DBRequestInternalServerError *internalServerError = [error asInternalServerError];
NSLog(@"%@\n", internalServerError);
} else if ([error isBadInputError]) {
DBRequestBadInputError *badInputError = [error asBadInputError];
NSLog(@"%@\n", badInputError);
} else if ([error isAuthError]) {
DBRequestAuthError *authError = [error asAuthError];
NSLog(@"%@\n", authError);
} else if ([error isRateLimitError]) {
DBRequestRateLimitError *rateLimitError = [error asRateLimitError];
NSLog(@"%@\n", rateLimitError);
} else if ([error isHttpError]) {
DBRequestHttpError *genericHttpError = [error asHttpError];
NSLog(@"%@\n", genericHttpError);
} else if ([error isClientError]) {
DBRequestClientError *genericLocalError = [error asClientError];
NSLog(@"%@\n", genericLocalError);
[[client.filesRoutes delete_:@"/test/path"]
response:^(DBFILESMetadata *result, DBFILESDeleteError *routeError, DBError *error) {
if (result) {
NSLog(@"%@\n", result);
} else {
if (routeError) {
// see handling above
}
// Error not specific to the route (status codes 500, 400, 401, 403, 404, 429)
else {
if ([error isInternalServerError]) {
DBRequestInternalServerError *internalServerError = [error asInternalServerError];
NSLog(@"%@\n", internalServerError);
} else if ([error isBadInputError]) {
DBRequestBadInputError *badInputError = [error asBadInputError];
NSLog(@"%@\n", badInputError);
} else if ([error isAuthError]) {
DBRequestAuthError *authError = [error asAuthError];
NSLog(@"%@\n", authError);
} else if ([error isRateLimitError]) {
DBRequestRateLimitError *rateLimitError = [error asRateLimitError];
NSLog(@"%@\n", rateLimitError);
} else if ([error isHttpError]) {
DBRequestHttpError *genericHttpError = [error asHttpError];
NSLog(@"%@\n", genericHttpError);
} else if ([error isClientError]) {
DBRequestClientError *genericLocalError = [error asClientError];
NSLog(@"%@\n", genericLocalError);
}
}
}
}
}];
}];
```

---
Expand All @@ -591,26 +594,27 @@ For example, the [/delete](https://www.dropbox.com/developers/documentation/http
To determine at runtime which subtype the `Metadata` type exists as, perform an `isKindOfClass` check for each possible class, and then cast the result accordingly. See below:

```objective-c
[[client.filesRoutes delete_:@"/test/path"] response:^(DBFILESMetadata *result, DBFILESDeleteError *routeError, DBError *error) {
if (result) {
if ([result isKindOfClass:[DBFILESFileMetadata class]]) {
DBFILESFileMetadata *fileMetadata = (DBFILESFileMetadata *)result;
NSLog(@"%@\n", fileMetadata);
} else if ([result isKindOfClass:[DBFILESFolderMetadata class]]) {
DBFILESFolderMetadata *folderMetadata = (DBFILESFolderMetadata *)result;
NSLog(@"%@\n", folderMetadata);
} else if ([result isKindOfClass:[DBFILESDeletedMetadata class]]) {
DBFILESDeletedMetadata *deletedMetadata = (DBFILESDeletedMetadata *)result;
NSLog(@"%@\n", deletedMetadata);
}
} else {
if (routeError) {
// see handling above
[[client.filesRoutes delete_:@"/test/path"]
response:^(DBFILESMetadata *result, DBFILESDeleteError *routeError, DBError *error) {
if (result) {
if ([result isKindOfClass:[DBFILESFileMetadata class]]) {
DBFILESFileMetadata *fileMetadata = (DBFILESFileMetadata *)result;
NSLog(@"%@\n", fileMetadata);
} else if ([result isKindOfClass:[DBFILESFolderMetadata class]]) {
DBFILESFolderMetadata *folderMetadata = (DBFILESFolderMetadata *)result;
NSLog(@"%@\n", folderMetadata);
} else if ([result isKindOfClass:[DBFILESDeletedMetadata class]]) {
DBFILESDeletedMetadata *deletedMetadata = (DBFILESDeletedMetadata *)result;
NSLog(@"%@\n", deletedMetadata);
}
} else {
// see handling above
if (routeError) {
// see handling above
} else {
// see handling above
}
}
}
}];
}];
```
This `Metadata` object is known as a **datatype with subtypes** in our API v2 documentation.
Expand Down Expand Up @@ -661,13 +665,13 @@ By default, response/progress handler code runs on the main thread. You can set
```objective-c
[[client.filesRoutes listFolder:@""]
response:[NSOperationQueue new] response:^(DBFILESListFolderResult *result, DBFILESListFolderError *routeError, DBError *error) {
if (result) {
NSLog(@"%@", [NSThread currentThread]); // Output: <NSThread: 0x600000261480>{number = 5, name = (null)}
NSLog(@"%@", [NSThread mainThread]); // Output: <NSThread: 0x618000062bc0>{number = 1, name = (null)}
NSLog(@"%@\n", result);
}
}];
response:[NSOperationQueue new] response:^(DBFILESListFolderResult *result, DBFILESListFolderError *routeError, DBError *error) {
if (result) {
NSLog(@"%@", [NSThread currentThread]); // Output: <NSThread: 0x600000261480>{number = 5, name = (null)}
NSLog(@"%@", [NSThread mainThread]); // Output: <NSThread: 0x618000062bc0>{number = 1, name = (null)}
NSLog(@"%@\n", result);
}
}];
```

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
F25D1B481D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */ = {isa = PBXBuildFile; fileRef = F25D1B471D95B68600B748CF /* ObjectiveDropboxOfficial.h */; };
F25D1B491D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */ = {isa = PBXBuildFile; fileRef = F25D1B471D95B68600B748CF /* ObjectiveDropboxOfficial.h */; };
F25D1B481D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */ = {isa = PBXBuildFile; fileRef = F25D1B471D95B68600B748CF /* ObjectiveDropboxOfficial.h */; settings = {ATTRIBUTES = (Public, ); }; };
F25D1B491D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */ = {isa = PBXBuildFile; fileRef = F25D1B471D95B68600B748CF /* ObjectiveDropboxOfficial.h */; settings = {ATTRIBUTES = (Public, ); }; };
F27DEB9A1D7FFBB9003B1CEE /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F27DEB991D7FFBB9003B1CEE /* AppKit.framework */; };
F27DEB9C1D7FFBBF003B1CEE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F27DEB9B1D7FFBBF003B1CEE /* Foundation.framework */; };
F29AFA7B1D7FF0220043800A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F29AFA7A1D7FF0220043800A /* Foundation.framework */; };
Expand Down Expand Up @@ -3921,7 +3921,6 @@
F2EBBCE01D921E7A004707E1 /* DBSHARINGFileMemberActionError.h in Headers */,
F2EBBD981D921E7A004707E1 /* DBSHARINGListFoldersContinueArg.h in Headers */,
F2EBC09C1D921E7C004707E1 /* DBTEAMTeamMemberStatus.h in Headers */,
F25D1B481D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */,
F2EBBB541D921E7A004707E1 /* DBFILESGetTemporaryLinkError.h in Headers */,
F2EBBD5C1D921E7A004707E1 /* DBSHARINGListFileMembersBatchResult.h in Headers */,
F2EBC13A1D921E7C004707E1 /* DBTasks.h in Headers */,
Expand Down Expand Up @@ -4150,6 +4149,7 @@
F2EBBFE81D921E7B004707E1 /* DBTEAMMembersDeactivateArg.h in Headers */,
F2EBBD681D921E7A004707E1 /* DBSHARINGListFileMembersCountResult.h in Headers */,
F2EBBDEC1D921E7A004707E1 /* DBSHARINGRelinquishFileMembershipError.h in Headers */,
F25D1B481D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */,
F2EBBC7C1D921E7A004707E1 /* DBPROPERTIESListPropertyTemplateIds.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -4362,7 +4362,6 @@
F2EBBCE11D921E7A004707E1 /* DBSHARINGFileMemberActionError.h in Headers */,
F2EBBD991D921E7A004707E1 /* DBSHARINGListFoldersContinueArg.h in Headers */,
F2EBC09D1D921E7C004707E1 /* DBTEAMTeamMemberStatus.h in Headers */,
F25D1B491D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */,
F2EBBB551D921E7A004707E1 /* DBFILESGetTemporaryLinkError.h in Headers */,
F2EBBD5D1D921E7A004707E1 /* DBSHARINGListFileMembersBatchResult.h in Headers */,
F2EBC13B1D921E7C004707E1 /* DBTasks.h in Headers */,
Expand Down Expand Up @@ -4591,6 +4590,7 @@
F2EBBFE91D921E7B004707E1 /* DBTEAMMembersDeactivateArg.h in Headers */,
F2EBBD691D921E7A004707E1 /* DBSHARINGListFileMembersCountResult.h in Headers */,
F2EBBDED1D921E7A004707E1 /* DBSHARINGRelinquishFileMembershipError.h in Headers */,
F25D1B491D95B68600B748CF /* ObjectiveDropboxOfficial.h in Headers */,
F2EBBC7D1D921E7A004707E1 /* DBPROPERTIESListPropertyTemplateIds.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#import "TargetConditionals.h"

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#import <Cocoa/Cocoa.h>
#endif

//! Project version number for ObjectiveDropboxOfficial.
Expand All @@ -23,7 +23,7 @@ FOUNDATION_EXPORT const unsigned char ObjectiveDropboxOfficialVersionString[];
// <ObjectiveDropboxOfficial/PublicHeader.h>

#if TARGET_OS_IPHONE
#import <ObjectiveDropboxOfficial/DropboxSDKImportsMobile.h>
#import <ObjectiveDropboxOfficial/DropboxSDKImportsMobile.h>
#else
#import <ObjectiveDropboxOfficial/DropboxSDKImportsDesktop.h>
#import <ObjectiveDropboxOfficial/DropboxSDKImportsDesktop.h>
#endif

0 comments on commit 41c81f7

Please sign in to comment.