I have an iOS App MY-App
which uses my own framework MY-Framework
. Both are written in swift
. The app only handles user authentification and passes an access token to MY-Framework
. MY-Framework
then handles the entire ScreenFlow and business logic. The goal is to distribute the MY-Framework
to customers to use it in their apps.
a minimal sample of the project setup exhibiting this problem is available here: https://github.com/vprimachenko/lottie-pod-problem-sample
now I was to enhance my framework provided views with some animations and were to use lottie for it. i am using cocoapods version1.6.0-pre
i created a Podfile
with following content
target 'fw' do
pod 'lottie-ios'
end
which resulted in a compile error in the framework
./fw/fw/File.swift:4:8: error: no such module 'Lottie'
import Lottie
^
after some googling i changed my Podfile
to:
target 'fw' do
use_frameworks!
pod 'lottie-ios'
end
result: Runtime crash
dyld: Library not loaded: @rpath/Lottie.framework/Lottie
Referenced from: .../Build/Products/Debug-iphonesimulator/fw.framework/fw
Reason: image not found
cocoapods release notes mention use_modular_headers!
, lets try that:
target 'fw' do
use_modular_headers!
pod 'lottie-ios'
end
result: compiler error in the containing app
./app/app/ViewController.swift:3:8: error: missing required module 'Lottie'
import fw
^
target 'fw' do
use_modular_headers!
use_frameworks!
pod 'lottie-ios'
end
result: runtime crash
dyld: Library not loaded: @rpath/Lottie.framework/Lottie
Referenced from: .../Build/Products/Debug-iphonesimulator/fw.framework/fw
Reason: image not found
after some trying around I was able to solve the situation by providing my own bringing header for Lottie
but this feels more like a duct-tape rather than a proper solution. I will still post this later as an additional answer.
how do i use properly integrate lottie-ios
cocoapod in such a way that it is completely contained in MY-Framework
, so when i share it to a customer they can just drop it into their App and not worry about any dependencies?
Releasing it as a private pod with dependencies is sadly not an option.
You can use Objective-C and Swift files together in a single project, no matter which language the project used originally. This makes creating mixed-language app and framework targets as straightforward as creating an app or framework target written in a single language.
The common way to use objective-c
code in swift
is using bridging headers, take a look at this:
Importing Objective-C into Swift
you need to create a bridging header and add it to your project then inside the .h file you created simply add :
#import <Lottie/Lottie.h>
how do i use properly integrate lottie-ios cocoapod in such a way that it is completely contained in MY-Framework, so when i share it to a customer they can just drop it into their App and not worry about any dependencies?
I don't think you want to do this. What if your customer's app already uses the Lottie framework, possibly a different version than used in MY-Framework?
A typical way to solve this is to require your client to use Lottie as a dependency. If you're using cocoapod, your clients won't really notice, and it is common practice. You specify your dependency using spec.dependency at https://guides.cocoapods.org/syntax/podspec.html)
If really desperate, you could copy all the source of Lottie into MY-framework, and make sure they are defined in their own module to avoid clashes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With