Skip to content

Type mismatch in overrides in AVFoundation generation #1416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stuartmorgan-g opened this issue Aug 12, 2024 · 1 comment · Fixed by #1433
Closed

Type mismatch in overrides in AVFoundation generation #1416

stuartmorgan-g opened this issue Aug 12, 2024 · 1 comment · Fixed by #1433
Assignees
Labels
lang-objective_c Related to Objective C support package:ffigen
Milestone

Comments

@stuartmorgan-g
Copy link

stuartmorgan-g commented Aug 12, 2024

While experimenting with FFI using AVFoundation, using this config:

headers:
  entry-points:
    - '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AVFoundation.framework/Versions/A/Headers/AVFoundation.h'
exclude-all-by-default: true
objc-interfaces:
  include:
    - 'AVAudioSession'
    - 'AVPlayer'
globals:
  include:
    - 'AVAudioSessionCategoryPlayback'
    - 'AVAudioSessionCategoryOptionMixWithOthers'

I got the following related errors in the generated output:

  • 'AVFragmentedAsset.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVFragmentedAssetTrack_NSError)') isn't a valid override of 'AVAsset.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVAssetTrack_NSError)').
  • 'AVComposition.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVCompositionTrack_NSError)') isn't a valid override of 'AVAsset.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVAssetTrack_NSError)').
  • 'AVMutableComposition.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVMutableCompositionTrack_NSError)') isn't a valid override of 'AVComposition.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVCompositionTrack_NSError)').
  • 'AVMovie.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVMovieTrack_NSError)') isn't a valid override of 'AVAsset.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVAssetTrack_NSError)').
  • 'AVMutableMovie.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVMutableMovieTrack_NSError)') isn't a valid override of 'AVMovie.loadTrackWithTrackID_completionHandler_' ('void Function(int, ObjCBlock_ffiVoid_AVMovieTrack_NSError)').

It looks like the issue is that generated block type is a unique type based on the combination of all of the individual parameter types, but the subclasses are using subclasses in one of the block parameter types and so the generated types don't match.

(I'm not trying to use this set of APIs so I can probably trim this out to unblock myself, but I wanted to file it since it's making output that doesn't compile from standard iOS SDK headers.)

@liamappelbe
Copy link
Contributor

Makes sense. I'll need to think about how to reflect the inheritance rules in the block type. Maybe have the generated block implement an interface that takes the signature as a generic param, then take that interface in these methods: https://dartpad.dev/?id=f987590bbdc4e04fbd24b850a70086ba

@liamappelbe liamappelbe moved this from Todo to In progress in ObjC/Swift interop Aug 15, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in ObjC/Swift interop Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-objective_c Related to Objective C support package:ffigen
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants