Dropbox SDK, проблема SwiftyDropbox. Не может скомпилировать без ошибок - PullRequest
0 голосов
/ 08 октября 2019

Я пытаюсь создать приложение, в котором я могу загрузить личный файл, хранящийся в Dropbox, изменить его через приложение, а затем повторно загрузить его. Я разрабатываю свое приложение только для личного использования, на моем Mac под управлением OS X Mojave 10.14.6, Xcode 11.0 и Swift 5. Я следую этому учебнику на github с небольшими изменениями, потому что яначинающий со Swift. Вот мой код FirstViewController.swift:

//  FirstViewController.swift

import UIKit
import SwiftyDropbox

class FirstViewController: UIViewController {
    var filenames: Array<String>?
    var client = DropboxClientsManager.authorizedClient

    @IBAction func tryPressed(_ sender: Any) {
        debugPrint("1")
        self.client.files.createFolder(path: "/test/path/in/Dropbox/account").response { response, error in
            if let response = response {
                print(response)
            } else if let error = error {
                print(error)
            }
        }
    }

    func LogIn (){
        //Ask user to login with his DB account
        DropboxClientsManager.authorizeFromController(UIApplication.shared,
        controller: self,
        openURL: { (url: URL) -> Void in
          UIApplication.shared.open(url)
        })
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        //Check if the app has permission to access to DB user account
        if (self.client == nil) {
            debugPrint("Not logged, ask permission.")
        self.LogIn ()
        } else {
            debugPrint("Already logged.")
        }
    }
}

Это AppDelegate.swift

//  AppDelegate.swift

import UIKit
import SwiftyDropbox

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        DropboxClientsManager.setupWithAppKey("npn5ui23bjpuq5z")
        // Override point for customization after application launch.
        return true
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
       if let authResult = DropboxClientsManager.handleRedirectURL(url) {
        switch authResult {
        case .success(let token):
          //  print("Success! User is logged into Dropbox with token: \(token)")
            print("Success! User is logged into Dropbox with token: *****")
        case .cancel:
            print("User canceld OAuth flow.")
        case .error(let error, let description):
            print("Error \(error): \(description)")
            }
        }
        return true
    }

    // MARK: UISceneSession Lifecycle
    @available(iOS 13.0, *)
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }
    @available(iOS 13.0, *)
    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }


}

Проблемы в основном две: 1. Как заставить пользователя не регистрироваться каждый раз при запуске приложения? 2. Я не могу понять, почему копирование из примера, показанного выше в этой строке, приводит к ошибке, как на другом скриншоте.

self.client.files.createFolder (path: "/ test / path / in / Dropbox/account").response {ответ, ошибка в

Я прикрепил как изображения: макет приложения, отладочный вывод и ошибка Xcode.

Заранее спасибо

App layout Xcode error Debug

...