SDWebImage / SDWebImageAVIFCoder

A SDWebImage coder plugin to support AVIF(AV1 Image File Format) image
MIT License
55 stars 14 forks source link

[bug]fix include internal #41

Closed doihei closed 1 year ago

doihei commented 1 year ago

I got the following error in the source code I put in with Cocoapods. This fix solves it by adding a condition to the include statement.

'libavif/internal.h' file not found
1. Did not find header 'internal.h' in framework 'libavif' (loaded from '~/Library/Developer/Xcode/DerivedData/{app name}/Build/Products/Debug-iphonesimulator/libavif')

Xcode: 13.4.1 CocoaPods: 1.11.3

dreampiggy commented 1 year ago

Is this __has_include will become false and use #include "avif/include.h" instead ? Works ?

I think this one seems a little strange, because for CocoaPods, it can only either contains headers dir like this

Public
- libavif
-- include
--- avif.h
--- internal.h

or this:

Public
libavif
- avif.h
- internal.h

So your changes does not explain the reason under the hood...

dreampiggy commented 1 year ago

Which means, if I can import avif headers via

#include <libavif/avif.h>

I can always include another public headers like internal.h via

#include <libavif/internal.h>

These two is Bijection...


Or another possible reason: The internal.h is not public header, but the avif.h is public header, they are different. Maybe you can provide your demo, or upload the folder strcture of your Pods folder, using tree command (https://www.geeksforgeeks.org/tree-command-unixlinux/) to let me know what happends.

doihei commented 1 year ago

Thanks for looking at my fix.

Is it because libavif.podspec does not have internal.h in the public header?

It happens even if you simply add this library in your Podfile. The following files will be the contents of Pods.

Pods-tree.log

Also, the following URL will be the repository.

https://github.com/doihei/TestSDWebImageAVIFCoder

dreampiggy commented 1 year ago

Seems correct. Currently the libavif-Xcode (Our SDWebImage maintained wrapper)'s podspec shows:

  s.subspec 'core' do |ss|
    ss.source_files = 'src/**/*.{h,c,cc}', 'include/avif/*.h'
    ss.public_header_files = 'include/avif/avif.h'

which should be fixed to

  s.subspec 'core' do |ss|
    ss.source_files = 'src/**/*.{h,c,cc}', 'include/avif/*.h'
    ss.public_header_files = 'include/avif/*.h'

I'll submit new version (also bump libavif upstream dependency)

dreampiggy commented 1 year ago

Tip: The internal.h is actually public APIs, not some internal APIs :)

This issue only effect CocoaPods, the SwiftPM and Carthage already put both 2 headers files into public.

Our AVIF conversion use some of data structures to do RGB-YUV conversion


Fixed in https://github.com/SDWebImage/libavif-Xcode/pull/4 and should release new version (0.10.0/0.10.1)

dreampiggy commented 1 year ago

I'll re-release libavif v0.10.1, because v0.11 changes breaks APIs, I doubt that it's suitable or not to just upgrade.

For this PR, I'll merge as well, and check AVIFCoder to compatible with v0.11