Module 'GooglePlaces' not found - ios

I installed GooglePlaces, GooglePlacePicker and GoogleMaps as recommended using this Podfile:
platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'Myapp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'GooglePlacePicker'
pod 'TesseractOCRiOS', '4.0.0'
target 'MyappTests' do
inherit! :search_paths
# Pods for testing
end
end
In AppDelegate.h
#import GooglePlaces;
#import GooglePlacePicker;
#import GoogleMaps;
I can see the pods in my Pods directory, but Xcode gives me an error Module 'GooglePlaces' not found. I have launched Xcode properly by double clicking the .xcworkspace file.
Interestingly, if I add these pods to a brand new Xcode project, everything works fine. So, there must be some other setting in this specific project which is interfering with the module search path.
Is there a pragmatic way to compare the two projects and isolate the critical difference?
The Framework Search Paths in my project is:
Debug -> $(inherited) $(PROJECT_DIR) $(PROJECT_DIR)/Pods/GooglePlaces/Frameworks
Release -> $(inherited) $(PROJECT_DIR) $(PROJECT_DIR)/Pods/GooglePlaces/Frameworks
The project where everything works well has a different search path:
$(inherited) "${PODS_ROOT}/GoogleMaps/Base/Frameworks" "${PODS_ROOT}/GoogleMaps/Maps/Frameworks" "${PODS_ROOT}/GooglePlacePicker/Frameworks" "${PODS_ROOT}/GooglePlaces/Frameworks"
However, adding this path to my project did not fix the issue.

Related

Xcode and Cocoapods "No such module" error

I recently upgraded to Xcode 8 and an existing project to Swift 3. After having a variety of issues with Cocoapods, I decided to start over from scratch. After running pod deintegrate and deleting Podfile, Podfile.lock, and [Project].xcworkspace, I had a blank slate as far as Cocoapods was concerned.
I then took the following actions:
Opened a terminal at the project location and ran pod init, then pod install (using the stub Podfile that pod init creates).
This appeared to be successful, but came with the following two warnings:
[!] The `Xena [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Xena [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
At this point, opening Xcode and building the project gives the "No such module" error, which is entirely expected.
Following the instructions at this question solves this problem and rerunning pod install is a success.
Closed Xcode, added the modules I'm using to the Podfile (see below), the ran pod install again. According to the terminal output, this is successful.
Opened Xcode and built the project. I again receive the "No such module" error, specifically No such module 'ReactiveCocoa'
I have confirmed that the same problem occurs with SnapKit, Hue, KMPlaceholderTextView, KeychainSwift, and Siren, depending on the order of the import statements. For some reason, none of the Google modules are affected by this problem.
My Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Xena' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Xena
pod 'ReactiveCocoa', :git => 'https://github.com/ReactiveCocoa/ReactiveCocoa.git'
pod 'SnapKit', '~> 3.0.2'
pod 'Hue', '~> 2.0.1'
pod 'KMPlaceholderTextView', '~> 1.3.0'
pod 'GooglePlacePicker'
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'KeychainSwift', '~> 7.0'
pod 'Siren'
target 'XenaTests' do
inherit! :search_paths
# Pods for testing
end
target 'XenaUITests' do
inherit! :search_paths
# Pods for testing
end
end
Make sure you are opening .xcworkspace and not .xcodeproj file.
You may further look into this post.
Also under : Target > General > Linked Frameworks and Libraries
Make sure your frameworks are there. Even Pods_Xena.framework is there
Try:
Xcode ->Preferences ->Location ->DerivedData
open the folder DerivedData and move it to Trash
Uncomment the next line to define a global platform for your project
platform :iOS, '9.0'
Uncommenting the second line in your pod file will help you.

cocoa pod : Swift compiler error "Failed to import bridging header" reason?

I am using cocoa pod version 1.1.1, swift 3.0.1 and Xcode 8.1. I have an app, which used cocoa pod like this (Podfile)
# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'
platform :ios, '8.0'
use_frameworks!
target 'TestApp' do
pod 'GoogleAnalytics', '~> 3.14.0'
end
target 'TestAppTests' do
pod 'Quick'
pod 'Nimble'
end
And I have some objective-C file also, that's why I used Bridging-Header.h file.
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import <CommonCrypto/CommonCrypto.h>
#import <GoogleAnalytics/GAI.h>
#import <GoogleAnalytics/GAIFields.h>
#import <GoogleAnalytics/GAIDictionaryBuilder.h>
#import <GoogleAnalytics/GAILogger.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "AModel+Level.h"
#import "AModel+AutoStatus.h"
#import "AModel+Settings.h"
#import "APacketData+Decoders.h"
#import "Reachability.h"
When I run the TestApp, it's run perfectly. But I run the unit test cases, I got an error on TestAppTests -> Swift compiler error -> Failed to import bridging header "TestApp-Bridging-Header.h" on #import "GoogleAnalytics/GAI.h" not found.
I fix this issue, using this technique on podfile:
platform :ios, '8.0'
use_frameworks!
target 'TestApp' do
pod 'GoogleAnalytics', '~> 3.14.0'
end
target 'TestAppTests' do
pod 'GoogleAnalytics', '~> 3.14.0'
pod 'Quick'
pod 'Nimble'
end
I just want to know below mention points, when I migrate the code to Swift 3.0.1:
1. Is it require to install every pods in different targets? or we have any alternate solution.
2. What is the best technique to handle this kind of problems?
Please explain the reasons.
As the unit test cases contains different target you must install cocoapods to that target. So what you did about is correct.
platform :ios, '8.0'
use_frameworks!
target 'TestApp' do
pod 'GoogleAnalytics', '~> 3.14.0'
end
target 'TestAppTests' do
pod 'GoogleAnalytics', '~> 3.14.0'
pod 'Quick'
pod 'Nimble'
end
1. Is it require to install every pods in different targets? or we have any alternate solution.
Yes you need to install pods on all different targets.
2. What is the best technique to handle this kind of problems?
This is one of the way most people doing.
But for more complex things if you would like to do then take this Reference.
Adding the specific framework to the test target works for me.
In my case when running unit testing one of the frameworks didn't found by the linker.
After editing my Podfile as follow I were able to run my tests:
target 'MyTarget' do
pod 'somePod'
pod 'somePod2'
target 'MyTargetTests' do
inherit! :search_paths
pod 'somePod2'
end
end

Xcode Unit Testing with Cocoapods

I've been banging my head against a wall with this for the last few days but despite multiple Google/SO/Github searches I can't find a resolution to the issues I'm having!
All I'm trying to do is create some unit tests for my app which makes use of Firebase pods.
I'm using Xcode 7.3.1 & Cocoapods 1.0.1. Update: Issue remains with Xcode 8.0
With this podfile:
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
target 'MyApp' do
pod 'Firebase'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
target 'MyAppTests' do
inherit! :search_paths
end
end
In my XCTest class I get
Missing required module 'Firebase'
error at #testable import MyApp
Alternatively with this podfile:
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
def common_pods
pod 'SwiftyTimer'
pod 'Firebase'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
end
target 'MyApp' do
common_pods
end
target 'MyAppTests' do
common_pods
end
The tests build but my console is littered with warnings e.g.:
Class <-FirebaseClassName-> is implemented in both ...MyApp... and
...MyAppTests... One of the two will be used. Which one is undefined
I had the same issue. I solved it by moving pod 'Firebase' to my test target. Change your Podfile to this:
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
target 'MyApp' do
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
target 'MyAppTests' do
inherit! :search_paths
pod 'Firebase'
end
end
Try changing the inheritance to :complete, as in:
target 'MyAppTests' do
inherit! :complete
end
Importantly it allows anyone else checking out your repo to just do a pod update as usual without having to copy .xcconfig files or other hackery just to build.
Select your Unit Test Target setting.
Go to Build Settings.
Look for Header Search Paths.
Add this value $(SRCROOT)/Pods with recursive, then Xcode will resolve the path for you.
Here is Example
The issue is that Firebase does something special with the Header Search Paths after CocoaPods generates its own value for the setting so CocoaPods doesn't pick up on this change in order to carry it over to the test target. You can solve this one of two ways:
Locate MyAppTests.<configuration>.xcconfig in the file navigator and add the following to HEADER_SEARCH_PATHS:
${PODS_ROOT}/Firebase/Analytics/Sources [*]
Find the setting for Header Search Paths in Build Settings and add that same value as in option 1 to the list. You shouldn't need to set it as recursive.
* As per AKM's comment, this changed to ${PODS_ROOT}/Firebase/Core/Sources in version 3.14.0
Adding ${SRCROOT}/Pods/Firebase/CoreOnly/Sources into the unit test target's "Header search paths" fixed the problem.
Steps:
Select your unit tests target
Go to Build Settings
Search for header search path
Add ${SRCROOT}/Pods/Firebase/CoreOnly/Sources
After this the tests can run and the error will disappear.
Three Steps before I could get this to work:
CocoaPods : 1.5.0
Swift 4
Firebase : 4.13.0
Step 1:
Make sure to add the following target block into your podfile.
# Uncomment the next line to define a global platform for your project
platform :ios, '11.3'
target 'TIMII' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for TIMII
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
target 'TIMIITests' do
inherit! :search_paths
pod 'Firebase/Core'
end
end
Step 2:
Within the YourAppTests Project Navigator Build Settings tab. Find the Header Search Path row and add to Debug the following line
$(inherited) ${PODS_ROOT}/Firebase/Core/Sources
Step 3:
In terminal run:
pod update
A simpler method that also works:
target 'MyApp' do
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
target :MyAppTests
end
The problem is recorded in the firebase project here:
https://github.com/firebase/firebase-ios-sdk/issues/58
There is a workaround:
Add "${PODS_ROOT}/Firebase/Core/Sources" to your Tests target only
under Build Settings -> Header Search Paths
but this is also fixed by upgrading to CocoaPods 1.4.0 or later, which is a better solution.
At the time I'm writing this (November 2017) cocoapods 1.4.0 is still in beta, so to install it you need to explicitly request the beta:
gem install cocoapods --pre
This and then doing a pod install solved the problem running my tests.
I tried all the above and ran into various different errors, originally starting with Missing required module 'Firebase', then getting "Class ... is implemented in both ... " or linker issues if I tried to add Firebase Pods to my test target.
The solution that worked for me was to:
Remove test target entirely from Podfile and run 'pod update' to ensure the XCode project is in sync.
Open my test target's Build Settings and update header search paths to only include the following 3 items:
$(inherited) non-recursive
$(SRCROOT)/Pods/Headers/Public recursive
$(SRCROOT)/Pods/Firebase recursive
At this point cleaning the build folder, re-building then re-running the tests worked for me. Hope this helps someone!
The solution for me was to update cocoapods to version 1.1.0.rc.2.
sudo gem install cocoapods --pre
I had a similar problem. Phrased in terms of your question, I copied the contents of my MyApp.<configuration>.xcconfig file to my MyAppTests.<configuration>.xcconfig file. I cleaned and built the tests, and it worked.
Add "${PODS_ROOT}/Firebase/Core/Sources" to your Tests target only under
Build Settings -> Header Search Paths
As #Will mentioned an issue around Header Search Paths after CocoaPods installation.
I have a project with multiple targets where pod 'Firebase' embedded into separate module, lets say MyProject-Shared. Firebase pod at 'Podfile' installed only for 'MyProject-Shared' target. Other modules, which wants to use 'MyProject-Shared' can't be compiled due an error:
'missing required module "Firebase" '
The trick in my case was to add following missing header search path at each target's Build Settings referencing to Analytics-Framework:
"${PODS_ROOT}/Firebase/CoreOnly/Sources"
Please see pic below:
Hope it will save your time.
Missing required module Firebase NO CocoaPods solution
For those who encounter the same problem but NOT using CocoaPods:
If you're using Firebase, than you have some folder containing Firebase.h and module.modulemap file. For example - YOUR_PROJECT_DIR/Linking
If your Main project target is working correct way, than you should go to ProjectSettings -> Targets. Select test target. Search for User headers and add the path to YOUR_PROJECT_DIR/Linking. Select recursive option and you should be good to go.
See the screenshot for more details:

Firebase framework not found

I've been trying to migrate my project to cocoapods.
I feel like i'm almost there but I'm stuck in:
ld: framework not found Firebase for architecture x86_64
error: linker command failed with exit code 1 (use -v to see invocation)
I'm trying to compile using my "app.xcworkspace" and the project looks like this:
Also:
I've tried starting other projects and firebase works there so it's a problem with THIS project settings... Any idea?
My podfile looks like this:
# Uncomment this line to define a global platform for your project
# platform :ios, ‘8.0’
target 'Parti' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Parti
pod 'Firebase'
pod 'Firebase/Storage'
pod 'Firebase/Auth'
pod 'Firebase/Database'
target 'PartiTests' do
inherit! :search_paths
# Pods for testing
end
target 'PartiUITests' do
inherit! :search_paths
# Pods for testing
end
end
It might be relevant to add that the error happens when xcode tries to "Link /Users/myname/Library/Developer/Xcode/DerivedData/Parti-gsdsljzobcnqjkgutfpjasgrsfck/Build/Products/Debug-iphonesimulator/Parti.app/Parti"
I know it sounds far fetch, but:
Clean the project. Product -> Clean
Restart XCode (not always needed)
Run pod update & pod installfrom the project folder
Update: The Podfile should more like:
use_frameworks!
target 'Parti' do
pod 'Firebase'
pod 'Firebase/Storage'
pod 'Firebase/Auth'
pod 'Firebase/Database'
end
target 'PartiUITests' do
pod 'Firebase'
pod 'Firebase/Storage'
pod 'Firebase/Auth'
pod 'Firebase/Database'
end
Make sure you have added $(inherited) in your Header Search Paths, Framework Search Paths and Library Search Paths for your project target.
Also make sure that in frameworks folder in your project file(Not in your Pods, click on the Project Name in the Project Navigator), the "libPods-YourProjectName.a" is not red. If yes, delete it and build again.
add $PROJECT_DIR/Pods (make it recursive)
to Framework search paths
for whatever reason only this helped me, maybe you too
Just found the answer. Seems like I had an old geofire version and the new one is not available as a Pod yet...
Github Issue link
Thank you for your answers.
Some hints :
Make sure that your Podfile is correct (did you forget to uncomment the use_frameworks! line ? Have you correctly added the pod ?)
Have you forgotten to run "pod install" ?
Have you tried cleaning the project and the build folder ?
Another possibility is your project name is not ASCII. For example, you may have Chinese characters in the name.
In such case, In "general" -> "Frameworks, Libraries, and Embedded Content", remove "Pods___.framework", and add the one with the right name under "Pods/" would help.

COCOAPOD file not found for Xcode unit tests only

I have added PLCrashReporter using POD
use_frameworks!
pod 'PLCrashReporter'
I have imported following files in Briding Header to use in my swift project
#import <CrashReporter/CrashReporter.h>
#import <CrashReporter/PLCrashReport.h>
If I run the project, then I don't get any problem and it works as expected
If I do xcode unit-test I get the following error
(Xcode->Product->Test)
Add the pods separately for Target and TargetTests
Make the following changes in POD file
target ‘Target’ do
platform :ios, ‘8.0’
use_frameworks!
pod 'PLCrashReporter'
end
target 'TargetTests' do
platform :ios, ‘8.0’
use_frameworks!
pod 'PLCrashReporter'
end
Go to the Build Settings of TargetTests
and set the value for “Other Linker Flags” as $(inherited)
Do a POD install then do Clean Build Folder and run

Resources