Skip to content

Commit

Permalink
Merge 5fddf8f into 1a6faf5
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed May 8, 2024
2 parents 1a6faf5 + 5fddf8f commit 5faa085
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkgs/ffigen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 12.0.0-wip
## 12.0.0

- Global variables are now compatible with the `ffi-native` option.
- Exposing symbol addresses of functions and globals is now compatible with the
Expand Down
6 changes: 3 additions & 3 deletions pkgs/ffigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# BSD-style license that can be found in the LICENSE file.

name: ffigen
version: 12.0.0-wip
version: 12.0.0
description: >
Generator for FFI bindings, using LibClang to parse C, Objective-C, and Swift
files.
Expand All @@ -14,7 +14,7 @@ topics:
- codegen

environment:
sdk: '>=3.3.0-252.0.dev <4.0.0'
sdk: '>=3.3.0 <4.0.0'

dependencies:
args: ^2.0.0
Expand All @@ -35,7 +35,7 @@ dev_dependencies:
json_schema: ^5.1.1
lints: ^2.0.1
meta: ^1.11.0
objective_c: ^0.0.1
objective_c: ^1.0.0
test: ^1.16.2

dependency_overrides:
Expand Down
2 changes: 1 addition & 1 deletion pkgs/objective_c/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.0.1-wip
## 1.0.0

- Move sharable code from ffigen's generated code into this package, including
`ObjCObjectBase`, and `ObjCBlockBase`, as well as the core Objective C runtime
Expand Down
34 changes: 34 additions & 0 deletions pkgs/objective_c/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
[![Build Status](https://github.com/dart-lang/native/actions/workflows/objective_c.yaml/badge.svg)](https://github.com/dart-lang/native/actions/workflows/objective_c.yaml)
[![Coverage Status](https://coveralls.io/repos/github/dart-lang/native/badge.svg?branch=main)](https://coveralls.io/github/dart-lang/native?branch=main)
[![pub package](https://img.shields.io/pub/v/objective_c.svg)](https://pub.dev/packages/objective_c)
[![package publisher](https://img.shields.io/pub/publisher/objective_c.svg)](https://pub.dev/packages/objective_c/publisher)

# objective_c

A library to access Objective C from Flutter that acts as a support library for
package:ffigen.

This library isn't very useful on its own. Typically it is used while
interoperating with an Objective C library created by package:ffigen. See
https://pub.dev/packages/ffigen

For general information about interop with Objective C, see
https://dart.dev/guides/libraries/objective-c-interop

## Memory management

Objective C and Dart use different styles of memory management. Dart is garbage
collected, while Objective C uses reference counting. This difference is a
common cause of bugs when interoperating between the two languages.

Memory management issues typically manifest as seg faults, which can be hard to
debug as they often have no useful stack trace. The most common issue is use
after free errors, where a Dart object is constructed to wrap an Objective C
object that has already been destroyed. To debug these issues, try running your
program with [asserts enabled](https://dart.dev/language/error-handling#assert).
When the Dart wrapper object is created or destroyed, an assert checks that the
Objective C object still exists, which should provide a much more useful stack
trace.

References are automatically retained when the Dart wrapper object is
created, and released when the Dart object is garbage collected. But to fix a
reference counting issue, it may occasionally be necessary to manually control
the ref count. The ref count of the Objective C object can be controlled from
Dart by the `retain` and `release` options in the Dart wrapper object
constructors, and by the `retainAndReturnPointer()` and `release()` methods.
4 changes: 2 additions & 2 deletions pkgs/objective_c/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: objective_c
description: "A library to access Objective C from Flutter that acts as a support library for package:ffigen."
version: 0.0.1-wip
version: 1.0.0
repository: https://github.com/dart-lang/native/tree/main/pkgs/objective_c

topics:
Expand All @@ -26,7 +26,7 @@ dependencies:

dev_dependencies:
coverage: ^1.8.0
ffigen: ^11.0.0
ffigen: ^12.0.0
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
Expand Down

0 comments on commit 5faa085

Please sign in to comment.