在范围内找不到类型 'ParseCloud' - Back4App ios 实现

Cannot find type 'ParseCloud' in scope - Back4App ios implementation

我正在使用 Swift、Xcode 和 back4app(Parse) 开发一个 ios 应用程序。我正在尝试编写一个连接到后端函数的应用程序启动函数,但收到此错误。任何帮助都会很棒!提前谢谢你。

struct CloudUser: ParseCloud {
      typealias ReturnType = String
      var functionJobName: String
      var username: String
      var password: String
      var email: String
    }
    
    let cloudUser = CloudUser(functionJobName: "userRecord", username: self.userName.text!, password: self.password.text!, email: self.email.text!)
    cloudUser.runFunction { result in
          switch result {
          case .success(let response):
            print("Response from cloud function sumNumbers: \(response)")
          case .failure(let error):
            assertionFailure("Error calling cloud function sumNumbers: \(error)")
          }
        }

错误:在范围

中找不到类型 'ParseCloud'

如果 ParseCloud 不在范围内,您似乎没有在文件顶部添加 import ParseSwift。确保你 installed SDK 正确。首选方式是 Swift 包管理器,但 cocoapods 和 carthage 应该也可以。

请务必查看 Playground files 以获取有关如何使用 Swift SDK 的示例:

import ParseSwift

//: Create your own value typed `ParseCloud` type.
struct Hello: ParseCloud {

    //: Return type of your Cloud Function
    typealias ReturnType = String

    //: These are required by `ParseCloud`, you can set the default value to make it easier
    //: to use.
    var functionJobName: String = "hello"
}

//: Create another `ParseCloud` type.
struct TestCloudCode: ParseCloud {

    //: Return type of your Cloud Function
    typealias ReturnType = [String: Int]

    //: These are required by `ParseCloud`, you can set the default value to make it easier
    //: to use.
    var functionJobName: String = "testCloudCode"

    //: If your cloud function takes arguments, they can be passed by creating properties:
    var argument1: [String: Int]
}

//: Create another `ParseCloud` type.
struct TestCloudCodeError: ParseCloud {

    //: Return type of your Cloud Function
    typealias ReturnType = String

    //: These are required by `ParseCloud`, you can set the default value to make it easier
    //: to use.
    var functionJobName: String = "testCloudCodeError"
}

/*: Assuming you have the Cloud Function named "hello" on your parse-server:
     // main.js
     Parse.Cloud.define('hello', async (request) => {
       console.log('From client: ' + JSON.stringify(request));
       return 'Hello world!';
     });
 */
let hello = Hello()

// Using async/await, the Playgounds shows how to use a completion handler
do {
  let result = try await hello.runFunction() 
  print("Response from cloud function: \(response)")

} catch {

  print("Error calling cloud function: \(error)")
}