Skip to content

Conversation

@liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Oct 15, 2025

Update The Objective-C interop documentation to use the new FFIgen config Dart API, instead of YAML configs. I haven't updated the Swift example, because that will soon be replaced by swiftgen.

Fixes dart-lang/native#2710

@liamappelbe liamappelbe requested a review from parlough October 15, 2025 00:38
@liamappelbe liamappelbe changed the title Interop doc fixes WIP: Interop doc fixes Oct 15, 2025
@dart-github-bot
Copy link
Collaborator

dart-github-bot commented Oct 15, 2025

Visit the preview URL for this PR (updated for commit 93e64c5):

https://dart-dev--pr6942-objc-update-qqxo4l1b.web.app

@parlough
Copy link
Member

I believe the failure was from a version of Jaspr that had a regression. I updated the branch with main which should pull in the release with a fix.

I'm guessing swift isn't a supported language for the syntax highlighting? It works when I change the language to dart, but obviously that's not a viable solution. Any suggestions? Is there a list of supported languages somewhere?

You're right, Swift isn't supported yet, but if swift is specified, it should fall back to no syntax highlighting. The list of supported languages can be found in site/lib/src/extensions/code_block_processor.dart.

I'm planning to work on basic support for Swift soon, is the no highlighting fallback sufficient until I can finish that?

@liamappelbe
Copy link
Contributor Author

I'm planning to work on basic support for Swift soon, is the no highlighting fallback sufficient until I can finish that?

Yep, no hilighting is fine for now.

@liamappelbe liamappelbe changed the title WIP: Interop doc fixes Objective-C interop doc updates Oct 21, 2025
@liamappelbe
Copy link
Contributor Author

@parlough This is ready for review. PTAL

@liamappelbe liamappelbe marked this pull request as ready for review October 21, 2025 04:40
@parlough parlough requested a review from antfitch October 24, 2025 18:05
@parlough
Copy link
Member

parlough commented Oct 24, 2025

Sorry about the delay in reviewing this. I'll make sure to take a look before Monday!

\cc @antfitch For reviewing the writing and structure.

Copy link
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall these updates look good to me after a few updates, thanks for coming back to them @liamappelbe!

Do wait for @antfitch's approval as well before landing :)

Comment on lines +86 to +90
First, we'll tell FFIgen where to find the API we're trying to
generate bindings for.
To do this, we set the `headers.entryPoints` option.

For this example, we need to load `AVAudioPlayer.h`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally the style guide suggests addressing the reader as you:

Suggested change
First, we'll tell FFIgen where to find the API we're trying to
generate bindings for.
To do this, we set the `headers.entryPoints` option.
For this example, we need to load `AVAudioPlayer.h`.
First, you'll tell FFIgen where to find the API we're trying to
generate bindings for.
To do this, you set the `headers.entryPoints` option.
For this example, you'll load `AVAudioPlayer.h`.

such as `macSdkPath`.
Using these helper functions makes your code generation script
more reliable across different machines,
which may have different SDK installation locations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
which may have different SDK installation locations.
which might have different SDK installation locations.

Comment on lines +130 to +131
if the API you're generating bindings for needs it
(e.g. if you're using blocks or protocols).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if the API you're generating bindings for needs it
(e.g. if you're using blocks or protocols).
if the API you're generating bindings for needs it,
such as if you're using blocks or protocols.

but with `.m` at the end of the file name.
You can change its location with `output.objectiveCFile` option.
If FFIgen produces this file, you must compile it into your package,
otherwise you may get runtime exceptions to do with missing symbols.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
otherwise you may get runtime exceptions to do with missing symbols.
otherwise you might get runtime exceptions relating to missing symbols.

```console
$ dart run ffigen --config my_ffigen_config.yaml
```
You may notice other classes in the file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You may notice other classes in the file
You might notice other classes in the file

```
You may notice other classes in the file
with a comment indicating they are a stub.
FFIgen will generate stub bindings for all transitive dependencies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FFIgen will generate stub bindings for all transitive dependencies
FFIgen generates stub bindings for all transitive dependencies

Comment on lines +373 to +374
`FooBlock.blocking` may add support for non-`void` return values in future,
if there is user demand for it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`FooBlock.blocking` may add support for non-`void` return values in future,
if there is user demand for it.
If there is demand for it,
`FooBlock.blocking` might add support for
non-`void` return values in the future.

so this isn't an issue when invoking these thread-locked APIs
from the main isolate.
If you need to invoke these APIs from other isolates,
or you need to support older versions of flutter,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
or you need to support older versions of flutter,
or you need to support older versions of Flutter,

There is an experimental project to automate these steps
called [Swiftgen][].

[Swiftgen]: https://pub.dev/packages/swiftgen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Swiftgen]: https://pub.dev/packages/swiftgen
[Swiftgen]: {{site.pub-pkg}}/swiftgen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ffigen] Fix up documentation on dart.dev

3 participants