10

I'm developing an app using google maps. I will explain what I did with google maps, and maybe you can help me.

I was using Google maps frameworks without POD, but after a few errors about Google map Key I deleted the google map frameworks reference and I installed it using POD. Everything is working fine, but when I hit

Product -> TEST

now I get this error:

ld: framework not found GoogleMaps for architecture arm64

Any idea how fix this?

Thank you!

Podfile looks like this 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
Sнаđошƒаӽ
  • 16,753
  • 12
  • 73
  • 90
Asinox
  • 6,747
  • 14
  • 61
  • 89

4 Answers4

2

Update Please check if you have same build settings in the Architectures and Build active Architectures only keys of the targets

Your podfile should look like this

platform :ios, '8.0'
use_frameworks!

target 'Project' do
    pod 'GoogleMaps'
end

target 'ProjectTests' do
     //inherit! :search_paths
     pod 'Mockingjay'
end

End the project target before you start the ProjectTest target, also why you add inherit! :search_paths? it's usually not needed unless you have some special requirement


Old Answer

If you want to you pods in the Test target than you have to add then in the test also the same way you have added in project's main target

So your cocoa pods like this if "SwiftCocoaPods" is your main target name

//other top level imports
target “SwiftCocoaPods” do
pod "GoogleMaps"
end

target “SwiftCocoaPodsTests” do
pod "GoogleMaps"
end

Then you should add pods for the test also like "SwiftCocoaPodsTests". you may replace the name with whatever you Test target name is

Else if you want to add the same pods in the multiple target you can use def and use that in all the targets which looks like this

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
HardikDG
  • 5,892
  • 2
  • 26
  • 55
  • 1
    No. The problem is that we do NOT want to include GoogleMaps in the Test Target. So Cocoapods is used in order to only include it in the main target. However for some reason the Test target still believes it needs to load GoogleMaps. – GnarlyDog Apr 10 '16 at 23:04
  • @GnarlyDog , so you don't want googlemaps but it takes it for test target also ? can you update your podfile ? – HardikDG Apr 11 '16 at 02:38
  • @GnarlyDog also before downvoting you guys have to mentioned you don't want cocoapods in test target still it shows/takes cocoapods in the target your current question doesn't say this, it only says build failed – HardikDG Apr 11 '16 at 03:07
  • 1
    Fair enough. But I think it's pretty clear from the original question. Nonetheless, I'll update the question with an example Podfile. – GnarlyDog Apr 11 '16 at 14:22
  • @GnarlyDog , updated the answer may be that can help – HardikDG Apr 11 '16 at 15:09
  • @Pryro , you're 2nd suggestion was not the solution, but it did get me on the right track. My real problem was a mixup due to transitioning versions of Cocoapods, Xcode, & Google Libraries. My project also included GoogleConversionTracking which I added with Cocoapods 0.39.0. There was a problem with that library (which I had forgotten about) that required me to include the main target's search paths in the test target. That indeed caused the problem with GoogleMaps. However the actual solution for the GCT pod is http://stackoverflow.com/a/18327294/558776 but for the test target. – GnarlyDog Apr 12 '16 at 02:29
  • Still... it kinda smells that I need to link the AdSupport.framework to the Test Target's build phases. The framework is in the main target and the Test target references nothing with regard to the Google framework. I have a suspicion that it might have something to do with the main app's bridging header (where the Google library is imported) and the fact that I'm using '@testable import MyApp' in my test target's test cases. – GnarlyDog Apr 12 '16 at 02:35
0

This works for me:

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
user363349
  • 1,228
  • 14
  • 16
0

You can try this workaround by opening Xcode with Rosetta as suggested in https://github.com/googlemaps/google-maps-ios-utils/issues/355#issuecomment-800912985

It will hit your performance but works.

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.

See this comment: https://github.com/googlemaps/google-maps-ios-utils/issues/355#issuecomment-1060959728

-1

for Xcode 14.3 + please follow this to Open using Rosetta in Xcode 14.3+

To run an app on a Rosetta simulator, you need to do the followings.

  1. Go to the "Product" menu in the menu bar and select Destination > Destination Architectures > Show Rosetta Destinations.
  2. You will see architecture in parenthesis next to the simulator. In this case, it is Rosetta.

You will see a Rosetta architecture in parenthesis next to simulator names. If you want to run on both architectures, select the "Show Both" option.

  • Go to the "Product" menu in the menu bar and select Destination > Destination Architectures > Show Both.

Reference: https://sarunw.com/posts/open-using-rosetta-in-xcode-14-3/

Salman
  • 191
  • 9