I have a project who needs firebase for login and ...
So I decided to create a project(Cocoa Touch Framework) inside my workspace to handle all firebase operation.
The firebase framework added to main app via Linked Frameworks and Libraries
I also using cocoa pods
My pod file is something like this:
platform :ios, '10.0'
inhibit_all_warnings!
def firebase
# Firebase
pod 'Firebase/Core'
pod 'FirebaseUI/Auth'
pod 'FirebaseUI/Google'
pod 'FirebaseUI/Facebook'
pod 'FirebaseUI/Phone'
pod 'Firebase/Storage'
pod 'FBSDKLoginKit'
end
target 'RKFirebaseModule' do
use_frameworks!
workspace 'Main'
project 'RKFirebaseModule/RKFirebaseModule.xcodeproj'
firebase
end
target 'App' do
use_frameworks!
workspace 'Main'
project 'App.xcodeproj'
rx_swift
rx_cocoa
end
at this point if I run the app I will get this error:
dyld: Library not loaded: #rpath/Bolts.framework/Bolts
Referenced from: /.../RKFirebaseModule
Reason: image not found
So I tried to solve this problem by adding firebase dependencies to the main app (in pod file):
target 'App' do
use_frameworks!
workspace 'Main'
project 'App.xcodeproj'
rx_swift
rx_cocoa
firebase
end
Now I'm getting bunch of error relating to duplicate implementation of classes like this:
Class FIRAIdentifiers is implemented in both /.../RKFirebaseModule.framework/RKFirebaseModule and /.../App.app/App. One of the two will be used. Which one is undefined.
So how can I solve this problems?
Any help or suggestion will be appreciated. tnx
EDIT 1: Similar cases founds here, but non of the mentioned methods works for me.
1.Duplicate symbols when framework target has a static dependency
2.Duplicate classes warnings at runtime when multiple targets are contained in the same project
EDIT 2: The first problem is normal and it is due to this fact that cocoa pods won't bundle the dependencies into the framework, so I have to use same dependencies for main app.
The second problem caused by some of the firebase static framework, so my framework have a copy of firebase static frameworks and main app has a copy too, so the error is expected here.
I have to remove duplicate static frameworks. HOW?
I had a similar issue when I was using a framework I built and this framework was used in projects that used firebase as well. The workaround I came across was through using cocoapods. I built my framework as a static framework using cocoapods (check .podspec below):
s.static_framework = true
s.dependency 'Firebase'
s.dependency 'Firebase/Core'
The example app i was working on imported my framework via cocoapods as well
use_frameworks!
pod 'gameballSDK', :path => "~/Documents/Libraries/gameballSDK"
Related
I would like to create a framework that is archived and distributed on its own. The problem I'm having is that I would like this library to have cocoa pod dependency libraries compiled into it. Is this possible?
It seems to work. But when I embed the framework in a sample app and invoke code of the embedded dependency I get an error: dyld: Library not loaded:... Reason: image not found
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'MySDK' do
use_frameworks!
pod 'ALBNoSQLDB', '~> 4.2'
end
Do I have to run an archive script to embed the dependent pods? Is this even possible?
Thanks.
I have created framework and using pods pod 'AFNetworking' and same pods used in project also given warning how can i resolved it.
use use_frameworks! in your framework's pod file and you are done.
I am trying to create a Dynamic Framework to share the code among various extensions of my app.
Problem :
Here is my project structure.
MyFrameworks is a network layer of my app which inherently uses Alamofire. So structured my pod file as follow.
platform :ios, '9.0'
use_frameworks!
workspace 'CocoaPodsProjectworkspace'
def shared_pods
pod 'Alamofire'
pod 'SwiftyJSON'
end
target 'CocoaPodsProject' do
project 'CocoaPodsProject.xcodeproj'
# Pods for CocoaPodsProject
end
target 'MyFramework' do
project 'MyFramework/MyFramework.xcodeproj'
shared_pods
end
target 'CocoaPodsProjectTests' do
end
target 'CocoaPodsProjectUITests' do
end
On building the framework when I drag it as embedded binary to my Main project I get the error.
dyld: Library not loaded: .framework/Alamofire Referenced from:
/Users/sandeep/Library/Developer/Xcode/DerivedData/CocoaPodsProjectworkspace-enpobdyluhbxdwazuvbfogcspfof/Build/Products/Debug-iphonesimulator/MyFramework.framework/MyFramework
Reason: image not found
Solutions I tried :
Declaring the pods_frameworks.framework as optional in linked
binaries.
Tried changing RunPath Search path of framework Dynamic Library
Install name Running pod deintegrate and running pod install again.
Deleting derived data and relinking framework all lead to same
problem.
Solution that worked :
I realized that MyFramework.framework was trying to find the Alamofire.framework in a wrong directory and it was alway trying to search relative to project/target using the framework . So the simplest solution that I could find was to modify pod file as follow.
platform :ios, '9.0'
use_frameworks!
workspace 'CocoaPodsProjectworkspace'
def shared_pods
pod 'Alamofire'
pod 'SwiftyJSON'
end
target 'CocoaPodsProject' do
project 'CocoaPodsProject.xcodeproj'
shared_pods
# Pods for CocoaPodsProject
end
target 'MyFramework' do
project 'MyFramework/MyFramework.xcodeproj'
shared_pods
end
target 'CocoaPodsProjectTests' do
end
target 'CocoaPodsProjectUITests' do
end
As you can see I added the shared_pods to both main app and my framework project and their respective targets. Now everything works smooth. I neither had to make pods_framework optional nor had to modify the build settings of MyFramework.
Question:
Adding the shared repos to all the projects and their targets which wants to use my framework looks little redundant. Is there a better way I can specify Myframework.framework to read all its dependencies rather than reading from project using it?
I have raised a issue for the same on CocoaPods Git repo. But because it isn't inherently a issue they might not revert back. Hence posting it as a question here.Link to issue : https://github.com/CocoaPods/CocoaPods/issues/6901 if it helps.
Solved it by creating a cocoa pod for my custom Framework and using cocoa pods dependency .
Step 1 : Clean the Main/Parent project
Removed MyFramework from the project (which was added as sub
project) and remove MyFramework.framework added in embedded library of projects General settings.
Run pod deintegrate (to de-integrate the pod already added to
project)
Now that the project is clean and does not have any pod added
initialized the pod by running pod init
Step 2: Create a Pod for my Framework
Using cd command navigate to MyFramework project and once you are in
MyFramework's root folder run pod spec create MyFramework
This will create a file named MyFramework.podspec in the
MyFramework's root folder. Open MyFramework.podspec using any of the
editor tool and update it as shown in tutorial https://www.raywenderlich.com/126365/ios-frameworks-tutorial
Most important step which is not there in this tutorial is how to add
cocoa pods dependency that our framework needs to build. Turns out
thats the most easiest part. In my case I needed SwiftyJSON and
Alamofire so in .podspec file I added,
s.dependency 'Alamofire'
s.dependency 'SwiftyJSON'
Step 3:
Now open the Main/Parent projects Podfile and update it as shown
below.
target 'CocoaPodsProject' do
use_frameworks!
pod 'TestFramework', :path => 'TestFramework/'
end
What it did is, it tells main project to add TestFramework as dependency and installs TestFramework in Framework folder of main project. Because TestFramework in itself has dependency to Alamofire & SwiftyJSON when you run pod install it will not only install Alamofire but also installs SwiftyJSON and adds it to TestFramework's Framework folder.
Thats all. Now your TestFramework can access Alamofire and SwiftyJSON and Main/Patent project can access TestFramework
If you want to now update TestFramework code, till u finish develop add it as subproject to Main project (This is necessary because if you open TestFramework.xcproj u won't see Alamofire/Swifty JSON. You have to open the Parent project's workspace itself hence this solution). Once u are done with development if u decide to remove the TestFramework as subproject u can do that :)
Finally If you decide to add additional extensions to app, Lets say u add Today extension all u have to do is to modify ur Podfile as follow.
target 'CocoaPodsProject' do
use_frameworks!
pod 'TestFramework', :path => 'TestFramework/'
end
target 'CocoapodsToday' do
use_frameworks!
pod 'TestFramework', :path => 'TestFramework/'
end
Woo hooo :) Now add your frameworks to as many extensions you want :) Hope it helps.
I seem to have a issue with my project settings, in Xcode 8. The issue is as follows:
When adding a new Pod - lets say, Pod Firebase - the install works, and adds the necessary files to my project. I can then, do #Import Firebase
All is fine, up to this point. However, as soon as I make a reference to the Firebase API example: [FirApp configure]; - all is still fine - autocomplete on Xcode works as expected and no issues. However, when building I then get a compile time issue which states:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRAppIndexing", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The only way I am able to solve this - is by manually adding the _FIRAppIndexing.framework in my projects, Build settings, under Link Libraries with Libraries
To do that, I just drag and drop the frame work from the project navigator to the correct section under link libraries.
This works sometimes; as with other parts of the Firebase SDK, I get runtime crashes.
So, to try get to the root cause, I created a brand new test project, installed the Pods using Pod install - I however did not have to add the framework manually to Libraries - its actually not even listed there.
Everything in the test project worked just fine, at compile and run time.
Which leads me to believe its something in my project settings that's causing this.
Things I have tried
Removed cocoapods completely with pod deintegrate and removed all
other traces of it. Then did a clean build. Then Pod install
Added -objc to linker flag
Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
# Pods for MyApp
pod 'Crashlytics'
pod 'AsyncDisplayKit', '>= 2.0'
pod 'Firebase'
pod 'Firebase/Messaging'
pod 'FBSDKCoreKit'
pod "HockeySDK", :subspecs => ['AllFeaturesLib']
pod 'Fabric'
pod 'FirebaseAppIndexing'
pod 'AFNetworking', '~> 3.0'
pod '1PasswordExtension', '~> 1.8.4'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
end
GitHub example project
https://github.com/TanderZA/MyApp
I duplicated my current project - and removed all files. Problem still exists. You will see the project won't compile due to linker errors, with references to the Firebase AP.
By manually adding the frameworks to Link Libraries with Libraries, you will see that it should compile. But that is not how it should work. The current project has an issue with infoPlist.strings that I did not solve. But the project is in the state to demonstrate the issue.
I have checked the project, it seems you have messed up with schemes.
Create a new scheme properly then install the pods again and as the project is in Obj-C you don't need to enable frameworks in the podfile.
So comment like # use_frameworks!
Also update the pods using pod update
Then select the new scheme and build the project in it.
Let me know if you are not able to do it.
It is a xcode bug by the way
But try this :
Upgrade to latest version of xcode and Pods
Remove all architectures in your project
Clean your project
Add arcitectures from start.
This should resolve the issue.
Have you tried to use frameworks?
# platform :ios, '10.0'
use_frameworks!
target 'MyApp' do
I am not sure though but I think what you need is pod 'Firebase/Core'. not pod 'Firebase'.
This link have the list of the Firebase framework that can be used.
And, in the video on the top of the page it says something about there is no single pod that can be installed and you need to set each one of them on the podfile depending on the features you want.
My guess they mislead us in some places where they had pod 'Firebase'. I dont think that they meant that it should do the work.
som try the following:
# Pods for MyApp
pod 'Firebase/Core'
pod 'Firebase/Messaging'
.
.
I know that you said that you had it work on another new project.
I'm creating a new Cocoa Touch Framework (MyFramework.framework), which will have a dependency on Alamofire. This framework will be written in Swift. As a test I started a new Cocoa Touch Framework project:
File > New > Project > Framework & Library > Cocoa Touch Framework
Then, in the terminal I performed:
pod init
under this projects directory. In the newly created Podfile I added the following:
source 'https://github.com/CocoaPods/Specs.git'
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
pod 'Alamofire', '~> 3.0'
Once again, in the Terminal I performed:
pod install
and started coding away.
Everything seemed well and good till I used the MyFramework.framework Product in a Single View Project. When I attempt to run the project I get the following issue:
dyld: Library not loaded: #rpath/Alamofire.framework/Alamofire
Referenced from: /Users/me/Library/Developer/CoreSimulator/Devices/87DA70B6-49BF-441E-BD81-F4A80B0792CF/data/Containers/Bundle/Application/2E414EA8-7E54-4D71-9295-566D4FAAADE2/test.app/Frameworks/MyFramework.framework/MyFramework
Reason: image not found
I thought that Cocoa Touch Framework projects were inherently Dynamic, and therefore would include all dependencies.
Can anyone tell me why this is happening and how I may be able to fix it?
Is this an issue with CocoaPods or am I missing something?
I'm a noob to Stack Overflow so please let me know if you need more information from me.
Thanks!
Unfortunately CocoaPods doesn't support use with Cocoa Touch Framework target. I found a few references to this while digging through their issues on GitHub:
We don't really support integrating Pods into framework targets...
-neonichu on Nov 4, 2015
and
...in order for this to "just work", CP would need to do a recursive analysis of dependencies in your Xcode project and also somehow ensure that you would never use the build product in another context.
-neonichu on Jul 7, 2015
So far I've found two ways to deal with the issue:
The right way is to create a new pod spec for your framework and bring it in to your main project via CocoaPods. This resolves all of the problems CococaPods has with the dependency graph and is the recommended solution from the CocoaPods developers.
The easy way is to include the pods from your framework in your main project. This seems to work, but frankly I don't know why. This is the Podfile from my test project:
platform :ios, '9.0'
use_frameworks!
def myfirstframework_pods
pod 'Alamofire', '~> 3.0'
end
target 'MyApp' do
pod 'SwiftKeychainWrapper', '~>1.0'
myfirstframework_pods
end
target 'MyFirstFramework' do
myfirstframework_pods
end
Try adding the dependency on Alamofire in the framework's podspec as below
Pod::Spec.new do |s|
# Other setup
# Dependencies
s.dependency "Alamofire"
# Other dependencies if any