3

I want to embed several projects and frameworks in only one workspace.

Here is the structure in Xcode:

enter image description here

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 :

enter image description here

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.

2
  • I'm not sure why would you want to access a dependency through a framework as intermediate layer and not directly. I think you should use access Toast-Swift directly from Project1 / Project2 instead of trying to access it through BaseFramework => Toast-Swift. Can you please elaborate it further? Commented Mar 23, 2019 at 7:10
  • Well, I thought about it that way : let's suppose I want to create a base framework that reuses code from a dependency, and then several projects should include that framework, without necessarily use elements from the framework's dependency. Is this a bad approach? Commented Mar 26, 2019 at 10:21

2 Answers 2

3
+200

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 
Sign up to request clarification or add additional context in comments.

Comments

0

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

3 Comments

That's what I was thinking first, but since I'm planning to use this framework only in my team, I thought it could be a better idea to use a local framework instead. Guess I will have to use a private pod if I follow your idea, right?
yes,you could distribite your framework as a private pod.
Ok thank you. I'll wait to see if any other answer comes and if not I'll accept yours. I'm a bit surprised and disappointed though that there is no easy solution to do what I want...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.