AWS Amplify:AWSCognitoAuthPlugin 无法解码配置
AWS Amplify: AWSCognitoAuthPlugin Unable to decode configuration
请放轻松。我不熟悉 Swift 和 AWS。我正在尝试使用 AWS 身份验证进行用户登录。使用 AWSCognitoAuthPlugin,我收到此错误:
An error occurred setting up Amplify: PluginError: Unable to decode configuration
Recovery suggestion: Make sure the plugin configuration is JSONValue
我的 Swift 文件中的内容非常通用,请按照 AWS 指南进行设置。到目前为止,我没有 UI 用于登录。我通过日志看到错误。
这是我的代码:
import SwiftUI
import Amplify
import AWSAPIPlugin
import AWSDataStorePlugin
import AWSCognitoAuthPlugin
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
do {
Amplify.Logging.logLevel = .verbose
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure()
print("Amplify configured with auth plugin")
} catch {
print("An error occurred setting up Amplify: \(error)")
}
return true
}
}
@main
struct MyAmplifyAppApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
我没有使用 cocoa pods 因为这会导致 amplify 的导入语句不起作用。我正在遵循 AWS 的本指南:
https://docs.amplify.aws/lib/auth/getting-started/q/platform/ios#install-amplify-libraries
卡在 Initialize Amplify Auth 部分的最后一步。
几天来我也遇到了同样的错误,您刚刚向项目添加了基本文件,现在您需要为 Amplify 定义用户池以向两个配置文件添加更多数据。您需要 运行 这些命令才能解决此问题。请确保您位于项目目录中。
amplify init // It will make sure you have basic setup added
amplify add auth // It will add auth data and user pools to config files
amplify push // It will push all the setup to amplify cloud
希望它能解决这个问题:)
请放轻松。我不熟悉 Swift 和 AWS。我正在尝试使用 AWS 身份验证进行用户登录。使用 AWSCognitoAuthPlugin,我收到此错误:
An error occurred setting up Amplify: PluginError: Unable to decode configuration
Recovery suggestion: Make sure the plugin configuration is JSONValue
我的 Swift 文件中的内容非常通用,请按照 AWS 指南进行设置。到目前为止,我没有 UI 用于登录。我通过日志看到错误。
这是我的代码:
import SwiftUI
import Amplify
import AWSAPIPlugin
import AWSDataStorePlugin
import AWSCognitoAuthPlugin
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
do {
Amplify.Logging.logLevel = .verbose
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure()
print("Amplify configured with auth plugin")
} catch {
print("An error occurred setting up Amplify: \(error)")
}
return true
}
}
@main
struct MyAmplifyAppApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
我没有使用 cocoa pods 因为这会导致 amplify 的导入语句不起作用。我正在遵循 AWS 的本指南: https://docs.amplify.aws/lib/auth/getting-started/q/platform/ios#install-amplify-libraries
卡在 Initialize Amplify Auth 部分的最后一步。
几天来我也遇到了同样的错误,您刚刚向项目添加了基本文件,现在您需要为 Amplify 定义用户池以向两个配置文件添加更多数据。您需要 运行 这些命令才能解决此问题。请确保您位于项目目录中。
amplify init // It will make sure you have basic setup added
amplify add auth // It will add auth data and user pools to config files
amplify push // It will push all the setup to amplify cloud
希望它能解决这个问题:)