Cocoapods: Missing required module 'Google'

Created on 4 Feb 2016  Â·  27Comments  Â·  Source: CocoaPods/CocoaPods

Hello
Xcode emits Missing required module 'Google' when running unit test target.
Problem persists only with Google framework. In my original project i was using "Google/SignIn".

i created sample project here https://github.com/longlongjump/cocoapods-google-bug

i experience this problem on cocoapods 1.0.0.beta.3 and earlier

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.0"
use_frameworks!

target ’test’ do

    pod 'Google'
    pod 'Alamofire'

    target 'testTests' do
        inherit! :search_paths
        pod 'Nimble', '~> 3.0.0'
        pod 'OHHTTPStubs'
        pod 'OHHTTPStubs/Swift'
    end
end
detailed discussion

Most helpful comment

Solved this problem by adding Header Search Paths to Unit Test Target:

  1. Select your Unit Test Target setting.
  2. Go to Build Settings.
  3. Look for Header Search Paths.
  4. Add this value $(SRCROOT)/Pods with recursive, then Xcode will resolve the path for you.
    header search path
    @Estanque @longlongjump @Ybrin Maybe you would like to try if this works for you.

All 27 comments

I have the same issue. Also, adding the line

import Google

Will produce the error

No such module 'Google'

@longlongjump that sample project doesnt seem to be available?

@longlongjump
Make a bridging header

This is because the Google podspec is manually setting "HEADER_SEARCH_PATHS": "$(inherited) ${PODS_ROOT}/Google/Headers" in the user_target_xcconfig. Should search paths inheritance include {FRAMEWORK,HEADER}_SEARCH_PATHS from the user_target_xcconfig, @CocoaPods/core ?

Paths relative to PODS_ROOT rely on CocoaPods generated directory-structure, even though that was historically relatively stable from version to version and might be quite predictable, this feels like a big hack and could cause issues in edge cases, e.g. deduplication across platforms, where you end up having Google-iOS and Google-OSX instead. So I wonder whether we can do anything, so that the underlying issue can be addressed and such definitions can be avoided in the first place.

I have the exact same problem and I can't run Tests if I have the pod 'Google/CloudMessaging' installed. Is there any workaround for that?

Is there still no workaround for that?

Use it directly without cocoapods

It will work if you are using first module only. But my project uses Google Cloud Messaging service which contains a lot of dependencies. So this solution is not appropriate for me.

Solved this problem by adding Header Search Paths to Unit Test Target:

  1. Select your Unit Test Target setting.
  2. Go to Build Settings.
  3. Look for Header Search Paths.
  4. Add this value $(SRCROOT)/Pods with recursive, then Xcode will resolve the path for you.
    header search path
    @Estanque @longlongjump @Ybrin Maybe you would like to try if this works for you.

@yunnnyunnn 's solution works for me!

I'm going to close this as the underlying cause is in the Google podspec, see https://github.com/CocoaPods/CocoaPods/issues/4858#issuecomment-188368170

@yunnnyunnn's solution worked half. I got rid of the Missing required module 'Google' error. But it got replaced with another one (from Realm)
So Instead of adding $(SRCROOT)/Pods (recursive) I added:

  • "${SRCROOT}/Pods/Google" (recursive) to the Header Search Paths
  • "${SRCROOT}/Pods/Google" (recursive) to the Framework Search Paths

And now it works like a charm again

FYI, Google Analytics is gone. It is now Firebase Analytics. See the migration guide at https://firebase.google.com/support/guides/google-ios#configuring_the_firebase_sdk

I'm just working on it now. Hopefully it does not suck as much as Google's older iOS resources.

I got a similar problem. Now it is called "Missing required module 'Firebase'".

Here is how I solved it. To successfully compile the project and run unit tests the next lines must be added to the Header Search Paths:

  • $(inherited)
  • ${SRCROOT}/Pods

Same issue here -- Mine was a little different though and the path I had to add to Header Search Paths was:

${PODS_ROOT}/Google/Headers

I also have this problem, now with Firebase. The comment from @segiddins is exactly the problem. Is there a reason that inheriting search paths doesn't inherit the values _after_ the pods modify them?

Is there a fix for the Podfile itself that will add the right value to the search paths in the generated xcconfig's as opposed to having to bury the fix in the Xcode project config?

I have the same issue. Is the Firebase team aware of this? I think we need to modify the podfile.

Also had the same issue with Firebase: Missing required module Firebase. When I added $(SRCROOT)/Pods (recursive) to the Header Search Path as proposed above I got a bunch of other errors like Could not build Objective-C module Realm. Same error for the Facebook SDK.

Using $(SRCROOT)/Pods/Firebase (recursive) instead worked. Cleaning the build folder also fixed some other errors.

The problem with including $(SRCROOT)/Pods/Firebase is that it seems to break autocomplete in Xcode (at least for me).

What works for me is to modify the Podfile to have test targets inherit :complete instead of :search_paths

        inherit! :complete

So, for example the original poster's Podfile would look like this:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.0"
use_frameworks!

target ’test’ do

    pod 'Google'
    pod 'Alamofire'

    target 'testTests' do
        inherit! :complete
        pod 'Nimble', '~> 3.0.0'
        pod 'OHHTTPStubs'
        pod 'OHHTTPStubs/Swift'
    end
end

Followed by a pod install. This adds in various compilation and linking options that allows for Firebase to be found, and doesn't affect autocomplete. Note that after a pod install you'll need to remove some old frameworks from your project in the link phase of the test targets because the names used by CocoaPods is slightly different when inheriting with :complete. So you'll get a link error until you've removed these.

For me the fix was to add the HEADER_SEARCH_PATHS from Pods-project.debug.xcconfig into Pods-project-tests.debug.xcconfig. Of course, these get overwritten when you run pod install so I added a post_install lambda to the Podfile:

post_install do |installer|
    directory = installer.config.project_pods_root + 'Target Support Files/'
    podDirectory = '<directory_name>'
    fileName = podDirectory + '.debug.xcconfig'
    configFile = directory + podDirectory + fileName

    xcconfig = File.read(configFile)
    newXcconfig = 'HEADER_SEARCH_PATHS = $(inherited) ${PODS_ROOT}/Firebase/Core/Sources $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Carnival" "${PODS_ROOT}/Headers/Public/Crashlytics" "${PODS_ROOT}/Headers/Public/Fabric" "${PODS_ROOT}/Headers/Public/Firebase" "${PODS_ROOT}/Headers/Public/FirebaseAnalytics" "${PODS_ROOT}/Headers/Public/FirebaseCore" "${PODS_ROOT}/Headers/Public/FirebaseInstanceID" "${PODS_ROOT}/Headers/Public/FirebaseRemoteConfig" "${PODS_ROOT}/Headers/Public/Olapic-SDK-iOS" "${PODS_ROOT}/Headers/Public/Reveal-SDK" "${PODS_ROOT}/Headers/Public/SwiftGen"'
    File.open(configFile, "a") { |file| file << newXcconfig }
end

@kakubei An easier workaround is to update the HEADER_SEARCH_PATHS in the Build Settings of the test target. See https://github.com/firebase/firebase-ios-sdk/issues/16 and https://github.com/firebase/firebase-ios-sdk/issues/58

@paulb777 Those get blown away after each time you run pod install though.

@kakubei, @paulb777 can you please file a new issue? Is this related to test specifications?

@kakubei Not if you make the change in the xcproject's test target as opposed to a target added by CocoaPods in the xcworkspace.

@dnkoutso The bug is related to Firebase usage of CocoaPods described at firebase/firebase-ios-sdk#58

Oh, I see. Brilliant! Thanks a lot. Much better solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hmistry picture hmistry  Â·  3Comments

iosdev-republicofapps picture iosdev-republicofapps  Â·  3Comments

spencerkohan picture spencerkohan  Â·  3Comments

tlandsmancars picture tlandsmancars  Â·  3Comments

k06a picture k06a  Â·  3Comments