New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing required module 'Google' #4858

Closed
longlongjump opened this Issue Feb 4, 2016 · 27 comments

Comments

Projects
None yet
@longlongjump

longlongjump commented Feb 4, 2016

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
@fulldecent

This comment has been minimized.

Show comment
Hide comment
@fulldecent

fulldecent Feb 18, 2016

Contributor

I have the same issue. Also, adding the line

import Google

Will produce the error

No such module 'Google'

Contributor

fulldecent commented Feb 18, 2016

I have the same issue. Also, adding the line

import Google

Will produce the error

No such module 'Google'

@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Feb 18, 2016

Member

@longlongjump that sample project doesnt seem to be available?

Member

segiddins commented Feb 18, 2016

@longlongjump that sample project doesnt seem to be available?

@longlongjump

This comment has been minimized.

Show comment
Hide comment
@nekrich

This comment has been minimized.

Show comment
Hide comment
@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Feb 24, 2016

Member

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 ?

Member

segiddins commented Feb 24, 2016

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 ?

@mrackwitz

This comment has been minimized.

Show comment
Hide comment
@mrackwitz

mrackwitz Feb 24, 2016

Member

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.

Member

mrackwitz commented Feb 24, 2016

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.

@Ybrin

This comment has been minimized.

Show comment
Hide comment
@Ybrin

Ybrin Mar 3, 2016

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?

Ybrin commented Mar 3, 2016

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?

@achernoprudov

This comment has been minimized.

Show comment
Hide comment
@achernoprudov

achernoprudov Apr 8, 2016

Is there still no workaround for that?

achernoprudov commented Apr 8, 2016

Is there still no workaround for that?

@longlongjump

This comment has been minimized.

Show comment
Hide comment
@longlongjump

longlongjump Apr 8, 2016

Use it directly without cocoapods

longlongjump commented Apr 8, 2016

Use it directly without cocoapods

@achernoprudov

This comment has been minimized.

Show comment
Hide comment
@achernoprudov

achernoprudov Apr 8, 2016

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.

achernoprudov commented Apr 8, 2016

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.

@yunnnyunnn

This comment has been minimized.

Show comment
Hide comment
@yunnnyunnn

yunnnyunnn Apr 19, 2016

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 commented Apr 19, 2016

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.
@hijamoya

This comment has been minimized.

Show comment
Hide comment
@hijamoya

hijamoya Apr 28, 2016

@yunnnyunnn 's solution works for me!

hijamoya commented Apr 28, 2016

@yunnnyunnn 's solution works for me!

@neonichu

This comment has been minimized.

Show comment
Hide comment
@neonichu

neonichu May 1, 2016

Member

I'm going to close this as the underlying cause is in the Google podspec, see #4858 (comment)

Member

neonichu commented May 1, 2016

I'm going to close this as the underlying cause is in the Google podspec, see #4858 (comment)

@neonichu neonichu closed this May 1, 2016

@basvankuijck

This comment has been minimized.

Show comment
Hide comment
@basvankuijck

basvankuijck May 19, 2016

@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

basvankuijck commented May 19, 2016

@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

@fulldecent

This comment has been minimized.

Show comment
Hide comment
@fulldecent

fulldecent May 23, 2016

Contributor

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.

Contributor

fulldecent commented May 23, 2016

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.

@stanmots

This comment has been minimized.

Show comment
Hide comment
@stanmots

stanmots Jul 25, 2016

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

stanmots commented Jul 25, 2016

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
@briankeane

This comment has been minimized.

Show comment
Hide comment
@briankeane

briankeane Sep 15, 2016

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

briankeane commented Sep 15, 2016

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

@wafisher

This comment has been minimized.

Show comment
Hide comment
@wafisher

wafisher Sep 22, 2016

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?

wafisher commented Sep 22, 2016

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?

skunkmb pushed a commit to skunkmb/AbloLegacy that referenced this issue Sep 24, 2016

skunkmb
Import the main Ablo module for testing
In order to import Ablo, ensure that testing is enabled for it, and that
`HEADER_SEARCH_PATHS` is set to  `$(SRCROOT)/Pods`, to prevent an error
that says `Missing required module 'Firebase'`.  To learn more, visit
CocoaPods/CocoaPods#4858, and see
@yunnnyunnn's comment.
@esetnik

This comment has been minimized.

Show comment
Hide comment
@esetnik

esetnik Oct 5, 2016

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

esetnik commented Oct 5, 2016

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

@simonbengtsson

This comment has been minimized.

Show comment
Hide comment
@simonbengtsson

simonbengtsson Nov 5, 2016

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.

simonbengtsson commented Nov 5, 2016

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.

@acchou

This comment has been minimized.

Show comment
Hide comment
@acchou

acchou Nov 17, 2016

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.

acchou commented Nov 17, 2016

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.

@kakubei

This comment has been minimized.

Show comment
Hide comment
@kakubei

kakubei Jun 7, 2017

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 commented Jun 7, 2017

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
@paulb777

This comment has been minimized.

Show comment
Hide comment
@paulb777

paulb777 Jun 7, 2017

Member

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

Member

paulb777 commented Jun 7, 2017

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

@kakubei

This comment has been minimized.

Show comment
Hide comment
@kakubei

kakubei Jun 7, 2017

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

kakubei commented Jun 7, 2017

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

@dnkoutso

This comment has been minimized.

Show comment
Hide comment
@dnkoutso

dnkoutso Jun 7, 2017

Contributor

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

Contributor

dnkoutso commented Jun 7, 2017

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

@paulb777

This comment has been minimized.

Show comment
Hide comment
@paulb777

paulb777 Jun 7, 2017

Member

@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

Member

paulb777 commented Jun 7, 2017

@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

@kakubei

This comment has been minimized.

Show comment
Hide comment
@kakubei

kakubei Jun 7, 2017

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

kakubei commented Jun 7, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment