这应该很容易,但它让我卡住了。
在我的应用程序中,我有一个全局常量定义为
public let apiKey = "hjbcsddsbsdjhksdbvbsdbvsdbvs"
我想在作为 SwiftPackage 添加到项目中的库中使用该 apiKey。我需要它在图书馆中启动服务。
Library.configure(withAPIKey: apiKey)
但我得到了错误
Cannot find apiKey in scope
我尝试将 apiKey 包装成这样的结构:
public struct globalConstants {
static let apiKey = "hjbcsddsbsdjhksdbvbsdbvsdbvs"
}
并这样使用它:
Library.configure(withAPIKey: globalConstants.apiKey)
我收到类似的错误消息。
我错过了什么?