Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在生成阶段处理不同配置后,找不到有效的GoogleService-Info.plist_Ios_Firebase_Configuration_Google Play Services_Run Script - Fatal编程技术网

Ios 在生成阶段处理不同配置后,找不到有效的GoogleService-Info.plist

Ios 在生成阶段处理不同配置后,找不到有效的GoogleService-Info.plist,ios,firebase,configuration,google-play-services,run-script,Ios,Firebase,Configuration,Google Play Services,Run Script,我正在使用firebase在应用程序iOS中进行标记 我在app、dev、prod、prepod和appStore中有不同的配置。 所以我在项目中有几个GoogleService-Info.plist 我在参考资料文件夹中将它们重命名为GoogleService-Info-Prod.plist,GoogleService-Info-Dev.plist 我在project的构建阶段添加了一个运行脚本 cp“${SRCROOT}/Test/resources/Firebase/GoogleServi

我正在使用firebase在应用程序iOS中进行标记

我在app、dev、prod、prepod和appStore中有不同的配置。 所以我在项目中有几个GoogleService-Info.plist

我在参考资料文件夹中将它们重命名为GoogleService-Info-Prod.plist,GoogleService-Info-Dev.plist

我在project的构建阶段添加了一个运行脚本

cp“${SRCROOT}/Test/resources/Firebase/GoogleService Info-$CONFIGURATION.plist”“${SRCROOT}/Test/resources/Firebase/GoogleService Info.plist”我打算将GoogleService-Info-blablabla.plist的内容压缩到GoogleService-Info.plist中

但很明显,我有一个错误:

2018-07-02 19:05:27.295083+0200测试[PROD][63021:19806839]***由于未捕获异常“com.firebase.core”而终止应用程序,原因:“
[FIRApp configure]
FirebaseApp.configure()
在Swift中)在项目中找不到有效的GoogleService-Info.plist。请从下载一个

你知道我哪里出错了吗?
非常感谢您的关注

我相信你的方法中有很多问题

第1期:

我相信简单地将文件复制到文件夹是没有帮助的,您需要将文件添加到project中,并将其目标成员身份更改为您正在运行的特定目标。您需要在运行特定目标的构建阶段添加文件以复制捆绑资源

第二期:

此外,尽管您更改了
GoogleService info.plist
name的文件名,Firebase仍在查找
GoogleService info.plist
,而不是您重命名的文件,因此发生了崩溃

正如这里提到的github.com/firebase/quickstart-ios/issues/5您不能更改文件名,文件名必须命名为GoogleService-info.plist。所以复制整个文件将不起作用

可能的解决方案:

与复制文件不同,您可以做的是创建一个名为
GoogleService info.plist的空plist文件。plist
确保正确勾选了其目标成员资格,并将其添加到目标的复制捆绑资源中。将其他GoogleService-Info-Configuration.plist文件复制到项目中

然后,在运行脚本中,从特定的GoogleService Info-{Configuration}.plist读取内容,并将文件内容复制到您的
GoogleService Info.plist

使用类似

cat "${SRCROOT}/Test/Resourses/Firebase/GoogleService-Info-$CONFIGURATION.plist"  > "${SRCROOT}/Test/Resourses/Firebase/GoogleService-Info.plist"
或者正如OP在评论中提到的那样

cp "${SRCROOT}/Turf/Resourses/Firebase/GoogleService-Info-$CONFIGURATION.plist" "${SRCROOT}/Turf/Resourses/Firebase/GoogleService-Info.plist"

我还没有测试过上面的粘贴shell脚本,不过它应该可以让您非常简单地了解如何解决这个问题。

虽然这是一个相当老的问题,但这里有一个更好的解决方案。 您可以使用选项参数初始化firebase。在那里可以定义所需的GoogleService-Info.plist文件

let options = FirebaseOptions(contentsOfFile: Bundle.main.path(forResource: Constants.Firebase.plistFileName, ofType: "plist")!)!
FirebaseApp.configure(options: options)

例如,我在一个单独的常量文件中定义了stage/test和production的不同文件。在这个文件中,我用环境变量来区分常量的不同值。

我添加了一个空的GoogleService.plist并使用这个脚本:cp“${SRCROOT}/turph/resources/Firebase/GoogleService Info-$CONFIGURATION.plist”“${SRCROOT}/turph/resources/Firebase/GoogleService Info.plist”效果很好,谢谢你的帮助:)@shanshan ttzi:对不起,伙计,我被搞糊涂了,是的,cp命令可以正常工作:)干杯:)编码快乐