Reputation: 11
I have implemented core api of dropbox successfully in my app, however I need the functionality of datastore api and thats where the problem arrives. I have added the dropbox framework for datastore api but when I use dbaccountmanager and dbaccount, i am getting linker command error. It says there are duplicate symbols _kdbdropboxapihost,_kdbdropboxapiversion etc. The problem is I get this error only when I add methods of datastore api and dbaccount etc. Can someone help me to get rid of this error?
error:
duplicate symbol _kDBDropboxAPIVersion in:
/Users/.../Desktop/.../DropboxSDK.framework/DropboxSDK
/Users/.../Desktop/.../Dropbox.framework/Dropbox(DBConstants.o)
duplicate symbol _kDBDropboxAPIHost in:
/Users/.../Desktop/.../DropboxSDK.framework/DropboxSDK
/Users/.../Desktop/.../Dropbox.framework/Dropbox(DBConstants.o)
duplicate symbol _kDBDropboxAPIContentHost in:
/Users/.../Desktop.../DropboxSDK.framework/DropboxSDK
/Users/.../Desktop/.../Dropbox.framework/Dropbox(DBConstants.o)
duplicate symbol _kDBDropboxWebHost in:
/Users/.../Desktop/.../DropboxSDK.framework/DropboxSDK
/Users/.../Desktop/.../Dropbox.framework/Dropbox(DBConstants.o)
duplicate symbol _kDBSDKVersion in:
/Users/.../Desktop/.../DropboxSDK.framework/DropboxSDK
/Users/.../Desktop/.../Dropbox(DBConstants.o)
ld: 5 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Upvotes: 1
Views: 255
Reputation: 71
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:
All the modifications are done in the Dropbox Core SDK, once you have its source code available.
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];
Upvotes: 3