Skip to content

Commit 224d93e

Browse files
authored
[objective_c] Migrate to native assets (#2329)
1 parent 9767a50 commit 224d93e

File tree

193 files changed

+979
-1566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+979
-1566
lines changed

.github/workflows/ffigen.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- 'pkgs/ffigen/**'
1111
- 'pkgs/objective_c/**'
1212
pull_request:
13-
branches: [main, stable]
13+
branches: [main]
1414
paths:
1515
- '.github/workflows/ffigen.yml'
1616
- 'pkgs/ffigen/**'
@@ -34,17 +34,17 @@ jobs:
3434
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
3535
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
3636
with:
37-
channel: 'stable'
37+
channel: stable
3838
- id: install
3939
name: Install dependencies
40-
run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" && flutter pub get --directory="example/add"
40+
run: dart pub get && dart pub get --directory="example/shared_bindings" && dart pub get --directory="../objective_c" && dart pub get --directory="example/add"
4141
- name: Check formatting
4242
run: dart format --output=none --set-exit-if-changed .
4343
if: always() && steps.install.outcome == 'success'
4444
- name: Build test dylib and bindings
4545
run: dart --enable-asserts test/setup.dart
4646
- name: Analyze code
47-
run: flutter analyze --fatal-infos
47+
run: dart analyze --fatal-infos
4848

4949
test-linux:
5050
needs: analyze
@@ -56,9 +56,9 @@ jobs:
5656
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
5757
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
5858
with:
59-
channel: 'stable'
59+
channel: stable
6060
- name: Install dependencies
61-
run: flutter pub get && flutter pub get --directory="../jni"
61+
run: dart pub get && flutter pub get --directory="../jni"
6262
- name: Install libclang-14-dev
6363
run: sudo apt-get install libclang-14-dev
6464
- name: Build test dylib and bindings
@@ -82,7 +82,7 @@ jobs:
8282
with:
8383
channel: stable
8484
- name: Install dependencies
85-
run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni"
85+
run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni"
8686
- name: Install clang-format
8787
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30
8888
with:
@@ -92,7 +92,7 @@ jobs:
9292
- name: Install coverage
9393
run: dart pub global activate coverage
9494
- name: Run VM tests and collect coverage
95-
run: dart pub global run coverage:test_with_coverage --scope-output=ffigen --scope-output=objective_c
95+
run: dart test --coverage-path=./coverage/lcov.info
9696
- name: Generate package:jni bindings
9797
run: dart --enable-asserts run tool/generate_ffi_bindings.dart
9898
working-directory: pkgs/jni/
@@ -120,16 +120,16 @@ jobs:
120120
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
121121
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
122122
with:
123-
channel: master
123+
channel: stable
124124
- name: Install dependencies
125-
run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni"
125+
run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni"
126126
- name: Install clang-format
127127
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30
128128
with:
129129
brew: clang-format
130130
- name: Build test dylib and bindings
131131
run: dart --enable-asserts test/setup.dart
132-
- name: Run VM tests and collect coverage
132+
- name: Run VM tests
133133
run: dart test
134134

135135
test-mac-flutter:
@@ -142,13 +142,13 @@ jobs:
142142
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
143143
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
144144
with:
145-
channel: 'stable'
145+
channel: stable
146146
- name: Install dependencies
147-
run: flutter pub get && flutter pub get --directory="../objective_c"
147+
run: dart pub get && dart pub get --directory="../objective_c"
148148
- name: Build test dylib and bindings
149-
run: dart --enable-asserts test/setup.dart --main-thread-dispatcher
149+
run: dart --enable-asserts test/setup.dart
150150
- name: Run Flutter tests
151-
run: flutter test
151+
run: dart test
152152

153153
test-windows:
154154
needs: analyze
@@ -160,9 +160,9 @@ jobs:
160160
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
161161
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
162162
with:
163-
channel: 'stable'
163+
channel: stable
164164
- name: Install dependencies
165-
run: flutter pub get && flutter pub get --directory="../jni"
165+
run: dart pub get && flutter pub get --directory="../jni"
166166
- name: Build test dylib and bindings
167167
run: dart --enable-asserts test/setup.dart
168168
- name: Run VM tests
@@ -191,7 +191,7 @@ jobs:
191191
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
192192
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
193193
with:
194-
channel: "master"
194+
channel: stable
195195
- name: Install dependencies
196196
run: flutter pub get
197197
- name: Build test dylib and bindings

.github/workflows/ffigen_weekly.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ name: ffigen_weekly
66
on:
77
# Run once a week.
88
push:
9-
branches: [main, stable]
9+
branches: [main]
1010
paths:
1111
- '.github/workflows/ffigen_weekly.yml'
1212
pull_request:
13-
branches: [main, stable]
13+
branches: [main]
1414
paths:
1515
- '.github/workflows/ffigen_weekly.yml'
1616
schedule:
@@ -30,17 +30,17 @@ jobs:
3030
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
3131
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
3232
with:
33-
channel: 'stable'
33+
channel: stable
3434
- name: Install dependencies
35-
run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni"
35+
run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni"
3636
- name: Install clang-format
3737
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30
3838
with:
3939
brew: clang-format
4040
- name: Build test dylib and bindings
41-
run: dart --enable-asserts test/setup.dart --main-thread-dispatcher
41+
run: dart --enable-asserts test/setup.dart
4242
- name: Run VM tests
43-
run: flutter test
43+
run: dart test
4444
- name: Generate package:jni bindings
4545
run: dart --enable-asserts run tool/generate_ffi_bindings.dart
4646
working-directory: pkgs/jni/

.github/workflows/objective_c.yaml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name: objective_c
33
on:
44
# Run on PRs and pushes to the default branch.
55
push:
6-
branches: [main, stable]
6+
branches: [main]
77
paths:
88
- '.github/workflows/objective_c.yaml'
99
- 'pkgs/ffigen/**'
1010
- 'pkgs/native_test_helpers/**'
1111
- 'pkgs/objective_c/**'
1212
pull_request:
13-
branches: [main, stable]
13+
branches: [main]
1414
paths:
1515
- '.github/workflows/objective_c.yaml'
1616
- 'pkgs/ffigen/**'
@@ -35,10 +35,10 @@ jobs:
3535
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
3636
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
3737
with:
38-
channel: 'stable'
38+
channel: stable
3939
- id: install
4040
name: Install dependencies
41-
run: flutter pub get
41+
run: flutter pub get && flutter pub get --directory="example/command_line" && flutter pub get --directory="example/flutter_app"
4242
- name: Check formatting
4343
run: dart format --output=none --set-exit-if-changed .
4444
if: always() && steps.install.outcome == 'success'
@@ -54,14 +54,11 @@ jobs:
5454
working-directory: pkgs/objective_c/
5555
steps:
5656
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
57-
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
57+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
5858
with:
59-
channel: 'beta'
59+
sdk: stable
6060
- name: Install dependencies
61-
run: flutter pub get
62-
- name: Build test dylib
63-
# TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
64-
run: dart --enable-asserts test/setup.dart
61+
run: dart pub get
6562
- name: Install coverage
6663
run: dart pub global activate coverage
6764
- name: Run VM tests and collect coverage
@@ -84,20 +81,40 @@ jobs:
8481
github-token: ${{ secrets.GITHUB_TOKEN }}
8582
parallel-finished: true
8683

87-
build-example:
84+
build-flutter-example:
8885
needs: analyze
8986
runs-on: 'macos-latest'
9087
defaults:
9188
run:
92-
working-directory: pkgs/objective_c/example/
89+
working-directory: pkgs/objective_c/example/flutter_app
9390
steps:
9491
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
9592
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
9693
with:
97-
channel: 'stable'
94+
channel: stable
9895
- name: Install dependencies
9996
run: flutter pub get
100-
- name: Build the example app
97+
- name: Build the example app for macos
10198
run: flutter build macos
99+
- name: Build the example app for ios
100+
run: flutter build ios --no-codesign
102101
- name: Check for xcode for analyzer warnings
103102
run: xcodebuild analyze -workspace macos/Runner.xcworkspace -scheme Runner -configuration Debug GCC_TREAT_WARNINGS_AS_ERRORS=YES
103+
104+
build-command-line-example:
105+
needs: analyze
106+
runs-on: 'macos-latest'
107+
defaults:
108+
run:
109+
working-directory: pkgs/objective_c/example/command_line
110+
steps:
111+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
112+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
113+
with:
114+
sdk: stable
115+
- name: Install dependencies
116+
run: dart pub get
117+
- name: Run the example app
118+
run: dart run lib/main.dart
119+
120+

.github/workflows/swift2objc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name: swift2objc
33
on:
44
# Run on PRs and pushes to the default branch.
55
push:
6-
branches: [main, stable]
6+
branches: [main]
77
paths:
88
- '.github/workflows/swift2objc.yaml'
99
- 'pkgs/native_test_helpers/**'
1010
- 'pkgs/swift2objc/**'
1111
pull_request:
12-
branches: [main, stable]
12+
branches: [main]
1313
paths:
1414
- '.github/workflows/swift2objc.yaml'
1515
- 'pkgs/native_test_helpers/**'

.github/workflows/swiftgen.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: swiftgen
33
on:
44
# Run on PRs and pushes to the default branch.
55
push:
6-
branches: [main, stable]
6+
branches: [main]
77
paths:
88
- '.github/workflows/swiftgen.yaml'
99
- 'pkgs/ffigen/**'
@@ -12,7 +12,7 @@ on:
1212
- 'pkgs/swift2objc/**'
1313
- 'pkgs/swiftgen/**'
1414
pull_request:
15-
branches: [main, stable]
15+
branches: [main]
1616
paths:
1717
- '.github/workflows/swiftgen.yaml'
1818
- 'pkgs/ffigen/**'
@@ -39,10 +39,10 @@ jobs:
3939
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
4040
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
4141
with:
42-
channel: 'stable'
42+
channel: master
4343
- id: install
4444
name: Install dependencies
45-
run: flutter pub get
45+
run: dart pub get && dart pub get --directory="example"
4646
- name: Check formatting
4747
run: dart format --output=none --set-exit-if-changed .
4848
if: always() && steps.install.outcome == 'success'
@@ -60,16 +60,9 @@ jobs:
6060
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
6161
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
6262
with:
63-
channel: 'stable'
63+
channel: master
6464
- name: Install dependencies
65-
run: flutter pub get
66-
- name: Install ObjC dependencies
67-
working-directory: pkgs/objective_c/
68-
run: flutter pub get
69-
- name: Build ObjC test dylib
70-
working-directory: pkgs/objective_c/
71-
# TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
72-
run: dart test/setup.dart
65+
run: dart pub get
7366
- name: Install coverage
7467
run: dart pub global activate coverage
7568
- name: Run VM tests and collect coverage

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ doc/api/
9494
# Files generated by tests for debugging purposes.
9595
**/test/debug_generated/*
9696
coverage/
97+
**/temp/
9798

9899
## Downloaded files and build artifacts
99100
*.jar

pkgs/ffigen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 20.1.1
2+
3+
- Update tests and examples now that package:objective_c is using native assets.
4+
15
## 20.1.0
26

37
- Add `xcodeUri`, `iosSdkUri`, and `macSdkUri`, to mirror `xcodePath`,

pkgs/ffigen/example/objective_c/play_audio.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ import 'dart:ffi';
66

77
import 'package:objective_c/objective_c.dart';
88

9-
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
10-
import '../../../objective_c/test/setup.dart' as objc_setup;
119
import 'avf_audio_bindings.dart';
1210

1311
const _dylibPath =
1412
'/System/Library/Frameworks/AVFAudio.framework/Versions/Current/AVFAudio';
1513

1614
void main(List<String> args) async {
17-
objc_setup.main([]);
1815
DynamicLibrary.open(_dylibPath);
1916
for (final file in args) {
2017
final fileStr = NSString(file);

pkgs/ffigen/example/swift/example.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ import 'dart:ffi';
66

77
import 'package:objective_c/objective_c.dart';
88

9-
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
10-
import '../../../objective_c/test/setup.dart' as objc_setup;
119
import 'swift_api_bindings.dart';
1210

1311
void main() {
14-
objc_setup.main([]);
15-
1612
// TODO(https://github.com/dart-lang/ffigen/issues/443): Add a test for this.
1713
DynamicLibrary.open('libswiftapi.dylib');
1814
final object = SwiftClass();

pkgs/ffigen/lib/src/code_generator/objc_built_in_types.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,3 @@ const objCBuiltInCategories = {
141141
'NSNumberIsFloat',
142142
'NSStringExtensionMethods',
143143
};
144-
145-
const objCBuiltInGlobals = {
146-
'NSKeyValueChangeIndexesKey',
147-
'NSKeyValueChangeKindKey',
148-
'NSKeyValueChangeNewKey',
149-
'NSKeyValueChangeNotificationIsPriorKey',
150-
'NSKeyValueChangeOldKey',
151-
'NSLocalizedDescriptionKey',
152-
};

0 commit comments

Comments
 (0)