no such module 'Firebase' in Xcode (Swift) - ios

I have been looking up on every website that had a similar/identical issue to this Xcode error and I have tried everything and nothing has worked. Most people say cleaning and building the project will make Firebase recognized but that hasn't worked. I've tried a bunch of different framework search paths but each framework is in a different folder, not one framework folder. This is my podfile:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'Target' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Target
target 'TargetTests' do
inherit! :search_paths
pod 'Firebase', '>= 2.5.0'
# Pods for testing
end
end
these are my project folders
i've tried making my framework search path $(SRCROOT) and all variations and nothing works. My issue seems to be unlike any other that I can find from googling. I suspect its the framework search path but i don't know what to make it, and I could be wrong.
Any help would be greatly appreciated.

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Promposal
target 'Promposal' do
pod 'Firebase', '>= 2.5.0'
# Pods for testing
target 'PromposalTests' do
inherit! :search_paths
pod 'Firebase', '>= 2.5.0'
end
end
You were writing your podfile properly and you were adding the Firebase only to the test. Try this podfile and check.

It was good for me:
platform :ios, '10.0'
use_frameworks!
def shared_pods
pod 'Firebase'
end
target 'TargetName' do
shared_pods
end
target 'TargetNameDev' do
shared_pods
end

Related

Single cartfile to specify and install dependencies for multiple targets

Is there a way to write a single cartfile which can be used to install the dependencies required for multiple targets. This can be achieved when we're using Cocoapods as shown below:
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
def rx_swift
pod 'RxSwift', '~> 4.0'
end
def rx_cocoa
pod 'RxCocoa', '~> 4.0'
end
def test_pods
pod 'RxTest'
pod 'RxBlocking'
pod 'Nimble'
end
target 'CleanArchitectureRxSwift' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
rx_cocoa
rx_swift
pod 'QueryKit'
target 'CleanArchitectureRxSwiftTests' do
inherit! :search_paths
test_pods
end
end
target 'CoreDataPlatform' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
rx_swift
pod 'QueryKit'
target 'CoreDataPlatformTests' do
inherit! :search_paths
test_pods
end
end
target 'Domain' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
rx_swift
target 'DomainTests' do
inherit! :search_paths
test_pods
end
end
target 'NetworkPlatform' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
rx_swift
pod 'Alamofire'
pod 'RxAlamofire'
target 'NetworkPlatformTests' do
inherit! :search_paths
test_pods
end
end
target 'RealmPlatform' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
rx_swift
pod 'RxRealm', '~> 0.7.1'
pod 'QueryKit'
pod 'RealmSwift', '~> 3.10'
pod 'Realm', '~> 3.10'
target 'RealmPlatformTests' do
inherit! :search_paths
test_pods
end
end
Please let me know whether can we achieve similar thing while using Carthage? i.e. by writing all the dependencies needed for all targets in a single cartfile and then installing them using carthage?
Why I want to do this is, I feel that as we go on adding dependencies to different targets(frameworks) used in the application, it'd be easy to maintain if we have all the dependencies listed in a single cartfile.
Thanks in advance.
It's not possible to do this in Carthage, and will probably never be supported.
You could list all the dependencies in a single Cartfile, but you'll still have to manually select and add them to your target's linked frameworks and libraries.

Unable to install Firebase into my Xcode project via cocoapods

I am trying to import Firebase into my Xcode file via Cocoapods 1.1.1. My pod file looks something like this.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Firebase Login' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Firebase Login
pod 'Firebase', '~> 3.11'
target 'Firebase LoginTests' do
inherit! :search_paths
pod 'Firebase'
end
target 'Firebase LoginUITests' do
inherit! :search_paths
# Pods for testing
end
end
I also tried this.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Firebase Login' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Firebase Login
target 'Firebase LoginTests' do
inherit! :search_paths
pod 'Firebase'
end
target 'Firebase LoginUITests' do
inherit! :search_paths
# Pods for testing
end
end
Afterwards, I typed pod install in my terminal and this is what I got.
Analyzing dependencies
[!] Unable to find a specification for `FirebaseAnalytics (= 3.6.0)` depended upon by `Firebase/Core`
Is this something I have done wrong or is it a bug with Firebase itself? If it's me, I would appreciate it if someone can help me solve this problem.
You should add those pods before target 'Firebase LoginTests' do
Otherwise you will only include them your test target.
your podfiel should look like this
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'AppName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for AppName
pod 'Firebase'
pod 'Firebase/Auth'
pod 'Firebase/Database'
target 'AppName' do
inherit! :search_paths
# Pods for testing
end
target 'AppName' do
inherit! :search_paths
# Pods for testing
end
end

The bundle UITests couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle

I can't run my test case due to this following errors :
The bundle “UITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
Library not loaded: #rpath/Alamofire.framework/Alamofire.
Reason: image not found
Try searching and solving since two days but couldn't get through this issue can someone please help.
I was able to reproduce this issue with the project generated by Xcode 10.1. I used Swift 4.2 and CocoaPods 1.10.0 as a dependency manager. I had the following Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
pod 'Alamofire', '4.8.1'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
Then I removed use_frameworks!, see this link for more details:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'MyApp' do
# Pods for MyApp
pod 'Alamofire', '4.8.1'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
I also received some warnings like this:
[!] The `MyAppUITests [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-MyApp-MyAppUITests/Pods-MyApp-MyAppUITests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
That's why I removed this line from the MyAppUITests build settings:
After that run pod deintegrate && pod install and then the problem disappeared.
Probably for projects with more dependencies (like here) you need to use another solution.
It's because your pods only apply to your Framework target and no the tests one. Add the tests target to your podfile.
Example :
target 'MyFramework' do
use_frameworks!
pod 'Alamofire', '~> 4.5'
end
target 'MyFrameworkTests' do
use_frameworks!
pod 'Alamofire', '~> 4.5'
end
In your tests target change inherit! :search_paths to inherit! :complete.
See the documentation for what this does.
Check that the deployment target in your UITest target Build Settings is set to the same as the host application you are trying to test. In my case, I added the UITesting target later on, and it created it with a default of deployment target iOS 12. If you then try to run the UITest on iOS lower than 12, it gave me the error mentioned in the question.
In my case, I needed to separate the UI tests target with use_frameworks!.
Moving the UI tests target from nested structure to its own will not help, if you specified use_frameworks! globally somewhere in the top of the Podfile.
The Podfile with error (original):
platform :ios, '10.0'
inhibit_all_warnings!
use_frameworks!
target 'MyProject' do
pod 'R.swift', '~> 5.0'
pod 'Moya/RxSwift', '~> 12.0'
# and other pods
target 'MyProjectTests' do
inherit! :search_paths
pod 'iOSSnapshotTestCase', '~> 6.0'
end
target 'MyProjectUITests' do
inherit! :search_paths
end
end
The Podfile with error (first try to fix):
platform :ios, '10.0'
inhibit_all_warnings!
use_frameworks!
def shared_pods
pod 'R.swift', '~> 5.0'
end
target 'MyProject' do
shared_pods
pod 'Moya/RxSwift', '~> 12.0'
# and other pods
target 'MyProjectTests' do
inherit! :search_paths
pod 'iOSSnapshotTestCase', '~> 6.0'
end
end
target 'MyProjectUITests' do
shared_pods
end
The final working Podfile:
platform :ios, '10.0'
inhibit_all_warnings!
def shared_pods
pod 'R.swift', '~> 5.0'
end
target 'MyProject' do
use_frameworks!
shared_pods
pod 'Moya/RxSwift', '~> 12.0'
# and other pods
target 'MyProjectTests' do
inherit! :search_paths
pod 'iOSSnapshotTestCase', '~> 6.0'
end
end
target 'MyProjectUITests' do
shared_pods
end
I had to add the location of my frameworks to Runpath search Path under targets>mytestTarget>Build Settings>Runpath Search Path
This error happened to me when I added a framework to the project (that's a framework itself, too), and tried to run the tests. I made it optional instead of required, and the tests succeeded.
Switching to legacy build system fixed thi issue with Xcode 10.
For anyone encountering this issue using Carthage, I solved it by adding the /usr/local/bin/carthage copy-frameworks run script phase to the UITest target (rather than just my main app target), and added the framework as an input file.
The bundle UITests couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle
I have run on this problem when tried to run UI Testing Bundle for testing a Framework
The solution is simple:
Build Phases -> + -> New Copy Files Phase -> <select a framework> -> Destination Frameworks
As a result <UI_Testing_Bundle_name>-Runner.app is generated
]3
Go To Build Phases
Open Copy Pods Resources and copy the path
Paste the path that you have copied from Copy Pods Resources and change tag name resources with frameworks
Clean and Build
Run your UITestsFile
What solved my problem was following the following steps:
1) delete the UITests target from the pod file.
Initially, I had the following in the pod file:
target 'XUITests' do
inherit! :search_paths
end
2) Deintegrate the pods (with pod deintegrate)
3) Install the pods (with pod install)
4) Clean your project and run the project or your UITest
In my case, just removing inherit! :search_paths without changing the structure of the file or duplicating any pod fixed my problem.
I saw the answer but without an explanation so decided to post mine.
The issue is that UI tests performed in a separate application that controls the main one and so it can't use the main application's frameworks and so if you just inherit paths to frameworks using Cocoapods UI tests app will crash at the startup.
To fix the issue you need to actually copy frameworks to UI tests app or update your Podfile:
use_frameworks!
target 'App' do
pod 'Alamofire'
target 'App_UnitTests' do
inherit! :search_paths
pod 'Quick'
pod 'Nimble'
end
end
target 'App_UITests' do
pod 'Alamofire'
end
Xcode 11.2 using Apollo framework within another framework. Instead of changing to optional/required, I fixed it by setting to embed.
With this specific error:
The bundle “XXX” couldn’t be loaded because it is damaged or missing
necessary resources. Try reinstalling the bundle. Library not loaded:
#rpath/Apollo.framework/Apollo
I had to embed the framework
For me, the error was when build the UITests.
The solution:
The Targer was with a wrong iOS version, I replace with the same version that the tested Target and everything works!!
For me, this problem was caused by me referencing a property from an extension on a UIKit class from a framework which wasn't imported in the file where it was referenced. Fixed by not using that property. I'm not sure why it compiled in the first place - that should have been a compile-time error, not a runtime error.
In my case simply choosing "My Mac" instead of "My Mac (Mac Catalyst)" allowed me to run the tests.
Try copy every pod for your app target to the UI testing target.
2019 it works.
If you are in fact using Cocoapods, you probably just need to run "pod install" and the build settings will be updated automatically.

No such module 'Alamofire' in XCode 7.3 & Swift 2.2

I am integrating Almofire via cocoapods in my new swift project. After successful installation of Alamofire pod, i am unable to import it in my swift file. Xcode shows following error.
No such module 'Alamofire'
Following is my Podfile for reference
source 'https://github.com/CocoaPods/Specs.git'
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'CoreDataSample' do
pod 'Alamofire', '~> '3.4'
end
target 'CoreDataSampleUITests' do
end
I have already referred following issues in Almofire on github
Issue #551
Issue #1130
Also tried following things
Project clean
Project Build
Removed Derived Data
Any advise would be appreciate.
Try this inside your pod file
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'demoAlamofire' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for demoAlamofire
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire'
target 'demoAlamofireTests' do
inherit! :search_paths
# Pods for testing
end
target 'demoAlamofireUITests' do
inherit! :search_paths
# Pods for testing
end
end
I hope this will help you.

Cocoapods can't find header xcode 6

I have a problem xcode can't find the headers of my pods in my wokspace.
The headers search path for the target seems ok
Here is the content of my podfile
target "MyApp" do
pod 'AFNetworking', '~> 2.0'
pod 'Reachability'
pod 'ViewDeck', '2.2.11'
pod 'MBProgressHUD', '~> 0.8'
end
But when i build the project i have this error in the prefix.pch
/Users/...../MyApp-Prefix.pch:17:13: 'AFNetworking.h' file not found
I have tried to add platform :ios, "8.0" in my podfile and do a pod update but still no luck
I have also tried to add $(inherited) like suggested in the SO question :
Xcode 6 doesn´t find cocoapods libraries
I'm using xcode 6 on mavericks
I found solution. In your project properties replace this:
You might also want to link your pods with both your targets like so:
platform :osx, '10.7'
link_with 'MyApp', 'MyApp Tests'
pod 'AFNetworking', '~> 1.0'
pod 'Objection', '0.9'
From Cocoapods docs and this answer
Update: This no longer works for Cocoapods 1.0+, the correct way to implement the Podfile is:
platform :ios, '9.0'
inhibit_all_warnings!
target 'MyApp' do
pod 'ObjectiveSugar', '~> 0.5'
target "MyAppTests" do
inherit! :search_paths
pod 'OCMock', '~> 2.0.1'
end
end
Source: https://guides.cocoapods.org/syntax/podfile.html#podfile
I was able to fix this in my project. I had a second target for tests. I never used this target and the error disappeared after I deleted it from the project. So maybe not your main target is the source of the problem, but another one.
I agree with jwswart's answer because quite many times I have realized that the issue with just defining dependencies for the 'MyApp' and leaving out 'MyAppTests' as in:
target :'MyApp' do
..
end
breaks the build process because the classes defined in 'MyApp' make use of the dependencies which are not visible in the 'MyAppTests'. Thus as jwswart suggested:
link_with 'MyApp', 'MyApp Tests'
Just have a try to comment this line for your target
# use_frameworks!
~~

Resources