关于ios:Xcode / Cocoapods:我无法访问与我的项目链接的框架中的依赖项

 2021-04-08 

Xcode/Cocoapods: I can't access a dependency that's in a framework linked to my project

我只想在一个工作区中嵌入几个项目和框架。

这是Xcode中的结构:

enter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

enter

感谢您的帮助。


通过在框架目标范围内声明项目目标,项目目标将获得框架的所有依赖项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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

为框架创建一个pod并添加``Toast-Swift''作为依赖项是避免伞式框架的理想选择。