1
votes

My iOS application uses dropbox core api to access user's dropbox folder to save/retrieve files.

My app is core data based and I'd like to use Sync API to sync core data DB between different device (I don't trust core-data and iCloud with iOS version earlier than 7). I tried to add Sync API framework to my app but xcode returns lot of redefinition errors.

There is a way to use Core API and Sync API together?

Thanks, Max

3

3 Answers

2
votes

Ya it is possible in some cases. It is How you implement both Core and Sync together, as it requires lots of work.

I will suggest you to check HERE

I think you will find your answer here.

4
votes

Recently i had the need to integrate both Core and Datastore APIs. By doing questions in the dropbox forums, as well as checking some answers already given, i managed to successfully operate with both SDKs in the same project.

The following steps are the ones I did in order to achieve a successful result. I hope it solves your issue.

These steps are working for the following versions:

  • Dropbox Core iOS SDK v.1.3.11 (March 31, 2014)
  • Dropbox Datastore/Sync v.2.1.2 (April 16, 2014)

All the modifications are done in the Dropbox Core SDK, once you have its source code available.

Steps

1) Delete all files specific for OSX

DBAuthHelperOSX.m
DBKeychain-OSX.m
DBRestClient+OSX.m
DBAuthHelperOSX.h
DBRestClient+OSX.h
DropboxOSX.h
DropboxOSX-Info.plist
DropboxOSX-Prefix.pch
MPOAuthCredentiaIConcreteStore+KeychainAdditionsMac.m

2)Rename the files DBAccountInfo (.m and .h) to DBAccountInfoOld. Find all the occurrences of DBAccountInfo inside the SDK’s classes and replace with the new name.

3)Inside DBError.h, replace DBErrorCode with DBErrorCodeOld

4)Rename the files DBConnectController (.m and .h) to DBConnectControllerOld. Find all the occurrences of DBConnectController inside the SDK’s classes and replace with the new name.

5) Rename the classes DBKeychain and DBKeychain-iOS to DBKeychainOld and DBKeychainOld-iOS, respectively. Find all the occurrences of DBKeychain inside the SDK classes and replace them with DBKeychainOld.

6) Find all the occurrences of “redential" and replace them with “redentialOld”. Update the name of the classes too. Warning: replace only variables and class names containing that expression that belong to the Core SDK. Don’t replace, for example, in the following case: useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] . That is a method from the NSURL class and modifying that will break the code.

7) Import the source files to your project. All the imported source files from the Core SDK can’t run with ARC. This way, it must be disabled for those files. Select the project and go to build phases -> Compile Sources, select all the files regarding the Core SDK, double click on them and insert -fno-objc-arc.

8) If you compile the project you’ll find some duplicate symbols:

duplicate symbol _kDBDropboxAPIVersion in:
duplicate symbol _kDBDropboxAPIHost in:
duplicate symbol _kDBDropboxAPIContentHost in:
duplicate symbol _kDBDropboxWebHost in:
duplicate symbol _kDBSDKVersion in:
duplicate symbol _DBErrorDomain in:
duplicate symbol _DBStringFromLogLevel in:
duplicate symbol _DBLogFilePath in:
duplicate symbol _DBSetupLogToFile in:
duplicate symbol _DBLogSetLevel in:
duplicate symbol _DBLogSetCallback in:
duplicate symbol _DBLog in:
duplicate symbol _DBLogInfo in:
duplicate symbol _DBLogWarning in:
duplicate symbol _DBLogError in:
duplicate symbol _DBLogFatal in:

Append “Old” to the end of those variables’ name. Don’t forget to update the code so all the calls to those variables is made with their new name.

9) In order to manage to link your Dropbox account in both the SDKs, go to Core’s DBSession+iOS.m and inside the handleURL method and comment the following lines:

[[NSUserDefaults standardUserDefaults] removeObjectForKey:kDBLinkNonce];
[[NSUserDefaults standardUserDefaults] synchronize];

10) In application:openURL:sourceApplication:annotation: method of your App Delegate insert the following code:

[[DBSession sharedSession] handleOpenURL:url];//Core API
[[DBAccountManager sharedManager] handleOpenURL:url]; //Datastore API

IMPORTANT: this order must be followed! The handleOpenURL from Core API must be called before the Datastore’s one because the modifications done in 9)

11) In application:didFinishLaunchingWithOptions: insert the following code:

    //Datastore API
    DBAccountManager *mgr =
    [[DBAccountManager alloc] initWithAppKey:DROPBOX_APP_KEY secret:DROPBOX_APP_SECRET];
    [DBAccountManager setSharedManager:mgr];

    //CoreAPI
    DBSession *dbSession = [[DBSession alloc]initWithAppKey:DROPBOX_APP_KEY
                                                  appSecret:DROPBOX_APP_SECRET
                                                       root:kDBRootDropbox];
    [DBSession setSharedSession:dbSession];

12) In order to trigger the linking process use [[DBAccountManager sharedManager] linkFromController:self];

13) To unlink use the following lines

[[DBAccountManager sharedManager] linkedAccount] unlink];
[[DBSession sharedSession] unlinkAll];
0
votes

You might want to try just using the Sync API for files and the Datastore API for syncing data. They're bundled together in the same iOS library and work together well.