对不同的构建方案使用不同的GoogleService-Info.plist [英] Use different GoogleService-Info.plist for different build schemes
问题描述
我正在使用prod的构建方案,另一个使用staging(使用2个不同的包标识符),我试图为每个方案使用单独的GoogleService-Info.plist。
有什么办法可以手动选择在初始化GCM(和goole登录)时使用的plist文件?或者是可以避免使用plist并手动进行设置?
谢谢!
<@> @inidona的答案对我有用。在我将Swift 2.3转换为Swift之后,为Swift 2.3添加了b
$ b
:
let filePath = NSBundle.mainBundle()。pathForResource(GoogleService-Info,ofType:plist)
let options = FIROptions(contentsOfFile:filePath)
FIRApp.configureWithOptions(options)
用于Swift 3.0:
让filePath = Bundle.main.path(forResource:GoogleService-Info,ofType:plist)!
let options = FIROptions(contentsOfFile:filePath)
FIRApp.configure(with:options)
for Swift 4.0:
let filePath = Bundle.main.path(forResource:GoogleService-Info,ofType :plist)!
let options = FirebaseOptions(contentsOfFile:filePath)
FirebaseApp.configure(options:options!)
I am using a build scheme for prod and one for staging (with 2 different bundle identifiers) and I am trying to use a separate GoogleService-Info.plist for each scheme. Is there any way to manually select the plist file to use when initialising GCM (and goole login)? Or is its possible to avoid using the plist and do the setup manually?
Thanks!
@inidona 's answer worked for me. After I converted it to Swift
for Swift 2.3:
let filePath = NSBundle.mainBundle().pathForResource("GoogleService-Info", ofType: "plist")
let options = FIROptions(contentsOfFile: filePath)
FIRApp.configureWithOptions(options)
for Swift 3.0:
let filePath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")!
let options = FIROptions(contentsOfFile: filePath)
FIRApp.configure(with: options)
for Swift 4.0:
let filePath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")!
let options = FirebaseOptions(contentsOfFile: filePath)
FirebaseApp.configure(options: options!)
这篇关于对不同的构建方案使用不同的GoogleService-Info.plist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!