在 swift 项目中导入 PayPal-iOS-SDK

Import PayPal-iOS-SDK in swift project

我想在我的 swift 项目中使用 PayPal-iOS-SDK。

https://github.com/paypal/PayPal-iOS-SDK

我使用 CocoaPods 并将 LSApplicationQueriesSchemes 设置为 info.plist。

但我在 AppDelegate.swift 中仍然遇到 "Use of unresolved identifier 'PayPalMobile'" 错误。

PayPalMobile .initializeWithClientIds(forEnvironments: [PayPalEnvironmentProduction: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                                                            PayPalEnvironmentSandbox: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"])

我是否需要执行更多流程才能使用 PayPal-iOS-SDK?

我想,您错过了一些使用外部库的步骤。如果您正确设置了 LSApplicationQueriesSchemes,您是否将此行包含在您的 podfile 中?

pod 'PayPal-iOS-SDK'

之后,您应该从项目路径中的 CLI 调用 pod install

如@Scriptable 所述,要使用此库,您需要使用导入。

import PayPalMobile 

将其写在您需要使用它的文件顶部。

使用正确的名称创建一个新的头文件-Bridging-Header.h 并添加:

导入“PayPalMobile.h”