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

做~自己de王妃 提交于 2019-12-23 19:37:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!