Consume FFmpeg XCFramework from Objective-C, headers not found

Viewed 1330

I built FFmpeg for Apple's platforms as an XCFramework. I used the script in https://github.com/kewlbear/FFmpeg-iOS-build-script/pull/147 to do so.

I'm trying to now consume that framework inside a traditional iOS/macOS framework (named VideoEditing), that then is used inside my iOS app (soon to try and be Catalyst).

In VideoEditing I have linked to FFmpeg.xcframework and then in the app that uses VideoEditing I have linked & embedded FFmpeg.xcframework. Previously I was building FFmpeg as a standard static library, and using that from inside VideoEditing in a Objective-C++ wrapper so I can use it all from Swift.

In that Objective-C++ file I would import FFmpeg headers like #import <libswscale/swscale.h> To make that work, I had to set header search paths. How are you supposed to do it once you convert to the XCFramework? I've tried @import FFmpeg, #import <FFmpeg/libswscale/swscale.h>, #import <FFmpeg/swscale.h> as well as #import <libswscale/swscale.h>. In every case I just get a file not found error on the import line.

All of Apple's examples are showing it just in Swift with the framework vending a module. If I was to try and still set a header search path, you now have different headers per architecture.

Overview of contents of XCFramework

2 Answers

Try @import FFmpeg and also set Enable Modules (C and Objective C) to YES from build settings. Make sure that Link Frameworks Automatically is set to YES

You need to put header files parallel to xcframework and set header search path to that header file. xcframework is just like a single .a file, Xcode will not search headers inside xcframework.

Related