i am developing Framework, i have added this framework project into host project. now i want to add cocoapods pod(framework) into parent(host) project. and share same pod into child(framework) project. or is there something i can add to Podfile and it will get share with child project.
SwiftProtoBuf framework, i want to use. and i don't wish to make umbrella framework.
can we share cocoapods pod between parent and child project
platform :ios, '8.0'
use_frameworks!
workspace 'ParentApp.xcworkspace'
abstract_target 'commonpods' do
pod 'SwiftProtobuf', git: 'https://github.com/apple/swift-protobuf.git', :tag => '0.9.24'
target 'ParentApp' do
project 'ParentApp.xcodeproj'
end
target 'ChildApp' do
project 'ChildFramework/ChildApp.xcodeproj'
end
end
or do i need to add pod to both project something like
platform :ios, '8.0'
use_frameworks!
target 'ParentApp' do
project 'ParentApp.xcodeproj'
pod 'SwiftProtobuf', git: 'https://github.com/apple/swift-protobuf.git', :tag => '0.9.24'
end
target 'ChildApp' do
project 'ChildFramework/ChildApp.xcodeproj'
pod 'SwiftProtobuf', git: 'https://github.com/apple/swift-protobuf.git', :tag => '0.9.24'
end
After little Struggle, i am able to solve it, it may help some-one in need.
Create Blank .xcworkspace , Xcode->File->New->Workspace
Open your .xcworkspace file in xcode, Add your Host(partent) project into .xcworkspace
add your framework(child) project in .xcworkspace.
and Podfile structure is like.
platform :ios, '8.0'
use_frameworks!
workspace 'MyWorkSpaceName.xcworkspace'
abstract_target 'CommonPods' do
pod 'SwiftProtobuf', git: 'https://github.com/apple/swift-protobuf.git', :tag => '0.9.24'
target 'MyHostAppProject' do
project 'MyHostAppProject/MyHostAppProject.xcodeproj'
end
target 'MyFrameworkProject' do
project 'MyFrameworkProject/MyFrameworkProject.xcodeproj'
end
end
make sure .xcworkspace is created and both your project is added into workspace, then only install pods to your project.
Related
I have project with 10+ targets in Xcode. I am using cocoapods to provide me some frameworks.
But Pod projects starting to grow (many files)
It is possible somehow configure Pod file to create one universal configuration, which is imported to other projects? Something like abstract target?
I don't need for each target create new pod framework, because all my targets using same pods.
Thanks for suggestion.
Something like this:
platform :ios, '11.0'
custom config 'Pods-framewrks' do
use_frameworks!
pod 'Alamofire'
end
project = Xcodeproj::Project.open “./MyProject.xcodeproj"
project.targets.each do |t|
target t.name do
import framework Pods // ???
end
end
If you put pod 'Alamofire' outside of any specific target, then it will be included in all targets.
For example:
platform :ios, '11.0'
pod 'Alamofire'
target 'FirstTarget' do
end
target 'SecondTarget' do
pod 'SwifterSwift'
end
I am working on a project where I have added Firebase, Crashlytics etc using POD.
Now there is a requirement to create modules for each feature available in the app, so I created Modules for each Feature (Say Profile, Payment, Linking etc) & its working fine with main container app. Now My App looks like as below
Now I want to a use Framework(say Firebase) added Via POD in my module(Say Profile) but when I tried to import in a module I am getting
No such module 'Firebase'
Please suggest me how can add Framework added Via POD in any module.
Please also let me know If I have explained my question.
Below is my POD file
platform :ios, '8.0'
use_frameworks!
def mainPodPackage
pod 'Mapbox-iOS-SDK'
pod 'ZendeskSDK'
pod 'OneSignal'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'FacebookSDK'
end
target 'Production' do
mainPodPackage
end
target 'PreProd' do
mainPodPackage
end
target 'Dev' do
mainPodPackage
end
This is how you can install pod for multiple project workspace, edit your podfile as so, test target should have same project as it's target:
use_frameworks!
workspace 'Workspace_name'
project 'PjA.xcodeproj'
project 'path_to_PjB/PjB.xcodeproj'
target 'PjA' do
project 'PjA.xcodeproj'
...
end
target 'PjB' do
project 'path_to_PjB/PjB.xcodeproj'
...
end
I'm trying to figure out how to use Realm in both projects iOS and macOS of a single workspace.
At first try it fails to compile with more than 200 errors.
Workspace currently contains:
MyApp iOS project
MyAppMac macOS project
Pods project
Podfile:
workspace 'MyApp'
target 'MyApp' do
workspace 'MyApp'
xcodeproj 'MyApp.xcodeproj'
use_frameworks!
pod 'RealmSwift'
pod 'SVProgressHUD'
end
target 'MyAppMac' do
workspace 'MyApp'
xcodeproj 'MyAppMac.xcodeproj'
use_frameworks!
pod 'RealmSwift'
end
I just discovered that adding pod 'Realm' to MyAppMac target, works fine and produces no errors.
However, is this optimal?
I've seen some ways to reuse shared pods like RealmSwift but not sure how to do this given the configuration.
Right now I need to add LiveSDK to multiple targets. Please see below:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
target :CalDoKit do
pod 'LiveSDK'
end
pod 'Google-API-Client/Calendar'
pod 'LiveSDK'
As you can see the LiveSDK pod added twice. And I am getting warning from the console output when I run the application: One of the two will be used. Which one is undefined.
What's the correct way to add one pod to multiple targets?
New code:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
link_with 'CalDo', 'CalDoKit'
pod 'LiveSDK'
target :CalDo do
pod 'SVProgressHUD'
end
But I am getting warning:
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `TestKit` to `Pods/Target Support Files/Pods/Pods.debug.xcconfig` or include the `Pods/Target Support Files/Pods/Pods.debug.xcconfig` in your build configuration.
Solution 1:
Remove that 'target :xx do ... end' and add pod without defining targets. It will add the pod for all targets.
Solution 2:
Delete that podfile and run pod init command from terminal. this will make a new podfile with all the targets used in the project and then you can add pods separately for each target
Add this to the Podfile
target :AnotherTarget do
pod 'LiveSDK'
end
EDIT
This is the final Podfile source
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
target :CalDoKit do
pod 'LiveSDK'
end
target :OtherTarget do
pod 'LiveSDK'
end
If you execute pod init console command on your project folder, it will create the Podfile with built in code.
See here: http://guides.cocoapods.org/syntax/podfile.html#target
I want to integrate an action extension into my app. I generated an embedded framework with the shared code between app and extension.
Now I need to access a pod in the embedded framework. How do I link the pods into the framework?
You can use target to separate the pods for the app and your embedded framework.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target :App do
pod ...
pod ...
end
target :Framework do
pod ...
pod ...
end