I currently have 2 deployable frameworks. Same app, two faces: Client and Vendor.
Most of the data-model classes and some views are completely identical. So I've created another framework named "Common". I had no problem using Common as a dependency for Client and Vendor frameworks until Firebase and Crashlytics appeared.
I have some code that again, would be identical in both frameworks. So Common is the way I wanted to go. But, when using Cocoapods, there will be two definitions of those libraries, Xcode log says Class <<SomeFirebaseClass>> is implemented in both <<LONG CLIENT PATH>> and <<LONG COMMON PATH>>. One of the two will be used. Which one is undefined. and this issue occurs.
My Pod File:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
workspace 'Application'
use_frameworks!
# ignore all warnings from all pods
inhibit_all_warnings!
abstract_target 'CommonPods' do
pod 'ChameleonFramework/Swift'
pod 'Fabric'
pod 'Crashlytics'
pod 'Alamofire', '~> 4.5'
pod 'SwiftyJSON'
pod 'Firebase/Core'
pod 'Firebase/Auth'
target 'Attendant' do
project 'Attendant/Attendant'
end
target 'Client' do
project 'Client/Client'
end
end
I've found some issues in the CocoaPods's repository somehow related but no fix so far.
My question here is: How can I accomplish this? And if I can't, what is the best way to achieve something close to this?
Related
I have Main Project A and multiple customFramework B ,C etc. In that Main Project A I have All Pod and I need to share the same pod to customFramework B ,C etc. how should I implement the same pod to multiple customFramework?
I don't want to implement a pod for a particular customFramework, I want to use the same pod of the Main Project.
how to implement this? Can anyone help me out? and is it possible?
You can put common pods in outside specific targets in your Podfile:
use_frameworks!
inhibit_all_warnings!
pod 'Firebase' # will be included in all targets
target 'MainProject' do
pod 'Alamofire' # included only in MainProject
end
target 'FrameworkB' do
pod 'PhoneNumberKit' # included only in FrameworkB
end
I am writing an iOS app, using CocoaPods 1.6.0 as my dependency manager. My project consists of a iOS app project (myapp-ui), as well as 3 iOS framework projects (myapp-common, myapp-model, and myapp-editor). I'm also leveraging Fabric.io for crash reporting and app metrics. My myapp-ui and myapp-model projects both make use of the Fabric and Crashlytics frameworks. My Pods file looks like this:
platform :ios, '11.0'
workspace 'MyApp.xcworkspace'
project 'myapp-ui/myapp-ui.xcodeproj'
project 'myapp-common/myapp-common.xcodeproj'
project 'myapp-model/myapp-model.xcodeproj'
project 'myapp-editor/myapp-editor.xcodeproj'
target 'myapp-ui' do
use_frameworks!
project 'myapp-ui/myapp-ui.xcodeproj'
# Pods for myapp-ui
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'Fabric'
pod 'Crashlytics'
pod 'KeychainSwift', '~> 13.0'
target 'myapp-uiTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'myapp-common' do
use_frameworks!
project 'myapp-common/myapp-common.xcodeproj'
# Pods for myapp-common
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'KeychainSwift', '~> 13.0'
end
target 'myapp-model' do
use_frameworks!
project 'myapp-model/myapp-model.xcodeproj'
# Pods for myapp-model
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'Fabric'
pod 'Crashlytics'
end
target 'myapp-editor' do
use_frameworks!
project 'myapp-editor/myapp-editor.xcodeproj'
# Pods for myapp-editor
end
The pods install just fine, and my app builds with no issue. However, when I run it I see a large number of errors in the console that look something like this:
objc[62607]: Class CLSInternalReport is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252f960) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f2831e8). One of the two will be used. Which one is undefined.
objc[62607]: Class Crashlytics is implemented in both <SOME LOCATION>/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252f9b0) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283238). One of the two will be used. Which one is undefined.
objc[62607]: Class CLSFileManager is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252fa00) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283288). One of the two will be used. Which one is undefined.
objc[62607]: Class CLSAlert is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252fa78) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283300). One of the two will be used. Which one is undefined.
Is there a way to address these warnings? I've tried removing them from myapp-ui thinking that myapp-ui makes use of myapp-model (and would therefore inherit the dependency) but that didn't work. I'm at a loss as to how to address this. Thoughts?
I was getting the same warnings you're seeing and took me a while to find a fix. Turns out this happens when you have a dependency that comes pre-compiled, like Fabric and Crashlytics. I think it's because they are copied twice.
What I did was to add those pods only to the app target. My Podfile ended up looking somewhat like this
def pods
pod 'CGMath'
...
end
def app
pod 'Crashlytics'
pod 'Fabric'
end
target 'FrameworkTarget' do
pods
end
target 'AppTarget' do
pods
app
end
I built 2 swift projects. Both use CocoaPod, so these projects are workspaces.
The first one is like a framework with a lot of Classes I use in the second one.
I don't succeed in this importation:
I followed those steps from the Apple Docs , but any Classes from my Framework (1st project) are recognized... I have 80 error like this :
Use of undeclared type < MyFrameworkClass >
I know two options for setting up a workspace with multiple pods.
You can create a single podfile for both projects. As you can imagine, it will create a single workspace where your two projects (app and framework) will be at (let's cocoapods take care of the entire workspace).
The pod file will look like this:
platform :ios, '8.0'
use_frameworks!
workspace 'WorkspaceName’
xcodeproj ‘FolderOfApp/Project.xcodeproj'
xcodeproj ‘FolderOfApp/App.xcodeproj'
target :ApptTarget do
xcodeproj 'FolderOfApp/App.xcodeproj'
pod ‘MyAppPod’
end
target :FrameworkTarget do
xcodeproj 'FolderOfFramework/Framework.xcodeproj
pod ‘MyFrameworkPod’
end
You will probably need to add the "MyFrameworkPod" to the AppTarget too, and this bring some warnings that I still couldn't solve.
Anyway, you have another option that I was using before. Create and execute the two pod files as you are doing now, create another workspace, add the two projects and the two pods (separate them with folders). DONT ADD THE WORKSPACES, just the projects.
With this approach I had a feel problems like the app not finding the frameworks dependencies, but I solved adding the framework search path.
Swift 5 Very easy solution in your POD File
in your directory : touch Podfile (file will create in workspace)
# platform :ios, '10.0'
use_frameworks!
workspace 'TestWorkSpace'
xcodeproj 'Project1/Project1.xcodeproj'
xcodeproj 'Project2/Project2.xcodeproj'
target 'Project1' do
xcodeproj 'Project1/Project1.xcodeproj'
#Pods for Project1
pod 'SwiftyJSON', '~> 4.0'
end
target 'Project2' do
xcodeproj 'Project2/Project2.xcodeproj'
#Pods for Project2
pod 'SwiftyJSON', '~> 4.0'
end
I use several pods in my Xcode project, all work perfectly well except SimpleAuth
Here is my code in my podfile:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, ‘8.0’
pod 'SWRevealViewController', '~> 2.3'
pod 'SAMCache'
source 'https://github.com/calebd/SimpleAuth'
use_frameworks!
pod 'SimpleAuth/Instagram'
Then, I install my pod using my terminal targeting my project folder. And as you can see, the "SimpleAuth" folder created in my project is empty when it should include all the objective-c classes that it needs to operate:
Any help by more experience objective-c coders much appreciated.
why are you using two ways. instead use simple
podflie
use_frameworks!
platform :ios, ‘8.0’
pod 'SWRevealViewController', '~> 2.3'
pod 'SAMCache'
pod 'SimpleAuth/Instagram'
there is no need of mentioning source path. Cocoapods will do it automatically.
It is not used because if sometime in future if it change then you will have a problem.
I want to have a Workspace that contains two projects (2 different apps), a Common (shared) project and a couple of Pods.
I have been struggling to get the App1 project to "see" the Common classes.
My thinking was:
Create the workspace
Create the two app projects (App1 and App2)
Create the Common project
Create Podfile
The Podfile I have is along the lines of this:
workspace 'MyApps'
xcodeproj 'App1/App1.xcodeproj'
xcodeproj 'App2/App2.xcodeproj'
xcodeproj 'Common/Common.xcodeproj'
target :App1 do
platform :ios, '6.0'
pod 'AFNetworking', '~> 1.3.2'
xcodeproj 'App1/App1.xcodeproj'
end
target :App2 do
platform :ios, '6.0'
pod 'AFNetworking', '~> 1.3.2'
xcodeproj 'App2/App2.xcodeproj'
end
target :Common do
platform :ios, '6.0'
pod 'AFNetworking', '~> 1.3.2'
xcodeproj 'Common/Common.xcodeproj'
end
I have seen this question but I can't seem to get the Common code to be available in the Apps.
Do I have to manually update the search paths for each of the Apps projects to make it work or can this be solved via the Podfile?
i had a similar problem at work, and i found it was better to change the project structure to work with Cocoapods.
i think the right solution for you, or at least the right path to one, is to turn your common project into a local (see "Using the files from a local path" here), private pod.
i implemented my common project as such, and have my Application project also configured with CocoaPods, using that private pod.
a final word of note, when building a common library project through CocoaPods, you'll want to override the 'Other Linker Flags' build setting in that project, just like it is in the Pods project created and managed by CocoaPods.
¡let me know if this works for you!
I have just posted an answer on this topic in the context of multiple targets - should apply to multiple projects to: Multiple targets depending on same cocoapods