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
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!
Related
I've built swift frameworks before, but I've never dealt with one that has 3rd party dependencies.
What I have right now is a Swift framework that has a dependency on several Swift packages. When I build it I see MyFramework.framework in the products folder as well as bunch of dependencies. I can make XCFramework out of it, but when integrating (embedding) it into another app I see an error that MyFramework is missing its dependencies (see image below).
What am I doing wrong or missing?
Creating a framework (or xcframework) that has embedded other frameworks is not supported for iOS(I believe this is answered here).
But there is an other way. You can statically link all the dependencies of your library, so in the final framework the binary will also contain the code of its dependencies.
If you are using CocoaPods and the name of the framework is aFramework you can do:
target 'aFramework' do
pod 'Alamofire', :linkage => :static
end
Then you can use the created aFramework.framework in a application target that does not have the Alamofire framework, since the code will be "embedded" in the aFramework's binary.
I have the custom created framework.
I want to use CryptoSwift Pods in this framework.
First, I create a custom framework and I can use this framework(From Frameworks folder Example.framework) from another project.
Second, I installed CryptySwift Pods to these frameworks
How can I install Pods programmatically in custom frameworks and used it in other projects?
Not understanding you exact question but if you want to create your own framework and you are using any third party then you can create your framework with your own files and then when you will use your framework in another project then ask developer to install those third party pods or frameworks into their project. It will help to avoid conflict if developer also using same framework or pod in their project.
I have a free framework (FW). It distributes via cocoapods. In this framework i use another framework. It compiled as dynamic framework (DFW).
So in my FW i need to write import DFW and after this can use it. Also the DFW is linked in Embedded Binaries and Linked Frameworks and Libraries in my project target.
After that i push my FW to cocoapods and after installing it tells Cannot find such a module near the import DFW statement.
The question is - how to properly distribute cocoapod with embedded dynamic frameworks in it?
There is no way to use dynamic frameworks in cocoapods, because it brings in a versioning issues. Instead of this use s.dependency in the podspec file. You can read this also.
I want to build a Cocoa touch framework in iOS. My framework named as 'MyFramework' which depends on third party frameworks like 'GoogleWebRTC'.
I tried adding this through cocoa pods and also with drag into MyFramework project. But the issue is when I import MyFramework into any other Project, it gives error:
Module 'WebRTC' not found
I have also seen that Apple discourage umbrella frameworks:
Why are umbrella frameworks discouraged?
Then:
I want to understand how I can include this GoogleWebRTC.framework or any other third party lib. in MyFramework project and distribute to others.
Help is Appreciated!
Solution for me was that I have to explicitly add GoogleWebRTC in the app with my framework.
And if your framework can install by pods then you can mention your dependent third parties lib. in podspec file as below:
s.ios.dependency 'dependent framework pod'
I created a cocoa touch framework with Swift as the preferred language.
On this framework I need to import static libraries, so I created a podfile and imported the pod using use_frameworks!
I created a bridging header and also added the pods source as header search path since it couldn't find the pod's header.
The framework compiles fine and I have no issues.
So I created a pod spec for the framework and created a sample app in swift. I had the framework as development pod in my podfile. Now I get
Include of non-modular header inside framework module in my bridging header import of the static library public header.
I understand since it's a static library we cannot build the touch framework, but what would be the work around to have a touch framework with static libraries in them written in Swift.
PS I have set Allow Non-modular Includes in Framework Modules to Yes
To answer my original question. It seems to be an issue with cocoapods(0.36.2) for vendor libraries where there is no implementation file.
There is a hack to get this working and you can take a look at this github issue