英文:
Why my app crashes when I try to sign in with Google in ios-prod flavor?
问题
我正在尝试为开发和生产环境使用不同的 Firebase 项目,并使用 Flutter 的 flavors 和 xCode schemes 进行设置。在 Android 上运行良好。但在 iOS 上,当我尝试使用 google_sign_in 在 prod flavor 中登录时,应用程序崩溃,没有任何输出。在 dev flavor 中也运行良好。
为了设置这个,我遵循了 这篇帖子。
我认为问题可能出在这里:
为了根据 flavor 更改不同的 REVERSED_CLIENT_ID,我做了以下操作(这也包含在我之前提到的帖子中):
我将以下内容添加到 ios/Flutter/Debug.xcconfig
和 ios/Flutter/Release.xcconfig
:
GOOGLE_SERVICE_REVERSED_CLIENT_ID = {Your REVERSED_CLIENT_ID found in GoogleService-Info.plist file}
在我的 ios/Runner/info.plist
中,我将这个:
<key>CFBundleURLSchemes</key>
<array>
<string>myOldReversedClientId</string>
</array>
更改为:
<key>CFBundleURLSchemes</key>
<array>
<string>$(GOOGLE_SERVICE_REVERSED_CLIENT_ID)</string>
</array>
最后,在 xCode 中的 Build Settings -> User-Defined
中,根据每个环境定义了我的变量 GOOGLE_SERVICE_REVERSED_CLIENT_ID:
Debug-dev = com.googleusercontent.apps.{dev client-id}
Debug-prod = com.googleusercontent.apps.{prod client-id}
Profile-dev = com.googleusercontent.apps.{dev client-id}
Profile-prod = com.googleusercontent.apps.{prod client-id}
Release-dev = com.googleusercontent.apps.{dev client-id}
Release-prod = com.googleusercontent.apps.{prod client-id}
(显然,使用每个 GoogleService-Info.plist 的 REVERSED_CLIENT_ID)
另外,当我实现 GoogleSignIn
类时,我这样做:
GoogleSignIn(clientId: DefaultFirebaseOptions.currentPlatform.iosClientId).signIn()
我的 ios/runner
文件夹中没有 GoogleService-Info.plist
文件。
由于它适用于 dev flavor,但不适用于 prod flavor,我认为问题可能出在我实现 GoogleSignIn
类时定义 clientId
时。也许我传递的是适用于 dev flavor 但不适用于 prod flavor 的 ID,但我不确定,也不知道还有哪些其他替代方案。
英文:
I am trying to set up different firebase projects for development and production with flavors and xCode schemes. It works well in Android. But, in IOS, when I try to sign in with google_sign_in with the prod flavor it crashes the app, without any output. In the dev flavor it also works well.
To set up this I followed this post
I think the problem may be here:
To change the differents REVERSED_CLIENT_ID depending on the flavor I did this (this also is included on the post I mentioned before):
I added this to ios/Flutter/Debug.xcconfig
and ios/Flutter/Release.xcconfig
GOOGLE_SERVICE_REVERSED_CLIENT_ID = {Your REVERSED_CLIENT_ID found in GoogleService-Info.plist file}
On my ios/Runner/info.plist
I changed this:
<key>CFBundleURLSchemes</key>
<array>
<string>myOldReversedClientId</string>
</array>
To this:
<key>CFBundleURLSchemes</key>
<array>
<string>$(GOOGLE_SERVICE_REVERSED_CLIENT_ID)</string>
</array>
And finally in xCode in Build Settings -> User-Defined
I defined my variable GOOGLE_SERVICE_REVERSED_CLIENT_ID according to each enviroment:
Debug-dev = com.googleusercontent.apps.{dev client-id}
Debug-prod = com.googleusercontent.apps.{prod client-id}
Profile-dev = com.googleusercontent.apps.{dev client-id}
Profile-prod = com.googleusercontent.apps.{prod client-id}
Release-dev = com.googleusercontent.apps.{dev client-id}
Release-prod = com.googleusercontent.apps.{prod client-id}
(obviously, using the REVERSED_CLIENT_ID of each GoogleService-Info.plist)
Also, when I implement the GoogleSignIn
class I do it this way:
GoogleSignIn(clientId: DefaultFirebaseOptions.currentPlatform.iosClientId).signIn()
I don't have a GoogleService-Info.plist
file on my ios/runner
folder
As it works for the dev-flavor but it doesn't for the prod-flavor, I think that it could be a problem when I implement the GoogleSignIn
class and I define the clientId
. Maybe I'm passing an Id which works for the dev-flavor but not for the prod-flavor, but I'm not sure and I don't know which other alternative I have.
答案1
得分: 0
解决。
我必须以这种方式登录:
GoogleSignIn().signIn()
英文:
Solved.
I have to sign in this way:
GoogleSignIn().signIn()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论