如何让SwiftUI应用程序使用Firebase Functions emulator而不是生产?

如何让SwiftUI应用程序使用Firebase Functions emulator而不是生产?,firebase,swiftui,google-cloud-functions,Firebase,Swiftui,Google Cloud Functions,因此,我目前在代码中添加了Firebase函数模拟器调用,如下所示 导入快捷界面 进口火基 导入FirebaseAuth 导入FirebaseFunctions @主要 结构我的Web应用程序:应用程序{ init(){ FirebaseApp.configure() Functions.Functions().useEmulator(带主机):http://localhost“,端口:5000) Functions.Functions().useFunctionsEmulator(原点:)ht

因此,我目前在代码中添加了Firebase函数模拟器调用,如下所示

导入快捷界面
进口火基
导入FirebaseAuth
导入FirebaseFunctions
@主要
结构我的Web应用程序:应用程序{
init(){
FirebaseApp.configure()
Functions.Functions().useEmulator(带主机):http://localhost“,端口:5000)
Functions.Functions().useFunctionsEmulator(原点:)http://localhost:5000")
}
var body:一些场景{
窗口组{
MyFirstView()
}
}
}
但无论我什么时候使用

Functions.Functions.httpscalable(“myFunction”).call()
它不起作用。它不断调用生产中的函数,而不是本地函数。有人能告诉我我可能做错了什么吗


非常感谢您的帮助。谢谢。

云功能模拟器通常在端口5001上启动(请参阅)

以下是我的作品:

let functions=functions.functions()
functions.useEmulator(带主机:“localhost”,端口:5001)
让helloWorldCallable=functions.httpscalable(“helloWorld”)
helloWorldCallable.call{结果,中出现错误
如果let error=错误为N错误{
如果error.domain==functionErrorDomain{
let code=functionErrorCode(原始值:error.code)
let message=error.localizedDescription
let details=error.userInfo[functionErrorDetailsKey]
print(“尝试调用函数时出错。\n”+
“代码:\(字符串(描述:代码))\n”+
“消息:\(消息)\n”+
“详细信息:\(字符串(描述:详细信息))”)
}
}
如果let data=result?数据为?字符串{
self.message=数据
self.showResultSheet=true
}
}

云函数模拟器通常在端口5001上启动(请参阅)

以下是我的作品:

let functions=functions.functions()
functions.useEmulator(带主机:“localhost”,端口:5001)
让helloWorldCallable=functions.httpscalable(“helloWorld”)
helloWorldCallable.call{结果,中出现错误
如果let error=错误为N错误{
如果error.domain==functionErrorDomain{
let code=functionErrorCode(原始值:error.code)
let message=error.localizedDescription
let details=error.userInfo[functionErrorDetailsKey]
print(“尝试调用函数时出错。\n”+
“代码:\(字符串(描述:代码))\n”+
“消息:\(消息)\n”+
“详细信息:\(字符串(描述:详细信息))”)
}
}
如果let data=result?数据为?字符串{
self.message=数据
self.showResultSheet=true
}
}