I am working on a project involving an iOS app communicating with another device by way of syncing data through Dropbox.
It works perfectly fine when I run the software on the iPhone Simulator (it syncs, uploads, downloads without issues), but when I load it onto my actual device, I get load/save errors.
The app on both the simulator and iPhone was successfully linked to my Dropbox account.
Some errors when I try do load requests:
2015-05-18 23:27:19.385 [2218:923269] [ERROR] DBRequest#connectionDidFinishLoading: error moving temp file to desired location: The operation couldn’t be completed. (Cocoa error 516.)
2015-05-18 23:27:19.387 [2218:923269] [WARNING] DropboxSDK: error making request to /1/files/dropbox/Projekt 2 (1)/Program/Units.txt - (516) Error Domain=NSCocoaErrorDomain Code=516 "The operation couldn’t be completed. (Cocoa error 516.)" UserInfo=0x174077700 {path=/Projekt 2 (1)/Program/Units.txt, destinationPath=/...}
Samples of the dropbox related code in my app:
In AppDelegate.swift:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let session = DBSession(appKey: "myAppKey", appSecret: "myAppSecret", root: kDBRootDropbox)
DBSession.setSharedSession(session)
...
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if DBSession.sharedSession().handleOpenURL(url) {
if DBSession.sharedSession().isLinked() {
// Linking was successfull.
}
return true
}
return false
}
In ViewControllerCausingErrors.swift:
class ViewControllerCausingErrors: DBRestClientDelegate {
var dbClient = DBRestClient()
override func viewDidLoad() {
super.viewDidLoad()
self.dbClient = DBRestClient(session: DBSession.sharedSession())
self.dbClient.delegate = self
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated: animated)
if !DBSession.sharedSession().isLinked() {
DBSession.sharedSession().linkFromController(self)
}
}
}
Chunk of code i use to download a file, elsewhere in the VC
if let localPath = NSBundle.mainBundle().pathForResource("Units", ofType: "txt") {
// Download file from Dropbox to local path.
let dropboxPath = Constants.Dropbox.Download.UnitFilePath
self.dbClient.loadFile(dropboxPath, intoPath: localPath)
}
Any help is greatly appreciated.