Search code examples
iosobjective-ciphoneios-frameworks

Sharing code between iOS Project and custom created iOS Framework


I have written a framework that make use of SAMKeychain. This frameworkA is used inside the an iOS project.

The iOS project in return has some additional classes that uses the same SAMKeychain. I am trying to find a way to refer the SAMKeychain in the framework and include as a dependency(But do not include SAMKeychain sources) inside the framework.

I tried referencing just the header files of SAMKeychain in the framework and try to build the framework but It failed with linking error _OBJC_CLASS_$_SAMKeychain

What is the best way to share third party code between the framework and iOS project


Solution

  • The solution was to use dynamic frameworks . So when frameworkA is made it should be dynamic and the Pods it contains that is SAMKeychain should also be dynamic to do that you use

    use_frameworks! in Podfile which will create SAMkeychain.framework for the Pod SAMkeychain.

    After the frameworkA binary is created in the iOS project you have to add both frameworkA and SAMKeychain.framework as embedded binaries. And this will work just ok.

    Note that if you don't use use_frameworks in the Podfile it would generate a static library of the pod which will be included in the binary of frameworkA.

    Hope this helps someone!