xcode GoogleMaps (GMSView) 不会在 iOS 中显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32054346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:41:26  来源:igfitidea点击:

GoogleMaps (GMSView) Won't display in iOS

iosxcodeswiftgoogle-mapsgmsmapview

提问by Avery Bentz

I have incorporated the following:

我已经合并了以下内容:

  1. Tried importing both the GoogleMaps/GoogleMaps.has well as the GoogleMapsM4B/GoogleMaps.hfiles through an Obj-CBridging Header
  2. Manually typed out the iOS API key in my AppDelegate.swift (didFinishLaunchingWithOptions)method.
  3. Cleaned the project (command+shift+k)
  4. Closed/relaunched Xcode
  5. Uninstalled/reinstalled Xcode
  1. 尝试导入两个GoogleMaps/GoogleMaps.h还有GoogleMapsM4B/GoogleMaps.h通过文件Obj-C桥接报
  2. 在我的AppDelegate.swift (didFinishLaunchingWithOptions)方法中手动输入 iOS API 密钥。
  3. 清理项目(command+shift+k)
  4. 关闭/重新启动 Xcode
  5. 卸载/重新安装 Xcode

And pretty much everything else other people have suggested. I have spent two days straight trying to fix this problem. Does anyone know a solution to this problem?

几乎所有其他人建议的其他内容。我已经连续两天试图解决这个问题。有谁知道这个问题的解决方案?

The console complaint is:

控制台投诉是:

> "2015-08-17 18:02:19.899 Project[608:10014] ClientParametersRequest
> failed, 3 attempts remaining (0 vs 6). Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x790bc050
> {data=<CFData 0x7925cb40 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:19.899 randoPracty[608:10014] Google Maps SDK for iOS
> (M4B) version: 1.10.17867.0 2015-08-17 18:02:19.959
> randoPracty[608:10014] ClientParametersRequest failed, 2 attempts
> remaining (0 vs 6). Error Domain=com.google.HTTPStatus Code=400 "The
> operation couldn't be completed. (com.google.HTTPStatus error 400.)"
> UserInfo=0x7925cf40 {data=<CFData 0x79187b20 [0x22da9a8]>{length =
> 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ...
> 3c2f48544d4c3e0a}} 2015-08-17 18:02:24.406 randoPracty[608:10014]
> ClientParametersRequest failed, 1 attempts remaining (0 vs 6). Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x790f4c60
> {data=<CFData 0x786e5610 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:32.797 randoPracty[608:10014] ClientParametersRequest
> failed, 0 attempts remaining (0 vs 6). Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7925b390
> {data=<CFData 0x790f3760 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:32.797 randoPracty[608:10014] Google Maps SDK for iOS
> (M4B) cannot connect or validate APIKey: Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7925b390
> {data=<CFData 0x790f3760 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:32.798 randoPracty[608:10014] Your key may be invalid
> for your bundle ID: com.User.ProjectName"
> "2015-08-17 18:02:19.899 Project[608:10014] ClientParametersRequest
> failed, 3 attempts remaining (0 vs 6). Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x790bc050
> {data=<CFData 0x7925cb40 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:19.899 randoPracty[608:10014] Google Maps SDK for iOS
> (M4B) version: 1.10.17867.0 2015-08-17 18:02:19.959
> randoPracty[608:10014] ClientParametersRequest failed, 2 attempts
> remaining (0 vs 6). Error Domain=com.google.HTTPStatus Code=400 "The
> operation couldn't be completed. (com.google.HTTPStatus error 400.)"
> UserInfo=0x7925cf40 {data=<CFData 0x79187b20 [0x22da9a8]>{length =
> 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ...
> 3c2f48544d4c3e0a}} 2015-08-17 18:02:24.406 randoPracty[608:10014]
> ClientParametersRequest failed, 1 attempts remaining (0 vs 6). Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x790f4c60
> {data=<CFData 0x786e5610 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:32.797 randoPracty[608:10014] ClientParametersRequest
> failed, 0 attempts remaining (0 vs 6). Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7925b390
> {data=<CFData 0x790f3760 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:32.797 randoPracty[608:10014] Google Maps SDK for iOS
> (M4B) cannot connect or validate APIKey: Error
> Domain=com.google.HTTPStatus Code=400 "The operation couldn't be
> completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7925b390
> {data=<CFData 0x790f3760 [0x22da9a8]>{length = 145, capacity = 256,
> bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
> 2015-08-17 18:02:32.798 randoPracty[608:10014] Your key may be invalid
> for your bundle ID: com.User.ProjectName"

采纳答案by Dev

I too faced the same problem. First of all follow the steps below.

我也面临同样的问题。首先,请按照以下步骤操作。

  1. Have all the steps mentioned in thislink been followed by you?

  2. Though you are unable to get through, check your Bundle Identifier is matching with the one you used to create the key.

  1. 您是否已遵循链接中提到的所有步骤?

  2. 尽管您无法通过,请检查您的捆绑标识符是否与您用于创建密钥的标识符匹配。

If everything is well and good, the problem is with the framework. Initially I too used the GoogleMapsM4B framework which didn't work for me. I downloaded the other framework which works fine for me from thislink.

如果一切顺利,那么问题就出在框架上。最初我也使用了对我不起作用的 GoogleMapsM4B 框架。我从这个链接下载了另一个对我来说很好用的框架。

Add the new framework (GoogleMaps.framework) and remove the GoogleMapsM4Bframework from the project. This solved my problem. Hope this helps you.

添加新框架 ( GoogleMaps.framework) 并GoogleMapsM4B从项目中删除该框架。这解决了我的问题。希望这对你有帮助。

EDIT:

编辑:

From version 1.10.0 onwards, the framework installation is supported only via cocoapods. And all zip downloads were removed for previous versions. Read "Migration from 1.9.2 or earlier:" section under "Version 1.10.0 - May 2015" in thislink.

从 1.10.0 版本开始,仅通过 cocoapods 支持框架安装。并且删除了以前版本的所有 zip 下载。阅读链接中“1.10.0 版 - 2015 年 5 月”下的“从 1.9.2 或更早版本迁移:”部分。

回答by Michael Katkov

Just enable "Google Maps SDK for iOS" for your project in Google Developers Console.

只需在Google Developers Console 中为您的项目启用“Google Maps SDK for iOS” 。

回答by Mattk90

I had the same problem. In my case it was, that I had to manually activate the Google Maps SDK for iOS and Google Places SDK for iOS in the Overview section of Googles API Library.

我有同样的问题。就我而言,我必须在 Googles API 库的概览部分手动激活适用于 iOS 的 Google Maps SDK 和适用于 iOS 的 Google Places SDK。

The steps how to activate it are:

激活步骤如下:

  1. Go to the Overviewpage in the API Library.
  2. Choose here Google Maps SDK for iOSand Google Places SDK for iOS.
  1. 转至API 库中的概览页面。
  2. 在此处选择适用于 iOS 的 Google Maps SDK适用于 iOS 的Google Places SDK

enter image description here

在此处输入图片说明

  1. Choose at the top left, the second item. On the screenshot it's now enabled. Before it was disabled.
  1. 选择左上角的第二项。在屏幕截图上,它现在已启用。在它被禁用之前。

enter image description here

在此处输入图片说明

Maybe this helps someone as well.

也许这也有助于某人。

Kind regards Matt

亲切的问候马特

回答by 72A12F4E

Can you update your question to provide any more details? (xcode version, Google Maps Framework version, etc)

您能否更新您的问题以提供更多详细信息?(xcode 版本、Google Maps Framework 版本等)

  1. Double check that your API key is valid for your bundle id on console.developer.google.com
  2. When running, check and see if any SSL errors are occurring in the console. In my case, I was having certificate problems with Google, and this interfered with my map tiles loading.
  3. Make sure you only have either the M4B framework OR the normal framework in your project. If you include both, I am pretty sure they are conflicting with each other.
  1. 在 console.developer.google.com 上仔细检查您的 API 密钥是否对您的包 ID 有效
  2. 运行时,检查并查看控制台中是否发生任何 SSL 错误。就我而言,我在使用 Google 时遇到了证书问题,这干扰了我的地图图块加载。
  3. 确保您的项目中只有 M4B 框架或普通框架。如果您将两者都包括在内,我很确定它们是相互冲突的。

Hope this helps out; it just randomly started working correctly in my case.

希望这会有所帮助;在我的情况下,它只是随机开始正常工作。

回答by Satheesh G

Check the Bundle identifier specified in the Xcode project target setting and the google project page where you created the google API key. both should match otherwise GMSServices.provideAPIKey(googleMapsAPiKey) will pass but you will get connection error

检查在 Xcode 项目目标设置中指定的 Bundle 标识符和您创建 google API 密钥的 google 项目页面。两者都应该匹配,否则 GMSServices.provideAPIKey(googleMapsAPiKey) 将通过,但您将收到连接错误

The operation couldn't be completed. (com.google.HTTPStatus error 400.)

操作无法完成。(com.google.HTTPStatus 错误 400。)

回答by iHarshil

I faced this problem too and after an hour of Googling and juggling on #SO, I have come to know this little mistake:

我也遇到了这个问题,经过一个小时的谷歌搜索和#SO 杂耍,我知道了这个小错误:

If you have changed your API key (somewhere during the development)

如果您更改了 API 密钥(在开发过程中的某个地方)

[GMSPlacesClient provideAPIKey:@"YOUR_API_KEY"];

[GMSPlacesClient 提供APIKey:@"YOUR_API_KEY"];

which you add to your didFinishLaunchingWithOptions:method in your AppDelegate.mfile. Make sure it is the same as you used to activating the Google Places APIhere

您将其添加到AppDelegate.m文件中的didFinishLaunchingWithOptions:方法中。确保它与您在此处激活Google Places API 时使用的相同

Hope this may help to someone after trying every solution.

希望在尝试了所有解决方案后这可能对某人有所帮助。