Xcode / Cocoapods:我无法访问链接到我的项目的框架中的依赖项 [英] Xcode/Cocoapods: I can't access a dependency that's in a framework linked to my project
问题描述
我只想在一个工作区中嵌入几个项目和框架。
I want to embed several projects and frameworks in only one workspace.
这是Xcode中的结构:
Here is the structure in Xcode:
Project1
和 Project2
是应用程序项目,而 BaseFramework
是一个Cocoa Touch框架。
Project1
and Project2
are application projects, and BaseFramework
is a Cocoa Touch framework.
现在我要做的是向该框架添加一个pod依赖项,然后将此框架链接到项目之一,并访问该项目中的依赖项。这是我尝试使用Podfile的方法:
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
然后,我将框架链接到 Project2
:
Then, I linked the framework to Project2
:
一切都可以编译,我可以在 Project2
中导入 BaseFramework
...但是我无法使用 Toast-Swift
中的方法。
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?
感谢您的帮助。
推荐答案
通过在框架目标范围内声明项目目标,项目目标将获得框架的所有依赖项
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
这篇关于Xcode / Cocoapods:我无法访问链接到我的项目的框架中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!