问题
I want to embed several projects and frameworks in only one workspace.
Here is the structure in Xcode:
Project1
and Project2
are application projects, and BaseFramework
is a Cocoa Touch framework.
Now what I want to do is to add a pod dependency to the framework, then link this framework to one of the projects and access the dependency in this project. Here is what I tried with my Podfile:
platform :ios, '12.1'
use_frameworks!
inhibit_all_warnings!
workspace 'BaseWorkspace'
def shared_pods
pod 'Toast-Swift'
end
project 'Project1/Project1.xcodeproj'
project 'Project2/Project2.xcodeproj'
project 'BaseFramework/BaseFramework.xcodeproj'
target 'BaseFramework' do
project 'BaseFramework/BaseFramework.xcodeproj'
shared_pods
end
Then, I linked the framework to Project2
:
Everything compiles fine, I can import BaseFramework
in Project2
... but I'm unable to use methods from Toast-Swift
. What am I doing wrong here?
Thanks for your help.
回答1:
By declaring project targets inside framework target scope, project targets will get all dependencies of framework
platform :ios, '12.1'
use_frameworks!
inhibit_all_warnings!
workspace 'BaseWorkspace'
def shared_pods
pod 'Toast-Swift'
end
target 'BaseFramework' do
project 'BaseFramework/BaseFramework.xcodeproj'
shared_pods
target 'Project1' do
project 'Project1/Project1.xcodeproj'
end
target 'Project1' do
project 'Project2/Project2.xcodeproj'
end
end
回答2:
It would be ideal to create a pod for your framework and add 'Toast-Swift' as a dependency as its ideal to avoid umbrella frameworks.Refer here
来源:https://stackoverflow.com/questions/55164377/xcode-cocoapods-i-cant-access-a-dependency-thats-in-a-framework-linked-to-my