Skip to content
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
Closed

Missing required module 'Google' #4858

longlongjump opened this issue Feb 4, 2016 · 27 comments

Comments

@longlongjump
Copy link

@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
Copy link
Contributor

@fulldecent 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
Copy link
Member

@segiddins segiddins commented Feb 18, 2016

@longlongjump that sample project doesnt seem to be available?

@nekrich
Copy link

@nekrich nekrich commented Feb 24, 2016

@segiddins
Copy link
Member

@segiddins 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
Copy link
Member

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

@koraykoska
Copy link

@koraykoska koraykoska 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
Copy link

@achernoprudov achernoprudov commented Apr 8, 2016

Is there still no workaround for that?

@longlongjump
Copy link
Author

@longlongjump longlongjump commented Apr 8, 2016

Use it directly without cocoapods

@achernoprudov
Copy link

@achernoprudov 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
Copy link

@yunnnyunnn 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
Copy link

@hijamoya hijamoya commented Apr 28, 2016

@yunnnyunnn 's solution works for me!

@neonichu
Copy link
Member

@neonichu 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
Copy link

@basvankuijck 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
Copy link
Contributor

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

@stanmots 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
Copy link

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

@wafisher 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?

@esetnik
Copy link

@esetnik 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
Copy link

@simonbengtsson 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
Copy link

@acchou 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
Copy link

@kakubei 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
Copy link
Member

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

@kakubei kakubei commented Jun 7, 2017

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

@dnkoutso
Copy link
Contributor

@dnkoutso dnkoutso commented Jun 7, 2017

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

@paulb777
Copy link
Member

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

@kakubei 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.