I have an ios app that uses opencv and some other libraries. When running it, I see a log:
(lldb) objc[536]: Class VideoWriter is implemented in both /System/Library/PrivateFrameworks/AutoLoop.framework/AutoLoop (0x1f897bd48) and /private/var/containers/Bundle/Application/6AF089E9-121C-41B4-8706-3F63E9F39090/Runner.app/Runner (0x1057a7888). One of the two will be used. Which one is undefined.
Surely, I can do nothing with AutoLoop.framework
. But for the Runner.app/Runner
(which is indeed the name of my app since I am using Flutter), I hope I can change it. However, I have searched through all my code and see I do not define VideoWriter
by myself. With more searching, it seems the OpenCV defines that (please correct me if I am wrong!). The clue is: At opencv2.framework/Modules/opencv2.swiftmodule/arm64-apple-ios.swiftinterface
I see –
...
extension VideoWriter {
@nonobjc public convenience init(filename: Swift.String, fourcc: Swift.Int32, fps: Swift.Double, frameSize: opencv2.Size2i, params: [Swift.Int32])
}
...
So I guess that is where VideoWriter
comes from.
I do not need the videoio
submodule of OpenCV, so I am happy to remove it if I can. Indeed, since I link against opencv2.framework
and do not use it, it should be already stripped out and I am not sure why it is still there.
Question:
- Does that conflict really comes from OpenCV? Or I made a wrong conclusion?
- What to do to resolve the conflict?
Any help is appreciated!
2
Answers
I have the same problem as you,and I finally use
CocoaPods
to import OpenCV, it fix the problemConfirm that it’s a naming conflict of OpenCV. I build the framework locally without opencv.videoio module and the warning is gone.
Just clone github.com/opencv/opencv repo and use its scripts for building:
It might be tricky if you want to use the local xcframework in podspec. And it also needs some effort to write a Pacakage.swift.
I just manually imported the opencv2.xcframework and added some builtin frameworks such as
Accelerate
CoreGraphics
CoreImage
CoreMedia
into theLink Binary With Libraries
of project settings.