tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.87k stars 791 forks source link

[iOS] Support for dynamic frameworks #559

Closed jorge-ai closed 4 years ago

jorge-ai commented 4 years ago

I was testing the Cocoapods library, and it looks like the FFMPEG libraries are all statically linked on iOS. Is there a way to link them dynamically or to configure the build scripts to generate them dynamically? I want to better comply with LGPL; let me know if I'm missing something. Thank you! :)

tanersener commented 4 years ago

As far as I know iOS only allows system libraries to be shared/dynamic. Has that changed?

jorge-ai commented 4 years ago

Yes, I think this has changed for a long time. use_frameworks! in a Podfile will embed the library as a .Framework folder in the app package, but it seems like it only does this if the package itself is built to support this, as I don't see it happening with MobileFFMPEG. For example, including CocoaLumberjack will put a CocoaLumberjack.framework file in the final application package.

Actually this was a problem in the past that applications were embedding too many dynamic frameworks and this was slowing down the application startup.

tanersener commented 4 years ago

Okay. Let me be more specific. The situation about mobile-ffmpeg is different. mobile-ffmpeg doesn't have a single .framework like your CocoaLumberjack.framework. There are multiple frameworks and some of them depend on each other. It is not easy to create frameworks in this structure. I tried this in 2018, spent a lot of time on it. Tried different solutions but couldn't find a working one. You can find those changes in the git history, implement & see them yourself.

I don't remember all the details but as far as I remember some features of dynamic frameworks were not supported on iOS. Prebinding is one of those features. Nevertheless, I'm not sure if that was my problem then.

jorge-ai commented 4 years ago

Hi tanersener, I was able to fix it like this:

1) Add a framework target to Xcode. 2) Add mobile-ffmpeg as a dependency to that framework target instead of the main app target. 3) Add the framework as a dependency to the target of the main application. 4) Add FFMPEG wrapping code in the framework, not in the main application.

The FFMPEG code will now be included as a framework in the application package. For some strange reason, I had to manually link to CoreVideo.framework in the target framework.

Maybe there is a simpler way, but I don't have that much experience with these things.

tanersener commented 4 years ago

I don't follow. What did you fix here?

jorge-ai commented 4 years ago

I don't follow. What did you fix here?

Maybe not so much "fixed" but worked around. In other words, instead of this:

My application -> MobileFFMPEG.

I do this:

My App -> My Framework -> MobileFFMPEG

"My framework" is integrated into the final application package rather than statically linked. This makes it easier to replace (assuming "My framework" is open source too).

tanersener commented 4 years ago

oh, okay.

jorge-ai commented 4 years ago

Closing as the problem can be worked around. Thanks for the project!