mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Since ffigen added support for [`NativeCallable.listener`](https://api.flutter.dev/flutter/dart-ffi/NativeCallable/NativeCallable.listener.html) to its ObjC bindings, this example can be simplified. We can replace the `Dart_Port` logic with `ObjCBlock.listener`, which lets us get rid of most of the native code. We still need a small bit of native code to `retain` a reference to the callback's arguments before invoking the listener, otherwise the arguments may be ref counted and deleted before the Dart side of the callback is invoked. See https://github.com/dart-lang/native/issues/835
25 lines
885 B
YAML
25 lines
885 B
YAML
# Run with `flutter pub run ffigen --config ffigen.yaml`.
|
||
name: PedometerBindings
|
||
description: "Bindings for CM pedometers"
|
||
language: objc
|
||
output: "lib/pedometer_bindings_generated.dart"
|
||
compiler-opts:
|
||
- "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks"
|
||
- "-mios-version-min=13.0"
|
||
exclude-all-by-default: true
|
||
functions:
|
||
include:
|
||
- "wrapCallback"
|
||
objc-interfaces:
|
||
include:
|
||
- "CMPedometer"
|
||
- "NSDate"
|
||
- "NSDateFormatter"
|
||
headers:
|
||
entry-points:
|
||
- "src/pedometerHelper.h"
|
||
|
||
# To use this API, you must include the NSMotionUsageDescription key in your app’s Info.plist file
|
||
# and provide a usage description string for this key.
|
||
# The usage description appears in the prompt that the user must accept the first time the system asks the user to access motion data for your app.
|