我正在使用谷歌地图开发一个应用程序。我会解释我用谷歌地图做了什么,也许你可以帮助我。
我在没有 POD 的情况下使用 Google 地图框架,但在出现一些关于 Google 地图密钥的错误后,我删除了 google 地图框架参考,并使用 POD 安装了它。一切都工作正常,但是当我点击
产品 -> 测试
现在我收到此错误:
ld: framework not found GoogleMaps for architecture arm64
知道如何解决这个问题吗?
谢谢!
Podfile 看起来像这个 Cocoapods v1.0 beta 6):
platform :ios, '8.0'
use_frameworks!
target 'Project' do
pod 'GoogleMaps'
target 'ProjectTests' do
inherit! :search_paths
pod 'Mockingjay'
end
end
更新 请检查目标的
Architectures
和 Build active Architectures only
键中是否具有相同的构建设置
你的 podfile 应该是这样的
platform :ios, '8.0'
use_frameworks!
target 'Project' do
pod 'GoogleMaps'
end
target 'ProjectTests' do
//inherit! :search_paths
pod 'Mockingjay'
end
在开始
project
目标之前结束ProjectTest
目标,还有为什么要添加inherit! :search_paths
?除非您有特殊要求,否则通常不需要
旧答案
如果您想在测试目标中添加 pod,则必须在测试中添加,就像您在项目的主目标中添加的方式一样
如果“SwiftCocoaPods”是您的主要目标名称,那么您的可可豆荚就像这样
//other top level imports
target “SwiftCocoaPods” do
pod "GoogleMaps"
end
target “SwiftCocoaPodsTests” do
pod "GoogleMaps"
end
然后您应该添加用于测试的 pod,例如“SwiftCocoaPodsTests”。您可以将名称替换为您的测试目标名称
否则,如果您想在多个目标中添加相同的 pod,您可以使用
def
并在所有目标中使用它,如下所示
def project_pods
pod "GoogleMaps"
//add other pods which you want in all the targets
end
target “SwiftCocoaPods” do
project_pods
end
//only add project_pods instead of pods individually
target “SwiftCocoaPodsTests” do
project_pods
end
这对我有用:
platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
def all_pods
pod 'GoogleMaps'
end
abstract_target 'Map Base' do
all_pods
target 'Map' do
end
target 'Unit Tests' do
end
target 'Device Tests' do
end
end
您可以按照https://github.com/googlemaps/google-maps-ios-utils/issues/355#issuecomment-800912985
中的建议使用Rosetta打开Xcode来尝试此解决方法它会影响你的表现,但有效。
1 - With Xcode closed (Important) Go to finder -> Applications
2 - Right Click on Xcode and select "Get Info"
3 - On the info panel check "Open using Rosetta"
4 - Double Click in the large bottom preview of the info panel.
看到这条评论: https://github.com/googlemaps/google-maps-ios-utils/issues/355#issuecomment-1060959728
适用于 Xcode 14.3 + 请按照此在 Xcode 14.3+ 中使用 Rosetta 打开
要在 Rosetta 模拟器上运行应用程序,您需要执行以下操作。
您将在模拟器名称旁边的括号中看到 Rosetta 架构。 如果您想在两种架构上运行,请选择“显示两者”选项。
参考:https://sarunw.com/posts/open-using-rosetta-in-xcode-14-3/