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
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 have one workspace that have 2 project and 1 common shared framework, each project can use common framework and on Two Apps with a shared private Framework, in a WorkSpace but when I added Podfile and execute pod install I got this warning
[!] The Podfile contains framework or static library targets, 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).
and I got this error when running my project application
dyld: Library not loaded: #rpath/Alamofire.framework/Alamofire
Referenced from: /Users/alfian0/Library/Developer/Xcode/DerivedData/SIPMI-arflaxzmdqswkjgsqghdmfizsjws/Build/Products/Debug-iphonesimulator/Common.framework/Common
Reason: image not found
this is my Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
use_frameworks!
workspace 'SIPMI'
project 'Common/Common.xcodeproj'
project 'TKIApp/TKIApp.xcodeproj'
project 'WalletApp/WalletApp.xcodeproj'
def networking_pods
pod 'Moya/RxSwift', '10.0.2'
end
def application_pods
pod 'RxCocoa', '4.1.2'
pod 'Fabric', '1.7.3'
pod 'Crashlytics', '3.10.0'
pod 'IQKeyboardManagerSwift', '5.0.7'
end
target 'Common' do
project 'Common/Common.xcodeproj'
networking_pods
end
target 'TKIApp' do
project 'TKIApp/TKIApp.xcodeproj'
application_pods
end
target 'WalletApp' do
project 'WalletApp/WalletApp.xcodeproj'
application_pods
end
and this is my project structure
I've created a private framework which utilises a number of pods. I want to now use this framework (which has a podspec file) in a project also using Cocoapods.
I've searched for many hours but cannot find a working example. My use case is that I am creating multiple apps, however these apps share a lot of code and assets (storyboards, files, etc). Therefore the framework contains all these common components and needs to be used in each app target.
I currently have this but it does not work as it should:
platform :ios, '9.0'
use_frameworks!
workspace 'Project.xcworkspace'
def shared_pods
pod 1
pod 2
pod 3
end
target 'Target1' do
shared_pods
end
target 'Target2' do
shared_pods
end
target 'MyPrivateFramework' do
project 'MyPrivateFrameworkDirectory/MyPrivateFramework.xcodeproj'
shared_pods
end
target 'TestsTarget' do
inherit! :search_paths
# Pods for testing
end
The warning I receive is:
[!] The Podfile contains framework targets, 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).
I found my answer by reading this thread carefully: https://github.com/CocoaPods/CocoaPods/issues/6123 and comparing with the sample project here: https://github.com/benasher44/CocoaPodsLibExample
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.