iOS frameworks interoperability

62 views Asked by At

I am currently refactoring an iOS app which contains massive amount of classes, and as requested, I made few CocoaTouch frameworks (and again, as requested, not static libraries) to contain these classes based on their purpose (models, requests, etc.). However, framework A contains class, that I need to use in framework B, and I'd like to ask if anyone knows how to "connect" the two frameworks? Like some sort of chaining, maybe?

1

There are 1 answers

0
Jens Meder On

I guess by connecting frameworks you mean you want to use classes from framework A in framework B.

Step 1: Target Dependencies

I assume your framework targets belong to the same project. In this case you need to make sure that framework A is a target dependency of framework B. This way framework A will be build before framework B.

Step 2: Linking

The linker needs to know where he can find the symbols for framework A if you want to use them in framework B. Therefore, add framework A in the Link Binary with Libraries build phase of framework B.

You should now be able to use classes of framework A in framework B. You also need to add framework B as target dependency to your app target, link both frameworks with the app, and also add both frameworks as Embedded Binaries to the corresponding Build Phase.