cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Can't import Dropbox API into Swift

New member | Level 1
New member | Level 1

I followed the instructions at https://www.dropbox.com/developers/sync/sdks/ios to setup the SDK and https://blogs.dropbox.com/developers/2014/09/swift-apps-with-dropbox/ to import it into Swift with #import <Dropbox/Dropbox.h>. I get an unresolved identifier error for DBAccountManager in the AppDelegate, so it seems as if the framework isn't being imported. I made sure to add the other required frameworks. The Dropbox framework file is inside the project folder, and I created the URL scheme.

5 Replies 5
Highlighted

Re: Can't import Dropbox API into Swift

New member | Level 1
New member | Level 1

Hmmm. Not sure if it will help or not, but here's my AppDelegate code...

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.

    /***** code added to support DropBox integration *****/

    var accountManager = DBAccountManager(appKey: <myKey>, secret: <mySecret>)
    DBAccountManager.setSharedManager(accountManager)

    network.startNotifier()

    return true
}

/***** code added to support DropBox integration *****/

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {

    var account = DBAccountManager.sharedManager().handleOpenURL(url)

    if account != nil {
        return true
    }

    return false
}
Highlighted

Re: Can't import Dropbox API into Swift

New member | Level 1
New member | Level 1

That's essentially what I have in my AppDelegate, but Xcode can't find DBAccountManager.

Highlighted

Re: Can't import Dropbox API into Swift

New member | Level 1
New member | Level 1

The network.startNotifier() method in my code sample above, BTW, has nothing to do with Dropbox

Highlighted

Re: Can't import Dropbox API into Swift

New member | Level 1
New member | Level 1

Then that sounds like something in the Build settings. You've got #import <Dropbox/Dropbox.h> in the bridging header...I assume the naming of the bridging header follows Apple's convention. You might try to import another objC header in your bridging header and just make sure it is, in fact, bridging. And if you open up the Dropbox.framework file in your project, do you see a Headers folder with 19-20 .h files in it, including DBAccountManager? An in your Target, General settings you have Dropbox, QuartzCore, SystemConfiguration, CFNetwork, and Security? (Some of these might not be needed for Dropbox, but it's what I'm using.) There could also be a build setting you need to turn on, but I'm not sure which one.

Highlighted

Re: Can't import Dropbox API into Swift

New member | Level 1
New member | Level 1

I apparently had two bridging header files, so I just needed to delete the duplicate one. Thanks!

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?