Our code structure is as follows,
We have a Framework A for iOS , which Application going to link and embed as a link as a binary inside Xcode,
Framework A pod file is
target 'iosFramework' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
# Pods for iosFramework
pod 'Firebase'
end
Now in the 'Application' where i am going to include 'iosFramework' i am getting error "FirebaseInstanceId" cannot be found,
Any help,
Basically i wanted to know, Is this correct way to make use of pod ?
What should be ideal practice if the code structure is something like this,
I am on Xcode 7.3 and pod 1.0.1
Related
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"
I'm creating a static library in iOS using Objective-C. This library will gather data from the app where this library is integrated, the gathered data from the app will be sent to the server.
I'm just wondering if is it possible to embed a cocoa pods framework in my library like AFNetworking?
Thanks in advance
Yes. It seems to be possible.
I created a static library project and tried to integrate cocoapods in to it with below steps.
pod init
Then edited the podfile to integrate AFNetworking pod in the project like below
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Testing' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'AFNetworking', '~> 3.0'
# Pods for Testing
end
then gave
pod install
I get the below warning
[!] The Podfile contains framework or static library targets
(Testing), for which the Podfile does not contain host targets
(targets which embed the framework). If this project is for doing
framework development, you can ignore this message. Otherwise, add a
target to the Podfile that embeds these frameworks to make this
message go away (e.g. a test target).
As the first line in the warning says we are doing framework development, hence we can ignore this message and it should work fine.
Also my suggestion is to use Alamofire instead of AFNetworking as Alamofire is swift based and AFNetworking is objective-c based.
I am doing Objective-C in iOS app. But the problem is I want to add few Objective-C apis into that I added successfully earlier with cocoa pods, But, now I want to add Swift Api through cocoa pods, but the problem getting while installing is following.
[!] Pods written in Swift can only be integrated as frameworks; add use_frameworks! to your Podfile or target to opt into using it. The Swift Pods being used are: apis
But I can't add this manually due to its large api and it contains sub folders.
But, if I remove "#" key from use_frameworks!, its getting installed, but, the old Objective-C apis getting file not found in my project.
Even I have very basic knowledge at installing frameworks/apis through cocoa pods.
Can any one suggest me how to over come this.
use_frameworks! will work with Objective-C pod only if they are dynamic frameworks not static libraries. Most of the popular third party libraries are using dynamic frameworks like AFNetworking, GoogleMaps etc.
Make sure all your Objective-C pods are dynamic frameworks. If you are not sure just create a sample project with cocoapods and use use_frameworks!. Try adding one by one, all the pods and find out which one is the culprit.
I had that problem once, what I did was use use_frameworks! like you mentioned, and then I changed how the Objective-C imports are written.
The command use_frameworks! turns each pod into a Framework, so in your projects the .h and .m files are no longer visible to the import like they would usually.
As a result, instead of using for example #import <AFNetworking/AFNetworking.h>, you do #import AFNetworking;
From my own experience, and maybe it was just a special case for my project. But turning everything into frameworks slowed down the compile time on Xcode and it made my App Package bigger for some reason.
Podfile file:
platform :ios, '10.0'
use_frameworks!
def pods
pod 'Alamofire', '= 4.4'
pod 'SwiftyJSON' '= 3.1.4'
pod 'MBProgressHUD'
end
target 'YourProject' do
pods
end
YourProject-Bridging-Header.h
#import <MBProgressHUD/MBProgressHUD.h>
Build Settings
Perhaps this is a n00b question but I'm going to ask it anyways. I followed the instructions for adding Firebase to a Swift app via CocoaPods. Everything seems to have worked fine. Here is my Podfile:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'FirebaseDemo2' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for FirebaseDemo2
pod 'Firebase'
end
When trying to import the Firebase module into the AppDelegate, at first Xcode complains it cannot find it but the project builds just fine. However, when trying to add the FIRApp it then fails to build because it cannot find the class.
The Podfile is in the same directory as the .xcodeproj and I am opening the .xcworkspace file in Xcode. This is really confusing me. Can someone see what I am doing wrong? Is CocoaPods misconfigured?
I had the same problem, it installed 2.5.1 but you need 3.2.0
Try running
pod update Firebase
You should now have Firebase 3.2.0
I think your Podfile should look like this:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
use_frameworks!
target 'FirebaseDemo2' do
pod 'Firebase'
end
Make sure to open the Xcodeworkspace and not the Project
I created an iOS framework that uses a library (RestKit) via CocoaPods.
In the application project that uses my framework I also use CocoaPods to include other libraries. I had to include the library from the framework as the project didn't compile otherwise.
Everything works fine, but as expected when I launch the application I get:
Class X is implemented in both /private/var/mobile/Containers/Bundle/Application/[...]/Application.app/Frameworks/Framework.framework/Framework and /private/var/mobile/Containers/Bundle/Application/[...]/Application.app/Application. One of the two will be used. Which one is undefined." in several classes from the libraries.
Is there any way in CocoaPods or in the build process to prevent having duplicate libraries when they're already being used?
Some more context to my question. Here's what I did:
Created a framework project as a Cocoa Touch Framework. Initially I added just a Podfile with a dependency for RestKit as following:
pod 'RestKit', '~>0.23'Then I removed the Podfile and just added a podspec as in the comment by #Paula ChavarrÃa.
Created the app project. Added a Podfile with other dependencies and also the dependency to the framework as #Paula ChavarrÃa also mentioned.
When I build the app project the framework fails building because it can't find the right headers.
I changed the header search path for the framework but it doesn't seem to be enough for the build to be successful.
Do I need to have also a Podfile in the framework? As I said in my original question, I did that at first and I ended up having duplicate libraries and that's what I'm trying to avoid in the first place.
Is there any way to tweak the Podfile or the configurations generated by it and use the headers in the app and link with the libraries in the app?
What am I missing here?... Thanks in advance! :)
If you are using Cocoapods on the application project you can create a private pod for the iOS framework. To do so you have to create a .podspec file in order to add the conflicting dependency. For Restkit the .podspec file would be like this:
Pod::Spec.new do |s|
s.name = "MyFramework"
...
s.dependency 'RestKit', '~> 0.23'
end
You can read more about these files here: http://guides.cocoapods.org/making/specs-and-specs-repo.html
After that you just have to add a dependency of your framework on the application project Podfile. You can do so through a local path or through a version control system.
pod 'MyFramework', :path => './../my-framework'
pod 'MyFramework', :git => 'https://url/to/my-framework.git', :tag => '0.0.1'