Open yanshouwang opened 1 month ago
That header is generated by the swift compiler, and the header parsing is done by clang, so ffigen doesn't directly get involved in that error.
I think the first thing to try is to fiddle with the clang flags using the compiler-opts
option in the config. Try adding a -F
flag to import the AVFoundation
framework (-FAVFoundation
might work, or you might need to specify the full path to the framework).
Last time I wrapped a swift framework, I found that I also had to specify the iOS version and sysroot. Check out this WebKit prototype for an example.
That header is generated by the swift compiler, and the header parsing is done by clang, so ffigen doesn't directly get involved in that error.
I think the first thing to try is to fiddle with the clang flags using the
compiler-opts
option in the config. Try adding a-F
flag to import theAVFoundation
framework (-FAVFoundation
might work, or you might need to specify the full path to the framework).Last time I wrapped a swift framework, I found that I also had to specify the iOS version and sysroot. Check out this WebKit prototype for an example.
Thanks, I'll try this later.
@liamappelbe I have tried these steps but the error still exists.
The objc-interfaces
is generated correctly, but the AVLayterVideoGravity
which is a typedef
can't be generated.
The
objc-interfaces
is generated correctly, but theAVLayterVideoGravity
which is atypedef
can't be generated.
I think AVLayerVideoGravity
is a struct. What header file is it defined in? If you manually edit the generated header (camerax_ios-Swift.h) to import the AVLayerVideoGravity
header, does the error go away?
The
objc-interfaces
is generated correctly, but theAVLayterVideoGravity
which is atypedef
can't be generated.I think
AVLayerVideoGravity
is a struct. What header file is it defined in? If you manually edit the generated header (camerax_ios-Swift.h) to import theAVLayerVideoGravity
header, does the error go away?
The AVLayerVideoGravity
is a structure
in swift but typealias
in objc
typedef NSString *AVLayerVideoGravity;
I've imported the AVFoundation header, do I need to import another header?
I've imported the AVFoundation header, do I need to import another header?
I'm not sure. The error you're describing is a clang compile error, so there's nothing I can do to fix it in ffigen. You'll basically have figure out what compiler-opts
are needed to fix the error.
It's also possible you need code changes in your swift file. Maybe the issue is that AVLayerVideoGravity
is a struct in Swift, but a typedef for a NSString*
in ObjC? That seems weird.
Another possible issue is that I don't think you can @objc
annotate methods that accept or return structs. So I'm surprised the swift compiler doesn't complain about the videoGravity
method. You'll probably need to write a wrapper class for AVLayerVideoGravity
that encapsulates it and exposes its fields as getters/setters.
I have written a swift class in a plugin like this
I can find the objc header in
example/build/ios/Debug-iphonesimulator/camerax_ios/camerax_ios.framework/Headers/camerax_ios-Swift.h
The
ffigen.yaml
is like this:When I run the ffigen command, there is an error caused the
AVLayerVideoGravity
can't be generated correctly.Seems the import statement is not figured out by ffigen. How can I fix this?