diff --git a/.github/workflows/ffigen.yml b/.github/workflows/ffigen.yml index 1c4bf03e62..04cdc5e271 100644 --- a/.github/workflows/ffigen.yml +++ b/.github/workflows/ffigen.yml @@ -10,7 +10,7 @@ on: - 'pkgs/ffigen/**' - 'pkgs/objective_c/**' pull_request: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/ffigen.yml' - 'pkgs/ffigen/**' @@ -34,17 +34,17 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: stable - id: install name: Install dependencies - run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" && flutter pub get --directory="example/add" + run: dart pub get && dart pub get --directory="example/shared_bindings" && dart pub get --directory="../objective_c" && dart pub get --directory="example/add" - name: Check formatting run: dart format --output=none --set-exit-if-changed . if: always() && steps.install.outcome == 'success' - name: Build test dylib and bindings run: dart --enable-asserts test/setup.dart - name: Analyze code - run: flutter analyze --fatal-infos + run: dart analyze --fatal-infos test-linux: needs: analyze @@ -56,9 +56,9 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: stable - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../jni" + run: dart pub get && flutter pub get --directory="../jni" - name: Install libclang-14-dev run: sudo apt-get install libclang-14-dev - name: Build test dylib and bindings @@ -82,7 +82,7 @@ jobs: with: channel: stable - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni" + run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni" - name: Install clang-format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: @@ -92,7 +92,7 @@ jobs: - name: Install coverage run: dart pub global activate coverage - name: Run VM tests and collect coverage - run: dart pub global run coverage:test_with_coverage --scope-output=ffigen --scope-output=objective_c + run: dart test --coverage-path=./coverage/lcov.info - name: Generate package:jni bindings run: dart --enable-asserts run tool/generate_ffi_bindings.dart working-directory: pkgs/jni/ @@ -120,16 +120,16 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: master + channel: stable - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni" + run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni" - name: Install clang-format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: brew: clang-format - name: Build test dylib and bindings run: dart --enable-asserts test/setup.dart - - name: Run VM tests and collect coverage + - name: Run VM tests run: dart test test-mac-flutter: @@ -142,13 +142,13 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: stable - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../objective_c" + run: dart pub get && dart pub get --directory="../objective_c" - name: Build test dylib and bindings - run: dart --enable-asserts test/setup.dart --main-thread-dispatcher + run: dart --enable-asserts test/setup.dart - name: Run Flutter tests - run: flutter test + run: dart test test-windows: needs: analyze @@ -160,9 +160,9 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: stable - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../jni" + run: dart pub get && flutter pub get --directory="../jni" - name: Build test dylib and bindings run: dart --enable-asserts test/setup.dart - name: Run VM tests @@ -191,7 +191,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: "master" + channel: stable - name: Install dependencies run: flutter pub get - name: Build test dylib and bindings diff --git a/.github/workflows/ffigen_weekly.yml b/.github/workflows/ffigen_weekly.yml index 3759899d02..1063a77c2d 100644 --- a/.github/workflows/ffigen_weekly.yml +++ b/.github/workflows/ffigen_weekly.yml @@ -6,11 +6,11 @@ name: ffigen_weekly on: # Run once a week. push: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/ffigen_weekly.yml' pull_request: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/ffigen_weekly.yml' schedule: @@ -30,17 +30,17 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: stable - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni" + run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni" - name: Install clang-format uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 with: brew: clang-format - name: Build test dylib and bindings - run: dart --enable-asserts test/setup.dart --main-thread-dispatcher + run: dart --enable-asserts test/setup.dart - name: Run VM tests - run: flutter test + run: dart test - name: Generate package:jni bindings run: dart --enable-asserts run tool/generate_ffi_bindings.dart working-directory: pkgs/jni/ diff --git a/.github/workflows/objective_c.yaml b/.github/workflows/objective_c.yaml index e2ebf8942e..13bb54f98d 100644 --- a/.github/workflows/objective_c.yaml +++ b/.github/workflows/objective_c.yaml @@ -3,14 +3,14 @@ name: objective_c on: # Run on PRs and pushes to the default branch. push: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/objective_c.yaml' - 'pkgs/ffigen/**' - 'pkgs/native_test_helpers/**' - 'pkgs/objective_c/**' pull_request: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/objective_c.yaml' - 'pkgs/ffigen/**' @@ -35,10 +35,10 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: stable - id: install name: Install dependencies - run: flutter pub get + run: flutter pub get && flutter pub get --directory="example/command_line" && flutter pub get --directory="example/flutter_app" - name: Check formatting run: dart format --output=none --set-exit-if-changed . if: always() && steps.install.outcome == 'success' @@ -54,14 +54,11 @@ jobs: working-directory: pkgs/objective_c/ steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: - channel: 'beta' + sdk: stable - name: Install dependencies - run: flutter pub get - - name: Build test dylib - # TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - run: dart --enable-asserts test/setup.dart + run: dart pub get - name: Install coverage run: dart pub global activate coverage - name: Run VM tests and collect coverage @@ -84,20 +81,40 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true - build-example: + build-flutter-example: needs: analyze runs-on: 'macos-latest' defaults: run: - working-directory: pkgs/objective_c/example/ + working-directory: pkgs/objective_c/example/flutter_app steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: stable - name: Install dependencies run: flutter pub get - - name: Build the example app + - name: Build the example app for macos run: flutter build macos + - name: Build the example app for ios + run: flutter build ios --no-codesign - name: Check for xcode for analyzer warnings run: xcodebuild analyze -workspace macos/Runner.xcworkspace -scheme Runner -configuration Debug GCC_TREAT_WARNINGS_AS_ERRORS=YES + + build-command-line-example: + needs: analyze + runs-on: 'macos-latest' + defaults: + run: + working-directory: pkgs/objective_c/example/command_line + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + with: + sdk: stable + - name: Install dependencies + run: dart pub get + - name: Run the example app + run: dart run lib/main.dart + + diff --git a/.github/workflows/swift2objc.yaml b/.github/workflows/swift2objc.yaml index 1c12994b7b..3eb31ec4b4 100644 --- a/.github/workflows/swift2objc.yaml +++ b/.github/workflows/swift2objc.yaml @@ -3,13 +3,13 @@ name: swift2objc on: # Run on PRs and pushes to the default branch. push: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/swift2objc.yaml' - 'pkgs/native_test_helpers/**' - 'pkgs/swift2objc/**' pull_request: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/swift2objc.yaml' - 'pkgs/native_test_helpers/**' diff --git a/.github/workflows/swiftgen.yaml b/.github/workflows/swiftgen.yaml index a78d2b52ce..6d580422c7 100644 --- a/.github/workflows/swiftgen.yaml +++ b/.github/workflows/swiftgen.yaml @@ -3,7 +3,7 @@ name: swiftgen on: # Run on PRs and pushes to the default branch. push: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/swiftgen.yaml' - 'pkgs/ffigen/**' @@ -12,7 +12,7 @@ on: - 'pkgs/swift2objc/**' - 'pkgs/swiftgen/**' pull_request: - branches: [main, stable] + branches: [main] paths: - '.github/workflows/swiftgen.yaml' - 'pkgs/ffigen/**' @@ -39,10 +39,10 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: master - id: install name: Install dependencies - run: flutter pub get + run: dart pub get && dart pub get --directory="example" - name: Check formatting run: dart format --output=none --set-exit-if-changed . if: always() && steps.install.outcome == 'success' @@ -60,16 +60,9 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e with: - channel: 'stable' + channel: master - name: Install dependencies - run: flutter pub get - - name: Install ObjC dependencies - working-directory: pkgs/objective_c/ - run: flutter pub get - - name: Build ObjC test dylib - working-directory: pkgs/objective_c/ - # TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - run: dart test/setup.dart + run: dart pub get - name: Install coverage run: dart pub global activate coverage - name: Run VM tests and collect coverage diff --git a/.gitignore b/.gitignore index 52dbcbe07a..09a3ceb87a 100644 --- a/.gitignore +++ b/.gitignore @@ -94,6 +94,7 @@ doc/api/ # Files generated by tests for debugging purposes. **/test/debug_generated/* coverage/ +**/temp/ ## Downloaded files and build artifacts *.jar diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md index d2a2b4bd28..f0498d6f5b 100644 --- a/pkgs/ffigen/CHANGELOG.md +++ b/pkgs/ffigen/CHANGELOG.md @@ -1,3 +1,7 @@ +## 20.1.1 + +- Update tests and examples now that package:objective_c is using native assets. + ## 20.1.0 - Add `xcodeUri`, `iosSdkUri`, and `macSdkUri`, to mirror `xcodePath`, diff --git a/pkgs/ffigen/example/objective_c/play_audio.dart b/pkgs/ffigen/example/objective_c/play_audio.dart index 0c402a32e2..82686d5bd8 100644 --- a/pkgs/ffigen/example/objective_c/play_audio.dart +++ b/pkgs/ffigen/example/objective_c/play_audio.dart @@ -6,15 +6,12 @@ import 'dart:ffi'; import 'package:objective_c/objective_c.dart'; -// TODO(https://github.com/dart-lang/native/issues/1068): Remove this. -import '../../../objective_c/test/setup.dart' as objc_setup; import 'avf_audio_bindings.dart'; const _dylibPath = '/System/Library/Frameworks/AVFAudio.framework/Versions/Current/AVFAudio'; void main(List args) async { - objc_setup.main([]); DynamicLibrary.open(_dylibPath); for (final file in args) { final fileStr = NSString(file); diff --git a/pkgs/ffigen/example/swift/example.dart b/pkgs/ffigen/example/swift/example.dart index 20b5eb81a5..26bee45762 100644 --- a/pkgs/ffigen/example/swift/example.dart +++ b/pkgs/ffigen/example/swift/example.dart @@ -6,13 +6,9 @@ import 'dart:ffi'; import 'package:objective_c/objective_c.dart'; -// TODO(https://github.com/dart-lang/native/issues/1068): Remove this. -import '../../../objective_c/test/setup.dart' as objc_setup; import 'swift_api_bindings.dart'; void main() { - objc_setup.main([]); - // TODO(https://github.com/dart-lang/ffigen/issues/443): Add a test for this. DynamicLibrary.open('libswiftapi.dylib'); final object = SwiftClass(); diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_types.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_types.dart index 3dc0ec5be1..ff71acd329 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_types.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_types.dart @@ -141,12 +141,3 @@ const objCBuiltInCategories = { 'NSNumberIsFloat', 'NSStringExtensionMethods', }; - -const objCBuiltInGlobals = { - 'NSKeyValueChangeIndexesKey', - 'NSKeyValueChangeKindKey', - 'NSKeyValueChangeNewKey', - 'NSKeyValueChangeNotificationIsPriorKey', - 'NSKeyValueChangeOldKey', - 'NSLocalizedDescriptionKey', -}; diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml index 4cc6485c38..ff69afbe7c 100644 --- a/pkgs/ffigen/pubspec.yaml +++ b/pkgs/ffigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: ffigen -version: 20.1.0 +version: 20.1.1-dev description: > Generator for FFI bindings, using LibClang to parse C, Objective-C, and Swift files. @@ -40,12 +40,15 @@ dev_dependencies: dart_flutter_team_lints: ^3.5.2 json_schema: ^5.1.1 leak_tracker: ^10.0.7 - objective_c: ^9.0.0 - test: ^1.16.2 + objective_c: ^9.2.0 + test: ^1.26.2 dependency_overrides: - # package:objective_c has a flutter dependency, so `dart test` must be run - # using the dart from the flutter SDK. - # See https://github.com/dart-lang/native/issues/1068 + code_assets: + path: ../code_assets + hooks: + path: ../hooks + native_toolchain_c: + path: ../native_toolchain_c objective_c: - path: ../objective_c/ + path: ../objective_c diff --git a/pkgs/ffigen/test/native_objc_test/arc_test.dart b/pkgs/ffigen/test/native_objc_test/arc_test.dart index e74a62cc64..887fd8ab75 100644 --- a/pkgs/ffigen/test/native_objc_test/arc_test.dart +++ b/pkgs/ffigen/test/native_objc_test/arc_test.dart @@ -20,16 +20,6 @@ void main() { group('ARC', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/bad_method_test.dart b/pkgs/ffigen/test/native_objc_test/bad_method_test.dart index 3f7d3f6db6..23ad2a8047 100644 --- a/pkgs/ffigen/test/native_objc_test/bad_method_test.dart +++ b/pkgs/ffigen/test/native_objc_test/bad_method_test.dart @@ -16,16 +16,6 @@ import 'util.dart'; void main() { group('bad_method_test', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/bad_override_test.dart b/pkgs/ffigen/test/native_objc_test/bad_override_test.dart index 93ae37ec5c..f358199661 100644 --- a/pkgs/ffigen/test/native_objc_test/bad_override_test.dart +++ b/pkgs/ffigen/test/native_objc_test/bad_override_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('bad overrides', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/block_annotation_test.dart b/pkgs/ffigen/test/native_objc_test/block_annotation_test.dart index fc46283320..cc2ca26cc1 100644 --- a/pkgs/ffigen/test/native_objc_test/block_annotation_test.dart +++ b/pkgs/ffigen/test/native_objc_test/block_annotation_test.dart @@ -35,16 +35,6 @@ void main() { // correct block type. setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/block_inherit_test.dart b/pkgs/ffigen/test/native_objc_test/block_inherit_test.dart index 7b84a63f4f..49aa586e61 100644 --- a/pkgs/ffigen/test/native_objc_test/block_inherit_test.dart +++ b/pkgs/ffigen/test/native_objc_test/block_inherit_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('Block inheritance', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/block_test.dart b/pkgs/ffigen/test/native_objc_test/block_test.dart index eb5a510fe5..699edf10b3 100644 --- a/pkgs/ffigen/test/native_objc_test/block_test.dart +++ b/pkgs/ffigen/test/native_objc_test/block_test.dart @@ -52,16 +52,6 @@ void main() { group('Blocks', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/cast_test.dart b/pkgs/ffigen/test/native_objc_test/cast_test.dart index 4d23f4b670..abc4afafad 100644 --- a/pkgs/ffigen/test/native_objc_test/cast_test.dart +++ b/pkgs/ffigen/test/native_objc_test/cast_test.dart @@ -20,16 +20,6 @@ void main() { group('cast', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/category_test.dart b/pkgs/ffigen/test/native_objc_test/category_test.dart index 5970ca5ec8..e05ab426f1 100644 --- a/pkgs/ffigen/test/native_objc_test/category_test.dart +++ b/pkgs/ffigen/test/native_objc_test/category_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('categories', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/enum_test.dart b/pkgs/ffigen/test/native_objc_test/enum_test.dart index 616b3d2c0f..0fb8d44ab0 100644 --- a/pkgs/ffigen/test/native_objc_test/enum_test.dart +++ b/pkgs/ffigen/test/native_objc_test/enum_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('enum', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/error_method_test.dart b/pkgs/ffigen/test/native_objc_test/error_method_test.dart index 904aa7bb00..44e81ab5d2 100644 --- a/pkgs/ffigen/test/native_objc_test/error_method_test.dart +++ b/pkgs/ffigen/test/native_objc_test/error_method_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('error_method_test', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/forward_decl_test.dart b/pkgs/ffigen/test/native_objc_test/forward_decl_test.dart index 6557b058c7..0d7324689a 100644 --- a/pkgs/ffigen/test/native_objc_test/forward_decl_test.dart +++ b/pkgs/ffigen/test/native_objc_test/forward_decl_test.dart @@ -16,16 +16,6 @@ import 'util.dart'; void main() { group('forward decl', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.dart b/pkgs/ffigen/test/native_objc_test/global_native_test.dart index 8bc4436991..0a74ab98c0 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_native_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('global using @Native', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/global_test.dart b/pkgs/ffigen/test/native_objc_test/global_test.dart index 7c6192805c..99563a14eb 100644 --- a/pkgs/ffigen/test/native_objc_test/global_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_test.dart @@ -20,16 +20,6 @@ void main() { late GlobalTestObjCLibrary lib; setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/inherited_instancetype_test.dart b/pkgs/ffigen/test/native_objc_test/inherited_instancetype_test.dart index a70df0700e..9e2345e8fe 100644 --- a/pkgs/ffigen/test/native_objc_test/inherited_instancetype_test.dart +++ b/pkgs/ffigen/test/native_objc_test/inherited_instancetype_test.dart @@ -17,16 +17,6 @@ import 'util.dart'; void main() { group('inheritedInstancetype', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/is_instance_test.dart b/pkgs/ffigen/test/native_objc_test/is_instance_test.dart index 8db6ee0329..f315c2b3a5 100644 --- a/pkgs/ffigen/test/native_objc_test/is_instance_test.dart +++ b/pkgs/ffigen/test/native_objc_test/is_instance_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('isInstance', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/isolate_test.dart b/pkgs/ffigen/test/native_objc_test/isolate_test.dart index 1ebdb4f9c9..4fd7ebf0ee 100644 --- a/pkgs/ffigen/test/native_objc_test/isolate_test.dart +++ b/pkgs/ffigen/test/native_objc_test/isolate_test.dart @@ -20,16 +20,6 @@ import 'util.dart'; void main() { group('isolate', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/log_test.dart b/pkgs/ffigen/test/native_objc_test/log_test.dart index ece9447f71..071655307c 100644 --- a/pkgs/ffigen/test/native_objc_test/log_test.dart +++ b/pkgs/ffigen/test/native_objc_test/log_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('log_test', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/method_filtering_test.dart b/pkgs/ffigen/test/native_objc_test/method_filtering_test.dart index 94c66b654e..7ddd0a286d 100644 --- a/pkgs/ffigen/test/native_objc_test/method_filtering_test.dart +++ b/pkgs/ffigen/test/native_objc_test/method_filtering_test.dart @@ -24,7 +24,6 @@ void main() { group('no version info', () { late final String bindings; setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. generateBindingsForCoverage('method_filtering'); bindings = File( path.join( diff --git a/pkgs/ffigen/test/native_objc_test/method_test.dart b/pkgs/ffigen/test/native_objc_test/method_test.dart index de03b95b27..03d6da67c1 100644 --- a/pkgs/ffigen/test/native_objc_test/method_test.dart +++ b/pkgs/ffigen/test/native_objc_test/method_test.dart @@ -19,16 +19,6 @@ void main() { group('method calls', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/native_objc_test.dart b/pkgs/ffigen/test/native_objc_test/native_objc_test.dart index 9c52091377..3b88eaecda 100644 --- a/pkgs/ffigen/test/native_objc_test/native_objc_test.dart +++ b/pkgs/ffigen/test/native_objc_test/native_objc_test.dart @@ -17,16 +17,6 @@ import 'util.dart'; void main() { group('native_objc_test', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/nullable_inheritance_test.dart b/pkgs/ffigen/test/native_objc_test/nullable_inheritance_test.dart index 98112a9875..18b95fe5e9 100644 --- a/pkgs/ffigen/test/native_objc_test/nullable_inheritance_test.dart +++ b/pkgs/ffigen/test/native_objc_test/nullable_inheritance_test.dart @@ -21,16 +21,6 @@ void main() { late NSObject obj; group('Nullable inheritance', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/nullable_test.dart b/pkgs/ffigen/test/native_objc_test/nullable_test.dart index 76b220a2a2..5c8051878f 100644 --- a/pkgs/ffigen/test/native_objc_test/nullable_test.dart +++ b/pkgs/ffigen/test/native_objc_test/nullable_test.dart @@ -20,16 +20,6 @@ void main() { late NSObject obj; group('Nullability', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/property_test.dart b/pkgs/ffigen/test/native_objc_test/property_test.dart index 8bd3cd942b..e8ebf7d695 100644 --- a/pkgs/ffigen/test/native_objc_test/property_test.dart +++ b/pkgs/ffigen/test/native_objc_test/property_test.dart @@ -20,16 +20,6 @@ void main() { group('properties', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/protocol_test.dart b/pkgs/ffigen/test/native_objc_test/protocol_test.dart index 2e7694d7b3..adceff4ddd 100644 --- a/pkgs/ffigen/test/native_objc_test/protocol_test.dart +++ b/pkgs/ffigen/test/native_objc_test/protocol_test.dart @@ -29,16 +29,6 @@ void main() { group('protocol', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/ref_count_test.dart b/pkgs/ffigen/test/native_objc_test/ref_count_test.dart index dc5684aa73..c0fc3eaeec 100644 --- a/pkgs/ffigen/test/native_objc_test/ref_count_test.dart +++ b/pkgs/ffigen/test/native_objc_test/ref_count_test.dart @@ -20,16 +20,6 @@ void main() { group('Reference counting', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/rename_test.dart b/pkgs/ffigen/test/native_objc_test/rename_test.dart index c55820dbad..ab6d0c3333 100644 --- a/pkgs/ffigen/test/native_objc_test/rename_test.dart +++ b/pkgs/ffigen/test/native_objc_test/rename_test.dart @@ -17,16 +17,6 @@ import 'util.dart'; void main() { group('rename_test', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/runtime_version_test.dart b/pkgs/ffigen/test/native_objc_test/runtime_version_test.dart index 5fe3a40526..c0faf1f626 100644 --- a/pkgs/ffigen/test/native_objc_test/runtime_version_test.dart +++ b/pkgs/ffigen/test/native_objc_test/runtime_version_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('runtime version check', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/sdk_variable_test.dart b/pkgs/ffigen/test/native_objc_test/sdk_variable_test.dart index de383b7f12..ee4ac5de64 100644 --- a/pkgs/ffigen/test/native_objc_test/sdk_variable_test.dart +++ b/pkgs/ffigen/test/native_objc_test/sdk_variable_test.dart @@ -17,16 +17,6 @@ void main() { late String bindings; setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/setup.dart b/pkgs/ffigen/test/native_objc_test/setup.dart index 68f9f3625e..db2e80a5e7 100644 --- a/pkgs/ffigen/test/native_objc_test/setup.dart +++ b/pkgs/ffigen/test/native_objc_test/setup.dart @@ -166,7 +166,6 @@ Future clean(List testNames) async { Future main(List arguments) async { final parser = ArgParser(); parser.addFlag('clean'); - parser.addFlag('main-thread-dispatcher'); final args = parser.parse(arguments); // Allow running this script directly from any path (or an IDE). @@ -179,9 +178,5 @@ Future main(List arguments) async { return await clean(_getTestNames()); } - await _runDart([ - '../objective_c/test/setup.dart', - if (args.flag('main-thread-dispatcher')) '--main-thread-dispatcher', - ]); return await build(args.rest.isNotEmpty ? args.rest : _getTestNames()); } diff --git a/pkgs/ffigen/test/native_objc_test/static_func_native_test.dart b/pkgs/ffigen/test/native_objc_test/static_func_native_test.dart index 337ce6fc9b..328128a75d 100644 --- a/pkgs/ffigen/test/native_objc_test/static_func_native_test.dart +++ b/pkgs/ffigen/test/native_objc_test/static_func_native_test.dart @@ -23,16 +23,6 @@ typedef IntBlock = ObjCBlock_Int32_Int32; void main() { group('static functions', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/static_func_test.dart b/pkgs/ffigen/test/native_objc_test/static_func_test.dart index 07a881533e..d7edaaf79b 100644 --- a/pkgs/ffigen/test/native_objc_test/static_func_test.dart +++ b/pkgs/ffigen/test/native_objc_test/static_func_test.dart @@ -25,16 +25,6 @@ void main() { group('static functions', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/string_test.dart b/pkgs/ffigen/test/native_objc_test/string_test.dart index c46d9cd214..dc79057009 100644 --- a/pkgs/ffigen/test/native_objc_test/string_test.dart +++ b/pkgs/ffigen/test/native_objc_test/string_test.dart @@ -18,16 +18,6 @@ import 'util.dart'; void main() { group('string', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/swift_class_test.dart b/pkgs/ffigen/test/native_objc_test/swift_class_test.dart index 964e9e1bae..5b4cf28f0d 100644 --- a/pkgs/ffigen/test/native_objc_test/swift_class_test.dart +++ b/pkgs/ffigen/test/native_objc_test/swift_class_test.dart @@ -16,16 +16,6 @@ import 'util.dart'; void main() { group('swift_class_test', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/typedef_test.dart b/pkgs/ffigen/test/native_objc_test/typedef_test.dart index 0ee3392148..179ccdf208 100644 --- a/pkgs/ffigen/test/native_objc_test/typedef_test.dart +++ b/pkgs/ffigen/test/native_objc_test/typedef_test.dart @@ -16,16 +16,6 @@ import 'util.dart'; void main() { group('typedef', () { setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open( - path.join( - packagePathForTests, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', - ), - ); final dylib = File( path.join( packagePathForTests, diff --git a/pkgs/ffigen/test/native_objc_test/util.dart b/pkgs/ffigen/test/native_objc_test/util.dart index 40f0c0d28e..1ed2a3b6f3 100644 --- a/pkgs/ffigen/test/native_objc_test/util.dart +++ b/pkgs/ffigen/test/native_objc_test/util.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@DefaultAsset('package:objective_c/objective_c.dylib') +library; + import 'dart:ffi'; import 'dart:io'; diff --git a/pkgs/ffigen/test/setup.dart b/pkgs/ffigen/test/setup.dart index e64008a9eb..812765a45e 100644 --- a/pkgs/ffigen/test/setup.dart +++ b/pkgs/ffigen/test/setup.dart @@ -8,8 +8,6 @@ import 'dart:async'; import 'dart:io'; -import 'package:args/args.dart'; - Future _run(String subdir, String script, List flags) async { final dir = Platform.script.resolve('$subdir/'); print('\nRunning $script in ${dir.toFilePath()}'); @@ -33,15 +31,9 @@ Future _run(String subdir, String script, List flags) async { } Future main(List arguments) async { - final parser = ArgParser(); - parser.addFlag('main-thread-dispatcher'); - final args = parser.parse(arguments); - await _run('native_test', 'build_test_dylib.dart', []); if (Platform.isMacOS) { - await _run('native_objc_test', 'setup.dart', [ - if (args.flag('main-thread-dispatcher')) '--main-thread-dispatcher', - ]); + await _run('native_objc_test', 'setup.dart', []); } print('\nSuccess :)\n'); } diff --git a/pkgs/objective_c/CHANGELOG.md b/pkgs/objective_c/CHANGELOG.md index 1728319792..05c5a1f260 100644 --- a/pkgs/objective_c/CHANGELOG.md +++ b/pkgs/objective_c/CHANGELOG.md @@ -1,3 +1,8 @@ +## 9.2.0 + +- Migrate to from a Flutter plugin to native assets. This enables + package:objective_c to be used in command line apps. + ## 9.1.0 - Use FFIgen 20.1.0 diff --git a/pkgs/objective_c/example/README.md b/pkgs/objective_c/example/README.md deleted file mode 100644 index ef2deb7f61..0000000000 --- a/pkgs/objective_c/example/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# objective_c example - -Demonstrates how to use the objective_c plugin. - -TODO(https://github.com/dart-lang/native/issues/1068): Migrate to native assets. diff --git a/pkgs/objective_c/example/analysis_options.yaml b/pkgs/objective_c/example/analysis_options.yaml deleted file mode 100644 index a5744c1cfb..0000000000 --- a/pkgs/objective_c/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/objective_c/example/command_line/README.md b/pkgs/objective_c/example/command_line/README.md new file mode 100644 index 0000000000..9d9d2e46eb --- /dev/null +++ b/pkgs/objective_c/example/command_line/README.md @@ -0,0 +1 @@ +Demonstrates using package:objective_c: `dart run lib/main.dart` diff --git a/pkgs/objective_c/example/command_line/analysis_options.yaml b/pkgs/objective_c/example/command_line/analysis_options.yaml new file mode 100644 index 0000000000..572dd239d0 --- /dev/null +++ b/pkgs/objective_c/example/command_line/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml diff --git a/pkgs/objective_c/example/command_line/lib/main.dart b/pkgs/objective_c/example/command_line/lib/main.dart new file mode 100644 index 0000000000..6bf9da655a --- /dev/null +++ b/pkgs/objective_c/example/command_line/lib/main.dart @@ -0,0 +1,10 @@ +import 'dart:io'; + +import 'package:objective_c/objective_c.dart'; + +void main() { + // Objective-C is only supported on macOS and iOS. + assert(Platform.isMacOS || Platform.isIOS); + + print('Hello World'.toNSString().toDartString()); +} diff --git a/pkgs/objective_c/example/command_line/pubspec.yaml b/pkgs/objective_c/example/command_line/pubspec.yaml new file mode 100644 index 0000000000..ff6cf0f7ad --- /dev/null +++ b/pkgs/objective_c/example/command_line/pubspec.yaml @@ -0,0 +1,15 @@ +name: example +description: "Demonstrates using package:objective_c" +version: 1.0.0 +publish_to: none + +environment: + sdk: '>=3.9.0-21.0.dev <4.0.0' + +dependencies: + objective_c: + path: ../.. + +dev_dependencies: + lints: ^5.0.0 + test: ^1.27.0 diff --git a/pkgs/objective_c/example/flutter_app/.gitignore b/pkgs/objective_c/example/flutter_app/.gitignore new file mode 100644 index 0000000000..3820a95c65 --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/pkgs/objective_c/.metadata b/pkgs/objective_c/example/flutter_app/.metadata similarity index 57% rename from pkgs/objective_c/.metadata rename to pkgs/objective_c/example/flutter_app/.metadata index a41ab896bb..f740eced88 100644 --- a/pkgs/objective_c/.metadata +++ b/pkgs/objective_c/example/flutter_app/.metadata @@ -4,23 +4,23 @@ # This file should be version controlled and should not be manually edited. version: - revision: "aedce673f760bc19f13aa0600e2c1df9ae502117" - channel: "master" + revision: "f5a8537f90d143abd5bb2f658fa69c388da9677b" + channel: "stable" -project_type: plugin_ffi +project_type: app # Tracks metadata for the flutter migrate command migration: platforms: - platform: root - create_revision: aedce673f760bc19f13aa0600e2c1df9ae502117 - base_revision: aedce673f760bc19f13aa0600e2c1df9ae502117 + create_revision: f5a8537f90d143abd5bb2f658fa69c388da9677b + base_revision: f5a8537f90d143abd5bb2f658fa69c388da9677b - platform: ios - create_revision: aedce673f760bc19f13aa0600e2c1df9ae502117 - base_revision: aedce673f760bc19f13aa0600e2c1df9ae502117 + create_revision: f5a8537f90d143abd5bb2f658fa69c388da9677b + base_revision: f5a8537f90d143abd5bb2f658fa69c388da9677b - platform: macos - create_revision: aedce673f760bc19f13aa0600e2c1df9ae502117 - base_revision: aedce673f760bc19f13aa0600e2c1df9ae502117 + create_revision: f5a8537f90d143abd5bb2f658fa69c388da9677b + base_revision: f5a8537f90d143abd5bb2f658fa69c388da9677b # User provided section diff --git a/pkgs/objective_c/example/flutter_app/README.md b/pkgs/objective_c/example/flutter_app/README.md new file mode 100644 index 0000000000..cbc07659ec --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/README.md @@ -0,0 +1,3 @@ +# flutter_app + +A new Flutter project. diff --git a/pkgs/objective_c/example/flutter_app/analysis_options.yaml b/pkgs/objective_c/example/flutter_app/analysis_options.yaml new file mode 100644 index 0000000000..f9b303465f --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/pkgs/objective_c/example/flutter_app/ios/.gitignore b/pkgs/objective_c/example/flutter_app/ios/.gitignore new file mode 100644 index 0000000000..7a7f9873ad --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/pkgs/objective_c/example/ios/Flutter/AppFrameworkInfo.plist b/pkgs/objective_c/example/flutter_app/ios/Flutter/AppFrameworkInfo.plist similarity index 96% rename from pkgs/objective_c/example/ios/Flutter/AppFrameworkInfo.plist rename to pkgs/objective_c/example/flutter_app/ios/Flutter/AppFrameworkInfo.plist index 7c56964006..1dc6cf7652 100644 --- a/pkgs/objective_c/example/ios/Flutter/AppFrameworkInfo.plist +++ b/pkgs/objective_c/example/flutter_app/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 12.0 + 13.0 diff --git a/pkgs/objective_c/example/flutter_app/ios/Flutter/Debug.xcconfig b/pkgs/objective_c/example/flutter_app/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/pkgs/objective_c/example/flutter_app/ios/Flutter/Release.xcconfig b/pkgs/objective_c/example/flutter_app/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000000..592ceee85b --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/pkgs/objective_c/example/ios/Runner.xcodeproj/project.pbxproj b/pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.pbxproj similarity index 75% rename from pkgs/objective_c/example/ios/Runner.xcodeproj/project.pbxproj rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.pbxproj index 8f49bdf9e3..b3b97e3250 100644 --- a/pkgs/objective_c/example/ios/Runner.xcodeproj/project.pbxproj +++ b/pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.pbxproj @@ -7,11 +7,9 @@ objects = { /* Begin PBXBuildFile section */ - 0016C0D0D056FCD78A6A33E8 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5349C2B3D454EF3220FB3306 /* Pods_RunnerTests.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 4D7C7CB911925A31801A2F1E /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B910B6B0374F2338E70D6AC /* Pods_Runner.framework */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; @@ -42,16 +40,11 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 0B910B6B0374F2338E70D6AC /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 5349C2B3D454EF3220FB3306 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 5898EAFA36C90FEB069D15C8 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; - 5E623BDE574BD3F02055F373 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; - 6F2BCFFFCABF2D8A79F17D26 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -62,9 +55,6 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - B6F1E5A6A7CC24D81665E0BA /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - F794A460162AE19694C18D43 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; - FFB0D24362152330E942673E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -72,30 +62,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 4D7C7CB911925A31801A2F1E /* Pods_Runner.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B209388E6951AC88C18EE569 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 0016C0D0D056FCD78A6A33E8 /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 2961EE994295B641DF59D533 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 0B910B6B0374F2338E70D6AC /* Pods_Runner.framework */, - 5349C2B3D454EF3220FB3306 /* Pods_RunnerTests.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; 331C8082294A63A400263BE5 /* RunnerTests */ = { isa = PBXGroup; children = ( @@ -122,8 +94,6 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, - 97F4D88CC18AF014179906AC /* Pods */, - 2961EE994295B641DF59D533 /* Frameworks */, ); sourceTree = ""; }; @@ -151,20 +121,6 @@ path = Runner; sourceTree = ""; }; - 97F4D88CC18AF014179906AC /* Pods */ = { - isa = PBXGroup; - children = ( - FFB0D24362152330E942673E /* Pods-Runner.debug.xcconfig */, - 6F2BCFFFCABF2D8A79F17D26 /* Pods-Runner.release.xcconfig */, - B6F1E5A6A7CC24D81665E0BA /* Pods-Runner.profile.xcconfig */, - 5E623BDE574BD3F02055F373 /* Pods-RunnerTests.debug.xcconfig */, - F794A460162AE19694C18D43 /* Pods-RunnerTests.release.xcconfig */, - 5898EAFA36C90FEB069D15C8 /* Pods-RunnerTests.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -172,10 +128,8 @@ isa = PBXNativeTarget; buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - 11218719EF64897AFE1F9EE8 /* [CP] Check Pods Manifest.lock */, 331C807D294A63A400263BE5 /* Sources */, 331C807F294A63A400263BE5 /* Resources */, - B209388E6951AC88C18EE569 /* Frameworks */, ); buildRules = ( ); @@ -191,14 +145,12 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - E0D32FA7EF8A23FC0FD30465 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 98CA06E4ED3E0BFB8A3C613F /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -270,28 +222,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 11218719EF64897AFE1F9EE8 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -323,45 +253,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - 98CA06E4ED3E0BFB8A3C613F /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - E0D32FA7EF8A23FC0FD30465 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -455,7 +346,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -471,13 +362,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = HY6BJPQR3W; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.objCFlutterApp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -487,14 +379,13 @@ }; 331C8088294A63A400263BE5 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5E623BDE574BD3F02055F373 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterApp.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -505,14 +396,13 @@ }; 331C8089294A63A400263BE5 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F794A460162AE19694C18D43 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterApp.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -521,14 +411,13 @@ }; 331C808A294A63A400263BE5 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5898EAFA36C90FEB069D15C8 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterApp.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -584,7 +473,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -635,7 +524,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -653,13 +542,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = HY6BJPQR3W; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.objCFlutterApp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -675,13 +565,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = HY6BJPQR3W; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.objCFlutterApp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/pkgs/objective_c/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from pkgs/objective_c/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/pkgs/objective_c/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from pkgs/objective_c/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/pkgs/objective_c/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings similarity index 100% rename from pkgs/objective_c/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/pkgs/objective_c/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 95% rename from pkgs/objective_c/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8e3ca5dfe1..e3773d42e2 100644 --- a/pkgs/objective_c/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/pkgs/objective_c/example/flutter_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/pkgs/objective_c/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/pkgs/objective_c/example/flutter_app/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 67% rename from pkgs/objective_c/example/ios/Runner.xcworkspace/contents.xcworkspacedata rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcworkspace/contents.xcworkspacedata index 21a3cc14c7..1d526a16ed 100644 --- a/pkgs/objective_c/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/pkgs/objective_c/example/flutter_app/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,7 +4,4 @@ - - diff --git a/pkgs/objective_c/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/pkgs/objective_c/example/flutter_app/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from pkgs/objective_c/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/pkgs/objective_c/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/pkgs/objective_c/example/flutter_app/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings similarity index 100% rename from pkgs/objective_c/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to pkgs/objective_c/example/flutter_app/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/pkgs/objective_c/example/ios/Runner/AppDelegate.swift b/pkgs/objective_c/example/flutter_app/ios/Runner/AppDelegate.swift similarity index 100% rename from pkgs/objective_c/example/ios/Runner/AppDelegate.swift rename to pkgs/objective_c/example/flutter_app/ios/Runner/AppDelegate.swift diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to pkgs/objective_c/example/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/pkgs/objective_c/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/pkgs/objective_c/example/flutter_app/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to pkgs/objective_c/example/flutter_app/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/pkgs/objective_c/example/ios/Runner/Base.lproj/Main.storyboard b/pkgs/objective_c/example/flutter_app/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Base.lproj/Main.storyboard rename to pkgs/objective_c/example/flutter_app/ios/Runner/Base.lproj/Main.storyboard diff --git a/pkgs/objective_c/example/ios/Runner/Info.plist b/pkgs/objective_c/example/flutter_app/ios/Runner/Info.plist similarity index 95% rename from pkgs/objective_c/example/ios/Runner/Info.plist rename to pkgs/objective_c/example/flutter_app/ios/Runner/Info.plist index 8bbbc6dc9a..cc87a7f2e7 100644 --- a/pkgs/objective_c/example/ios/Runner/Info.plist +++ b/pkgs/objective_c/example/flutter_app/ios/Runner/Info.plist @@ -2,10 +2,12 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - Objective C + Flutter App CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -13,7 +15,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - objective_c_example + flutter_app CFBundlePackageType APPL CFBundleShortVersionString @@ -24,6 +26,8 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -41,9 +45,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - diff --git a/pkgs/objective_c/example/ios/Runner/Runner-Bridging-Header.h b/pkgs/objective_c/example/flutter_app/ios/Runner/Runner-Bridging-Header.h similarity index 100% rename from pkgs/objective_c/example/ios/Runner/Runner-Bridging-Header.h rename to pkgs/objective_c/example/flutter_app/ios/Runner/Runner-Bridging-Header.h diff --git a/pkgs/objective_c/example/ios/RunnerTests/RunnerTests.swift b/pkgs/objective_c/example/flutter_app/ios/RunnerTests/RunnerTests.swift similarity index 100% rename from pkgs/objective_c/example/ios/RunnerTests/RunnerTests.swift rename to pkgs/objective_c/example/flutter_app/ios/RunnerTests/RunnerTests.swift diff --git a/pkgs/objective_c/example/lib/main.dart b/pkgs/objective_c/example/flutter_app/lib/main.dart similarity index 85% rename from pkgs/objective_c/example/lib/main.dart rename to pkgs/objective_c/example/flutter_app/lib/main.dart index e6c44abd11..2291ff2176 100644 --- a/pkgs/objective_c/example/lib/main.dart +++ b/pkgs/objective_c/example/flutter_app/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -23,7 +23,7 @@ class _MainAppState extends State { void initState() { super.initState(); - message = NSString('Hello World!').toString(); + message = NSString('Hello World!').toDartString(); } @override diff --git a/pkgs/objective_c/example/flutter_app/macos/.gitignore b/pkgs/objective_c/example/flutter_app/macos/.gitignore new file mode 100644 index 0000000000..746adbb6b9 --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/pkgs/objective_c/example/flutter_app/macos/Flutter/Flutter-Debug.xcconfig b/pkgs/objective_c/example/flutter_app/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/pkgs/objective_c/example/flutter_app/macos/Flutter/Flutter-Release.xcconfig b/pkgs/objective_c/example/flutter_app/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000000..c2efd0b608 --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/pkgs/objective_c/example/macos/Runner.xcodeproj/project.pbxproj b/pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/project.pbxproj similarity index 77% rename from pkgs/objective_c/example/macos/Runner.xcodeproj/project.pbxproj rename to pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/project.pbxproj index 7fb6863fbd..e8e96edff6 100644 --- a/pkgs/objective_c/example/macos/Runner.xcodeproj/project.pbxproj +++ b/pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/project.pbxproj @@ -27,8 +27,6 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 5C3BF24AE85F5C730B12E1C3 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 76CD4A3B26D45B1D35ED40BC /* Pods_Runner.framework */; }; - 98677E5D0F050EAF7F207C67 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6A9FB1952D96C5AEFCA4D69B /* Pods_RunnerTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -62,12 +60,11 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 253A21F847FB1AF244672D0E /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* objective_c_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = objective_c_example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* flutter_app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "flutter_app.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -79,15 +76,8 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 6A9FB1952D96C5AEFCA4D69B /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 76CD4A3B26D45B1D35ED40BC /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - AC25B0021603A0772CA9840F /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; - E5900647B1760244CA95C2A6 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - E739196F186306D59FB11177 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - ECD2E4ECDB0FCE6DA971A318 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; - EE079268A4FB02480F3FCA89 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -95,7 +85,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 98677E5D0F050EAF7F207C67 /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -103,7 +92,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 5C3BF24AE85F5C730B12E1C3 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -137,14 +125,13 @@ 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, - 96BE0B041091E6177B65072F /* Pods */, ); sourceTree = ""; }; 33CC10EE2044A3C60003C045 /* Products */ = { isa = PBXGroup; children = ( - 33CC10ED2044A3C60003C045 /* objective_c_example.app */, + 33CC10ED2044A3C60003C045 /* flutter_app.app */, 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, ); name = Products; @@ -185,25 +172,9 @@ path = Runner; sourceTree = ""; }; - 96BE0B041091E6177B65072F /* Pods */ = { - isa = PBXGroup; - children = ( - EE079268A4FB02480F3FCA89 /* Pods-Runner.debug.xcconfig */, - E739196F186306D59FB11177 /* Pods-Runner.release.xcconfig */, - E5900647B1760244CA95C2A6 /* Pods-Runner.profile.xcconfig */, - ECD2E4ECDB0FCE6DA971A318 /* Pods-RunnerTests.debug.xcconfig */, - AC25B0021603A0772CA9840F /* Pods-RunnerTests.release.xcconfig */, - 253A21F847FB1AF244672D0E /* Pods-RunnerTests.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( - 76CD4A3B26D45B1D35ED40BC /* Pods_Runner.framework */, - 6A9FB1952D96C5AEFCA4D69B /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -215,7 +186,6 @@ isa = PBXNativeTarget; buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - DD8A915821E91B2D640F20A1 /* [CP] Check Pods Manifest.lock */, 331C80D1294CF70F00263BE5 /* Sources */, 331C80D2294CF70F00263BE5 /* Frameworks */, 331C80D3294CF70F00263BE5 /* Resources */, @@ -234,13 +204,11 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - FF16D30B988DB2BCD781BB14 /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - 774CDE4872C6F2C91B1264E0 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -249,7 +217,7 @@ ); name = Runner; productName = Runner; - productReference = 33CC10ED2044A3C60003C045 /* objective_c_example.app */; + productReference = 33CC10ED2044A3C60003C045 /* flutter_app.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -361,67 +329,6 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; - 774CDE4872C6F2C91B1264E0 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - DD8A915821E91B2D640F20A1 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - FF16D30B988DB2BCD781BB14 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -473,46 +380,43 @@ /* Begin XCBuildConfiguration section */ 331C80DB294CF71000263BE5 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = ECD2E4ECDB0FCE6DA971A318 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterApp.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/objective_c_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/objective_c_example"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_app"; }; name = Debug; }; 331C80DC294CF71000263BE5 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = AC25B0021603A0772CA9840F /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterApp.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/objective_c_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/objective_c_example"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_app"; }; name = Release; }; 331C80DD294CF71000263BE5 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 253A21F847FB1AF244672D0E /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterApp.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/objective_c_example.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/objective_c_example"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_app"; }; name = Profile; }; @@ -557,7 +461,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -639,7 +543,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -689,7 +593,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/pkgs/objective_c/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from pkgs/objective_c/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/pkgs/objective_c/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 93% rename from pkgs/objective_c/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87f478474..1a7ee8ef66 100644 --- a/pkgs/objective_c/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/pkgs/objective_c/example/flutter_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -15,7 +15,7 @@ @@ -31,7 +31,7 @@ @@ -59,13 +59,14 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" + enableGPUValidationMode = "1" allowLocationSimulation = "YES"> @@ -82,7 +83,7 @@ diff --git a/pkgs/objective_c/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/pkgs/objective_c/example/flutter_app/macos/Runner.xcworkspace/contents.xcworkspacedata similarity index 67% rename from pkgs/objective_c/example/macos/Runner.xcworkspace/contents.xcworkspacedata rename to pkgs/objective_c/example/flutter_app/macos/Runner.xcworkspace/contents.xcworkspacedata index 21a3cc14c7..1d526a16ed 100644 --- a/pkgs/objective_c/example/macos/Runner.xcworkspace/contents.xcworkspacedata +++ b/pkgs/objective_c/example/flutter_app/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -4,7 +4,4 @@ - - diff --git a/pkgs/objective_c/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/pkgs/objective_c/example/flutter_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from pkgs/objective_c/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to pkgs/objective_c/example/flutter_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/pkgs/objective_c/example/macos/Runner/AppDelegate.swift b/pkgs/objective_c/example/flutter_app/macos/Runner/AppDelegate.swift similarity index 100% rename from pkgs/objective_c/example/macos/Runner/AppDelegate.swift rename to pkgs/objective_c/example/flutter_app/macos/Runner/AppDelegate.swift diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png diff --git a/pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png rename to pkgs/objective_c/example/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png diff --git a/pkgs/objective_c/example/macos/Runner/Base.lproj/MainMenu.xib b/pkgs/objective_c/example/flutter_app/macos/Runner/Base.lproj/MainMenu.xib similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Base.lproj/MainMenu.xib rename to pkgs/objective_c/example/flutter_app/macos/Runner/Base.lproj/MainMenu.xib diff --git a/pkgs/objective_c/example/macos/Runner/Configs/AppInfo.xcconfig b/pkgs/objective_c/example/flutter_app/macos/Runner/Configs/AppInfo.xcconfig similarity index 71% rename from pkgs/objective_c/example/macos/Runner/Configs/AppInfo.xcconfig rename to pkgs/objective_c/example/flutter_app/macos/Runner/Configs/AppInfo.xcconfig index 50d7b8686b..0ce4218346 100644 --- a/pkgs/objective_c/example/macos/Runner/Configs/AppInfo.xcconfig +++ b/pkgs/objective_c/example/flutter_app/macos/Runner/Configs/AppInfo.xcconfig @@ -5,10 +5,10 @@ // 'flutter create' template. // The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = objective_c_example +PRODUCT_NAME = flutter_app // The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.github.dartlang.objectiveCExample +PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterApp // The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright © 2024 com.github.dart_lang. All rights reserved. +PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. diff --git a/pkgs/objective_c/example/macos/Runner/Configs/Debug.xcconfig b/pkgs/objective_c/example/flutter_app/macos/Runner/Configs/Debug.xcconfig similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Configs/Debug.xcconfig rename to pkgs/objective_c/example/flutter_app/macos/Runner/Configs/Debug.xcconfig diff --git a/pkgs/objective_c/example/macos/Runner/Configs/Release.xcconfig b/pkgs/objective_c/example/flutter_app/macos/Runner/Configs/Release.xcconfig similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Configs/Release.xcconfig rename to pkgs/objective_c/example/flutter_app/macos/Runner/Configs/Release.xcconfig diff --git a/pkgs/objective_c/example/macos/Runner/Configs/Warnings.xcconfig b/pkgs/objective_c/example/flutter_app/macos/Runner/Configs/Warnings.xcconfig similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Configs/Warnings.xcconfig rename to pkgs/objective_c/example/flutter_app/macos/Runner/Configs/Warnings.xcconfig diff --git a/pkgs/objective_c/example/macos/Runner/DebugProfile.entitlements b/pkgs/objective_c/example/flutter_app/macos/Runner/DebugProfile.entitlements similarity index 100% rename from pkgs/objective_c/example/macos/Runner/DebugProfile.entitlements rename to pkgs/objective_c/example/flutter_app/macos/Runner/DebugProfile.entitlements diff --git a/pkgs/objective_c/example/macos/Runner/Info.plist b/pkgs/objective_c/example/flutter_app/macos/Runner/Info.plist similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Info.plist rename to pkgs/objective_c/example/flutter_app/macos/Runner/Info.plist diff --git a/pkgs/objective_c/example/macos/Runner/MainFlutterWindow.swift b/pkgs/objective_c/example/flutter_app/macos/Runner/MainFlutterWindow.swift similarity index 100% rename from pkgs/objective_c/example/macos/Runner/MainFlutterWindow.swift rename to pkgs/objective_c/example/flutter_app/macos/Runner/MainFlutterWindow.swift diff --git a/pkgs/objective_c/example/macos/Runner/Release.entitlements b/pkgs/objective_c/example/flutter_app/macos/Runner/Release.entitlements similarity index 100% rename from pkgs/objective_c/example/macos/Runner/Release.entitlements rename to pkgs/objective_c/example/flutter_app/macos/Runner/Release.entitlements diff --git a/pkgs/objective_c/example/macos/RunnerTests/RunnerTests.swift b/pkgs/objective_c/example/flutter_app/macos/RunnerTests/RunnerTests.swift similarity index 100% rename from pkgs/objective_c/example/macos/RunnerTests/RunnerTests.swift rename to pkgs/objective_c/example/flutter_app/macos/RunnerTests/RunnerTests.swift diff --git a/pkgs/objective_c/example/flutter_app/pubspec.yaml b/pkgs/objective_c/example/flutter_app/pubspec.yaml new file mode 100644 index 0000000000..a8dc3ec009 --- /dev/null +++ b/pkgs/objective_c/example/flutter_app/pubspec.yaml @@ -0,0 +1,21 @@ +name: flutter_app +description: "A new Flutter project." +publish_to: 'none' +version: 0.1.0 + +environment: + sdk: ^3.10.0 + +dependencies: + flutter: + sdk: flutter + objective_c: + path: ../.. + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^6.0.0 + +flutter: + uses-material-design: true diff --git a/pkgs/objective_c/example/ios/Flutter/Debug.xcconfig b/pkgs/objective_c/example/ios/Flutter/Debug.xcconfig deleted file mode 100644 index ec97fc6f30..0000000000 --- a/pkgs/objective_c/example/ios/Flutter/Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" -#include "Generated.xcconfig" diff --git a/pkgs/objective_c/example/ios/Flutter/Release.xcconfig b/pkgs/objective_c/example/ios/Flutter/Release.xcconfig deleted file mode 100644 index c4855bfe20..0000000000 --- a/pkgs/objective_c/example/ios/Flutter/Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" -#include "Generated.xcconfig" diff --git a/pkgs/objective_c/example/ios/Podfile b/pkgs/objective_c/example/ios/Podfile deleted file mode 100644 index d97f17e223..0000000000 --- a/pkgs/objective_c/example/ios/Podfile +++ /dev/null @@ -1,44 +0,0 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '12.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_ios_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) - target 'RunnerTests' do - inherit! :search_paths - end -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_ios_build_settings(target) - end -end diff --git a/pkgs/objective_c/example/macos/Flutter/Flutter-Debug.xcconfig b/pkgs/objective_c/example/macos/Flutter/Flutter-Debug.xcconfig deleted file mode 100644 index 4b81f9b2d2..0000000000 --- a/pkgs/objective_c/example/macos/Flutter/Flutter-Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/pkgs/objective_c/example/macos/Flutter/Flutter-Release.xcconfig b/pkgs/objective_c/example/macos/Flutter/Flutter-Release.xcconfig deleted file mode 100644 index 5caa9d1579..0000000000 --- a/pkgs/objective_c/example/macos/Flutter/Flutter-Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/pkgs/objective_c/example/macos/Podfile b/pkgs/objective_c/example/macos/Podfile deleted file mode 100644 index c795730db8..0000000000 --- a/pkgs/objective_c/example/macos/Podfile +++ /dev/null @@ -1,43 +0,0 @@ -platform :osx, '10.14' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_macos_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) - target 'RunnerTests' do - inherit! :search_paths - end -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_macos_build_settings(target) - end -end diff --git a/pkgs/objective_c/example/pubspec.yaml b/pkgs/objective_c/example/pubspec.yaml deleted file mode 100644 index 0b0e53e86f..0000000000 --- a/pkgs/objective_c/example/pubspec.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -# for details. All rights reserved. Use of this source code is governed by a -# BSD-style license that can be found in the LICENSE file. - -name: example -description: "Demonstrates using package:objective_c" -publish_to: 'none' -version: 0.1.0 - -environment: - sdk: '>=3.8.0 <4.0.0' - flutter: '>=3.32.0' - -dependencies: - ffi: ^2.1.0 - flutter: - sdk: flutter - objective_c: - path: .. - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^6.0.0 - -flutter: - uses-material-design: true diff --git a/pkgs/objective_c/ffigen_c.yaml b/pkgs/objective_c/ffigen_c.yaml index 4c062a2f0f..a41cf5cfc9 100644 --- a/pkgs/objective_c/ffigen_c.yaml +++ b/pkgs/objective_c/ffigen_c.yaml @@ -6,28 +6,20 @@ headers: entry-points: - 'src/include/dart_api_dl.h' - 'src/objective_c.h' - - 'src/objective_c_runtime.h' - 'src/os_version.h' ffi-native: - assetId: 'objective_c.framework/objective_c' + asset-id: 'package:objective_c/objective_c.dylib' exclude-all-by-default: true generate-for-package-objective-c: true sort: true functions: include: - - 'objc_.*' - - 'object_getClass' - - 'sel_registerName' - - 'sel_getName' - - 'protocol_getMethodDescription' - - 'protocol_getName' - 'newFinalizableHandle' - 'DOBJC_.*' leaf: include: - '.*' exclude: - - 'objc_msgSend.*' - 'DOBJC_deleteFinalizableHandle' - 'DOBJC_disposeObjCBlockWithClosure' - 'DOBJC_newFinalizableBool' @@ -35,33 +27,11 @@ functions: - 'DOBJC_awaitWaiter' rename: 'DOBJC_(.*)': '$1' - 'sel_registerName': 'registerName' - 'sel_getName': 'getName' - 'objc_getClass': 'getClass' - 'objc_retain': 'objectRetain' - 'objc_retainBlock': 'blockRetain' - 'objc_release': 'objectRelease' - 'objc_autorelease': 'objectAutorelease' - 'objc_msgSend': 'msgSend' - 'objc_msgSend_fpret': 'msgSendFpret' - 'objc_msgSend_stret': 'msgSendStret' - 'object_getClass': 'getObjectClass' - 'objc_copyClassList': 'copyClassList' - 'objc_getProtocol': 'getProtocol' - 'objc_autoreleasePoolPush': 'autoreleasePoolPush' - 'objc_autoreleasePoolPop': 'autoreleasePoolPop' - 'protocol_getMethodDescription': 'getMethodDescription' - 'protocol_getName': 'getProtocolName' -globals: - include: - - '_NSConcrete.*Block' - rename: - '_(.*)': '$1' typedefs: include: - 'Dart_FinalizableHandle' structs: - include : + include: - '_DOBJC_Context' rename: '_ObjC(.*)': 'ObjC$1' @@ -75,7 +45,7 @@ preamble: | // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. - // Bindings for `src/objective_c.h` and `src/objective_c_runtime.h`. + // Bindings for `src/objective_c.h` etc. // Regenerate bindings with `dart run tool/generate_code.dart`. // coverage:ignore-file diff --git a/pkgs/objective_c/ffigen_objc.yaml b/pkgs/objective_c/ffigen_objc.yaml index be99e8d504..a0eccc9d88 100644 --- a/pkgs/objective_c/ffigen_objc.yaml +++ b/pkgs/objective_c/ffigen_objc.yaml @@ -13,10 +13,13 @@ headers: - 'src/observer.h' - 'src/protocol.h' ffi-native: + asset-id: 'package:objective_c/objective_c.dylib' exclude-all-by-default: true include-transitive-objc-categories: false generate-for-package-objective-c: true sort: true +library-imports: + collection: 'dart:collection' external-versions: # See https://docs.flutter.dev/reference/supported-platforms. ios: @@ -174,14 +177,6 @@ enums: - NSURLBookmarkCreationOptions - NSURLBookmarkResolutionOptions - NSURLHandleStatus -globals: - include: - - NSKeyValueChangeIndexesKey - - NSKeyValueChangeKindKey - - NSKeyValueChangeNewKey - - NSKeyValueChangeNotificationIsPriorKey - - NSKeyValueChangeOldKey - - NSLocalizedDescriptionKey typedefs: include: - 'CFStringRef' @@ -190,7 +185,7 @@ preamble: | // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. - // Bindings for `src/foundation.h`. + // Bindings for package:objective_c's ObjC code and the Foundation framework. // Regenerate bindings with `dart run tool/generate_code.dart`. // coverage:ignore-file diff --git a/pkgs/objective_c/ffigen_runtime.yaml b/pkgs/objective_c/ffigen_runtime.yaml new file mode 100644 index 0000000000..5d14eeaf7d --- /dev/null +++ b/pkgs/objective_c/ffigen_runtime.yaml @@ -0,0 +1,71 @@ +# Generate bindings for the ObjC runtime headers. +# Regenerate bindings with `dart run tool/generate_code.dart`. +name: RuntimeBindings +output: 'lib/src/runtime_bindings_generated.dart' +headers: + entry-points: + - 'src/objective_c_runtime.h' +ffi-native: +exclude-all-by-default: true +generate-for-package-objective-c: true +sort: true +functions: + include: + - 'objc_.*' + - 'object_getClass' + - 'sel_registerName' + - 'sel_getName' + - 'protocol_getMethodDescription' + - 'protocol_getName' + leaf: + include: + - '.*' + exclude: + - 'objc_msgSend.*' + rename: + 'sel_registerName': 'registerName' + 'sel_getName': 'getName' + 'objc_getClass': 'getClass' + 'objc_retain': 'objectRetain' + 'objc_retainBlock': 'blockRetain' + 'objc_release': 'objectRelease' + 'objc_autorelease': 'objectAutorelease' + 'objc_msgSend': 'msgSend' + 'objc_msgSend_fpret': 'msgSendFpret' + 'objc_msgSend_stret': 'msgSendStret' + 'object_getClass': 'getObjectClass' + 'objc_copyClassList': 'copyClassList' + 'objc_getProtocol': 'getProtocol' + 'objc_autoreleasePoolPush': 'autoreleasePoolPush' + 'objc_autoreleasePoolPop': 'autoreleasePoolPop' + 'protocol_getMethodDescription': 'getMethodDescription' + 'protocol_getName': 'getProtocolName' +globals: + include: + - '_NSConcrete.*Block' + - NSKeyValueChangeIndexesKey + - NSKeyValueChangeKindKey + - NSKeyValueChangeNewKey + - NSKeyValueChangeNotificationIsPriorKey + - NSKeyValueChangeOldKey + - NSLocalizedDescriptionKey + rename: + '_(.*)': '$1' +structs: + include: + - '_ObjC.*' + rename: + '_ObjC(.*)': 'ObjC$1' +preamble: | + // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file + // for details. All rights reserved. Use of this source code is governed by a + // BSD-style license that can be found in the LICENSE file. + + // Bindings for `src/objective_c_runtime.h`. + // Regenerate bindings with `dart run tool/generate_code.dart`. + + // ignore_for_file: always_specify_types + // ignore_for_file: camel_case_types + // ignore_for_file: non_constant_identifier_names + // ignore_for_file: unused_element + // coverage:ignore-file diff --git a/pkgs/objective_c/hook/build.dart b/pkgs/objective_c/hook/build.dart new file mode 100644 index 0000000000..30e46093da --- /dev/null +++ b/pkgs/objective_c/hook/build.dart @@ -0,0 +1,152 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:code_assets/code_assets.dart'; +import 'package:hooks/hooks.dart'; +import 'package:logging/logging.dart'; +import 'package:native_toolchain_c/src/cbuilder/compiler_resolver.dart'; + +const objCFlags = ['-x', 'objective-c', '-fobjc-arc']; + +String sdkPath = firstLineOfStdout('xcrun', ['--show-sdk-path']); + +const assetName = 'objective_c.dylib'; + +// TODO(https://github.com/dart-lang/native/issues/2272): Remove this from the +// main build. +const extraCFiles = ['test/util.c']; + +final logger = Logger('') + ..level = Level.INFO + ..onRecord.listen((record) { + print('${record.level.name}: ${record.time}: ${record.message}'); + }); + +void main(List args) async { + await build(args, (input, output) async { + const supportedOSs = {OS.iOS, OS.macOS}; + final os = input.config.code.targetOS; + if (!supportedOSs.contains(os)) { + // Nothing to do. + return; + } + + if (input.config.code.linkModePreference == LinkModePreference.static) { + throw UnsupportedError('LinkModePreference.static is not supported.'); + } + + final packageName = input.packageName; + final assetPath = input.outputDirectory.resolve(assetName); + final srcDir = Directory.fromUri(input.packageRoot.resolve('src/')); + + final arch = input.config.code.targetArchitecture; + final target = '${clangArchName(arch)}-apple-${os.name}'; + + final cFiles = []; + final mFiles = []; + final hFiles = []; + for (final file in srcDir.listSync(recursive: true)) { + if (file is File) { + final path = file.path; + if (path.endsWith('.c')) cFiles.add(path); + if (path.endsWith('.m')) mFiles.add(path); + if (path.endsWith('.h')) hFiles.add(path); + } + } + + cFiles.addAll(extraCFiles.map((f) => input.packageRoot.resolve(f).path)); + + final cFlags = ['-isysroot', sdkPath, '-target', target]; + final mFlags = [...cFlags, ...objCFlags]; + final linkFlags = cFlags; + + final builder = await Builder.create(input, input.packageRoot.path); + + final objectFiles = await Future.wait(>[ + for (final src in cFiles) builder.buildObject(src, cFlags), + for (final src in mFiles) builder.buildObject(src, mFlags), + ]); + await builder.linkLib(objectFiles, assetPath.toFilePath(), linkFlags); + + output.dependencies.addAll(cFiles.map(Uri.file)); + output.dependencies.addAll(mFiles.map(Uri.file)); + output.dependencies.addAll(hFiles.map(Uri.file)); + + output.assets.code.add( + CodeAsset( + package: packageName, + name: assetName, + file: assetPath, + linkMode: DynamicLoadingBundled(), + ), + ); + }); +} + +class Builder { + final String _comp; + final String _rootDir; + final Uri _tempOutDir; + Builder._(this._comp, this._rootDir, this._tempOutDir); + + static Future create(BuildInput input, String rootDir) async { + final resolver = CompilerResolver( + codeConfig: input.config.code, + logger: logger, + ); + return Builder._( + (await resolver.resolveCompiler()).uri.toFilePath(), + rootDir, + input.outputDirectory.resolve('obj/'), + ); + } + + Future buildObject(String input, List flags) async { + assert(input.startsWith(_rootDir)); + final relativeInput = input.substring(_rootDir.length); + final output = '${_tempOutDir.resolve(relativeInput).path}.o'; + File(output).parent.createSync(recursive: true); + await _compile([...flags, '-c', input, '-fpic', '-I', 'src'], output); + return output; + } + + Future linkLib( + List objects, + String output, + List flags, + ) => _compile([ + '-shared', + '-undefined', + 'dynamic_lookup', + ...flags, + ...objects, + ], output); + + Future _compile(List flags, String output) async { + final args = [...flags, '-o', output]; + logger.info('Running: $_comp ${args.join(" ")}'); + final proc = await Process.run(_comp, args); + logger.info(proc.stdout); + logger.info(proc.stderr); + if (proc.exitCode != 0) { + exitCode = proc.exitCode; + throw Exception('Command failed: $_comp ${args.join(" ")}'); + } + logger.info('Generated $output'); + } +} + +String firstLineOfStdout(String cmd, List args) { + final result = Process.runSync(cmd, args); + assert(result.exitCode == 0); + return (result.stdout as String) + .split('\n') + .where((line) => line.isNotEmpty) + .first; +} + +String clangArchName(Architecture arch) => + arch == Architecture.x64 ? 'x86_64' : arch.name; diff --git a/pkgs/objective_c/ios/Classes/objective_c.c b/pkgs/objective_c/ios/Classes/objective_c.c deleted file mode 100644 index 6d9c021cce..0000000000 --- a/pkgs/objective_c/ios/Classes/objective_c.c +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Relative import to be able to reuse the C sources. -// See the comment in ../objective_c.podspec for more information. -#include "../../src/objective_c.c" -#include "../../src/include/dart_api_dl.c" diff --git a/pkgs/objective_c/ios/Classes/objective_c.m b/pkgs/objective_c/ios/Classes/objective_c.m deleted file mode 100644 index bb195a9e0b..0000000000 --- a/pkgs/objective_c/ios/Classes/objective_c.m +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Relative import to be able to reuse the ObjC sources. -// See the comment in ../objective_c.podspec for more information. -#include "../../src/input_stream_adapter.m" -#include "../../src/objective_c.m" -#include "../../src/objective_c_bindings_generated.m" -#include "../../src/ns_number.m" -#include "../../src/observer.m" -#include "../../src/protocol.m" diff --git a/pkgs/objective_c/ios/objective_c.podspec b/pkgs/objective_c/ios/objective_c.podspec deleted file mode 100644 index e784ccd7c0..0000000000 --- a/pkgs/objective_c/ios/objective_c.podspec +++ /dev/null @@ -1,28 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint objective_c.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'objective_c' - s.version = '0.0.1' - s.summary = 'A library to access Objective C from Flutter that acts as a support library for package:ffigen.' - s.description = <<-DESC -A library to access Objective C from Flutter that acts as a support library for package:ffigen. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - # This will ensure the source files in Classes/ are included in the native - # builds of apps using this FFI plugin. Podspec does not support relative - # paths, so Classes contains a forwarder C file that relatively imports - # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.dependency 'Flutter' - s.platform = :ios, '12.0' - - # Flutter.framework does not contain a i386 slice. - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } - s.swift_version = '5.0' -end diff --git a/pkgs/objective_c/lib/objective_c.dart b/pkgs/objective_c/lib/objective_c.dart index e984c24ef2..b581977be3 100644 --- a/pkgs/objective_c/lib/objective_c.dart +++ b/pkgs/objective_c/lib/objective_c.dart @@ -11,16 +11,10 @@ export 'src/c_bindings_generated.dart' Dart_FinalizableHandle_, ObjCBlockDesc, ObjCBlockImpl, - ObjCMethodDesc, - ObjCObjectImpl, - ObjCProtocolImpl, - ObjCSelector, - blockRetain, - objectRelease, - objectRetain, signalWaiter; export 'src/cf_string.dart'; export 'src/converter.dart'; +export 'src/globals.dart'; export 'src/internal.dart' hide blockHasRegisteredClosure, isValidBlock, isValidClass, isValidObject; export 'src/ns_array.dart'; @@ -37,4 +31,13 @@ export 'src/objective_c_bindings_exported.dart'; export 'src/observer.dart'; export 'src/os_version.dart'; export 'src/protocol_builder.dart'; +export 'src/runtime_bindings_generated.dart' + show + ObjCMethodDesc, + ObjCObjectImpl, + ObjCProtocolImpl, + ObjCSelector, + blockRetain, + objectRelease, + objectRetain; export 'src/selector.dart'; diff --git a/pkgs/objective_c/lib/src/autorelease.dart b/pkgs/objective_c/lib/src/autorelease.dart index b770bf8fb7..56f4d0b728 100644 --- a/pkgs/objective_c/lib/src/autorelease.dart +++ b/pkgs/objective_c/lib/src/autorelease.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'c_bindings_generated.dart'; +import 'runtime_bindings_generated.dart'; /// Creates an Objective-C autorelease pool, runs [function], then releases the /// pool. diff --git a/pkgs/objective_c/lib/src/c_bindings_generated.dart b/pkgs/objective_c/lib/src/c_bindings_generated.dart index d9c307bcee..1e4dabcc13 100644 --- a/pkgs/objective_c/lib/src/c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/c_bindings_generated.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// Bindings for `src/objective_c.h` and `src/objective_c_runtime.h`. +// Bindings for `src/objective_c.h` etc. // Regenerate bindings with `dart run tool/generate_code.dart`. // coverage:ignore-file @@ -11,67 +11,16 @@ // // Generated by `package:ffigen`. // ignore_for_file: type=lint, unused_import -@ffi.DefaultAsset('objective_c.framework/objective_c') +@ffi.DefaultAsset('package:objective_c/objective_c.dylib') library; import 'dart:ffi' as ffi; -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: '_NSConcreteAutoBlock') -external ffi.Array> NSConcreteAutoBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>( - symbol: '_NSConcreteFinalizingBlock', -) -external ffi.Array> NSConcreteFinalizingBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: '_NSConcreteGlobalBlock') -external ffi.Array> NSConcreteGlobalBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: '_NSConcreteMallocBlock') -external ffi.Array> NSConcreteMallocBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: '_NSConcreteStackBlock') -external ffi.Array> NSConcreteStackBlock; - -@ffi.Native)>( - symbol: 'objc_autoreleasePoolPop', - isLeaf: true, -) -external void autoreleasePoolPop(ffi.Pointer pool); - -@ffi.Native Function()>( - symbol: 'objc_autoreleasePoolPush', - isLeaf: true, -) -external ffi.Pointer autoreleasePoolPush(); - @ffi.Native)>( symbol: 'DOBJC_awaitWaiter', ) external void awaitWaiter(ffi.Pointer waiter); -@ffi.Native Function(ffi.Pointer)>( - symbol: 'objc_retainBlock', - isLeaf: true, -) -external ffi.Pointer blockRetain( - ffi.Pointer object, -); - -@ffi.Native< - ffi.Pointer> Function( - ffi.Pointer, - ) ->(symbol: 'objc_copyClassList', isLeaf: true) -external ffi.Pointer> copyClassList( - ffi.Pointer count, -); - @ffi.Native( symbol: 'DOBJC_deleteFinalizableHandle', ) @@ -93,59 +42,10 @@ external ffi.Pointer fillContext( ffi.Pointer context, ); -@ffi.Native Function(ffi.Pointer)>( - symbol: 'objc_getClass', - isLeaf: true, -) -external ffi.Pointer getClass(ffi.Pointer name); - -@ffi.Native< - ObjCMethodDesc Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ffi.Bool, - ) ->(symbol: 'protocol_getMethodDescription', isLeaf: true) -external ObjCMethodDesc getMethodDescription( - ffi.Pointer protocol, - ffi.Pointer sel, - bool isRequiredMethod, - bool isInstanceMethod, -); - -@ffi.Native Function(ffi.Pointer)>( - symbol: 'sel_getName', - isLeaf: true, -) -external ffi.Pointer getName(ffi.Pointer sel); - -@ffi.Native Function(ffi.Pointer)>( - symbol: 'object_getClass', - isLeaf: true, -) -external ffi.Pointer getObjectClass( - ffi.Pointer object, -); - /// Returns the MacOS/iOS version we're running on. @ffi.Native<_Version Function()>(symbol: 'DOBJC_getOsVesion', isLeaf: true) external _Version getOsVesion(); -@ffi.Native Function(ffi.Pointer)>( - symbol: 'objc_getProtocol', - isLeaf: true, -) -external ffi.Pointer getProtocol(ffi.Pointer name); - -@ffi.Native Function(ffi.Pointer)>( - symbol: 'protocol_getName', - isLeaf: true, -) -external ffi.Pointer getProtocolName( - ffi.Pointer proto, -); - @ffi.Native)>( symbol: 'DOBJC_initializeApi', isLeaf: true, @@ -158,15 +58,6 @@ external int initializeApi(ffi.Pointer data); ) external bool isValidBlock(ffi.Pointer block); -@ffi.Native(symbol: 'objc_msgSend') -external void msgSend(); - -@ffi.Native(symbol: 'objc_msgSend_fpret') -external void msgSendFpret(); - -@ffi.Native(symbol: 'objc_msgSend_stret') -external void msgSendStret(); - @ffi.Native Function(ffi.Handle)>( symbol: 'DOBJC_newFinalizableBool', ) @@ -186,34 +77,6 @@ external Dart_FinalizableHandle newFinalizableHandle( ) external ffi.Pointer newWaiter(); -@ffi.Native Function(ffi.Pointer)>( - symbol: 'objc_autorelease', - isLeaf: true, -) -external ffi.Pointer objectAutorelease( - ffi.Pointer object, -); - -@ffi.Native)>( - symbol: 'objc_release', - isLeaf: true, -) -external void objectRelease(ffi.Pointer object); - -@ffi.Native Function(ffi.Pointer)>( - symbol: 'objc_retain', - isLeaf: true, -) -external ffi.Pointer objectRetain( - ffi.Pointer object, -); - -@ffi.Native Function(ffi.Pointer)>( - symbol: 'sel_registerName', - isLeaf: true, -) -external ffi.Pointer registerName(ffi.Pointer name); - @ffi.Native< ffi.Void Function( ffi.Pointer)>>, @@ -308,18 +171,8 @@ final class ObjCBlockImpl extends ffi.Struct { external int dispose_port; } -final class ObjCMethodDesc extends ffi.Struct { - external ffi.Pointer name; - - external ffi.Pointer types; -} - final class ObjCObjectImpl extends ffi.Opaque {} -final class ObjCProtocolImpl extends ffi.Opaque {} - -final class ObjCSelector extends ffi.Opaque {} - final class _Dart_Isolate extends ffi.Opaque {} final class _Version extends ffi.Struct { diff --git a/pkgs/objective_c/lib/src/globals.dart b/pkgs/objective_c/lib/src/globals.dart new file mode 100644 index 0000000000..8f845e86fe --- /dev/null +++ b/pkgs/objective_c/lib/src/globals.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// ignore_for_file: non_constant_identifier_names + +import 'objective_c_bindings_generated.dart'; +import 'runtime_bindings_generated.dart' as r; + +NSString get NSKeyValueChangeIndexesKey => NSString.fromPointer( + r.NSKeyValueChangeIndexesKey, + retain: true, + release: true, +); + +NSString get NSKeyValueChangeKindKey => NSString.fromPointer( + r.NSKeyValueChangeKindKey, + retain: true, + release: true, +); + +NSString get NSKeyValueChangeNewKey => + NSString.fromPointer(r.NSKeyValueChangeNewKey, retain: true, release: true); + +NSString get NSKeyValueChangeNotificationIsPriorKey => NSString.fromPointer( + r.NSKeyValueChangeNotificationIsPriorKey, + retain: true, + release: true, +); + +NSString get NSKeyValueChangeOldKey => + NSString.fromPointer(r.NSKeyValueChangeOldKey, retain: true, release: true); + +NSString get NSLocalizedDescriptionKey => NSString.fromPointer( + r.NSLocalizedDescriptionKey, + retain: true, + release: true, +); diff --git a/pkgs/objective_c/lib/src/internal.dart b/pkgs/objective_c/lib/src/internal.dart index cff36a77b7..87d76361ee 100644 --- a/pkgs/objective_c/lib/src/internal.dart +++ b/pkgs/objective_c/lib/src/internal.dart @@ -10,8 +10,9 @@ import 'package:ffi/ffi.dart'; import 'c_bindings_generated.dart' as c; import 'ns_string.dart'; import 'objective_c_bindings_generated.dart' as objc; +import 'runtime_bindings_generated.dart' as r; -typedef ObjectPtr = Pointer; +typedef ObjectPtr = Pointer; typedef BlockPtr = Pointer; typedef VoidPtr = Pointer; @@ -107,23 +108,25 @@ final class NSErrorException implements Exception { String toString() => 'NSError: ${error.localizedDescription.toDartString()}'; } -extension GetProtocolName on Pointer { +extension GetProtocolName on Pointer { /// Returns the name of the protocol. - String get name => c.getProtocolName(this).cast().toDartString(); + String get name => r.getProtocolName(this).cast().toDartString(); } -/// Only for use by FFIgen bindings. -Pointer registerName(String name) { +/// Only for use by ffigen bindings. +Pointer registerName(String name) { + _ensureDartAPI(); final cstr = name.toNativeUtf8(); - final sel = c.registerName(cstr.cast()); + final sel = r.registerName(cstr.cast()); calloc.free(cstr); return sel; } /// Only for use by FFIgen bindings. ObjectPtr getClass(String name) { + _ensureDartAPI(); final cstr = name.toNativeUtf8(); - final clazz = c.getClass(cstr.cast()); + final clazz = r.getClass(cstr.cast()); calloc.free(cstr); if (clazz == nullptr) { throw FailedToLoadClassException(name); @@ -131,10 +134,11 @@ ObjectPtr getClass(String name) { return clazz; } -/// Only for use by FFIgen bindings. -Pointer getProtocol(String name) { +/// Only for use by ffigen bindings. +Pointer getProtocol(String name) { + _ensureDartAPI(); final cstr = name.toNativeUtf8(); - final clazz = c.getProtocol(cstr.cast()); + final clazz = r.getProtocol(cstr.cast()); calloc.free(cstr); if (clazz == nullptr) { throw FailedToLoadProtocolException(name); @@ -144,12 +148,13 @@ Pointer getProtocol(String name) { /// Only for use by FFIgen bindings. Pointer? getProtocolMethodSignature( - Pointer protocol, - Pointer sel, { + Pointer protocol, + Pointer sel, { required bool isRequired, required bool isInstanceMethod, }) { - final sig = c + _ensureDartAPI(); + final sig = r .getMethodDescription(protocol, sel, isRequired, isInstanceMethod) .types; return sig == nullptr ? null : sig; @@ -157,25 +162,25 @@ Pointer? getProtocolMethodSignature( /// Only for use by FFIgen bindings. final msgSendPointer = Native.addressOf>( - c.msgSend, + r.msgSend, ); /// Only for use by FFIgen bindings. final msgSendFpretPointer = Native.addressOf>( - c.msgSendFpret, + r.msgSendFpret, ); /// Only for use by FFIgen bindings. final msgSendStretPointer = Native.addressOf>( - c.msgSendStret, + r.msgSendStret, ); /// Only for use by FFIgen bindings. final useMsgSendVariants = Abi.current() == Abi.iosX64 || Abi.current() == Abi.macosX64; -/// Only for use by FFIgen bindings. -bool respondsToSelector(ObjectPtr obj, Pointer sel) => +/// Only for use by ffigen bindings. +bool respondsToSelector(ObjectPtr obj, Pointer sel) => _objcMsgSendRespondsToSelector(obj, _selRespondsToSelector, sel); final _selRespondsToSelector = registerName('respondsToSelector:'); final _objcMsgSendRespondsToSelector = msgSendPointer @@ -183,13 +188,13 @@ final _objcMsgSendRespondsToSelector = msgSendPointer NativeFunction< Bool Function( ObjectPtr, - Pointer, - Pointer aSelector, + Pointer, + Pointer aSelector, ) > >() .asFunction< - bool Function(ObjectPtr, Pointer, Pointer) + bool Function(ObjectPtr, Pointer, Pointer) >(); // _FinalizablePointer exists because we can't access `this` in the initializers @@ -257,10 +262,10 @@ abstract final class _ObjCReference _isReleased.value = true; } - void release() => _release(c.objectRelease); + void release() => _release(r.objectRelease); Pointer autorelease() { - _release(c.objectAutorelease); + _release(r.objectAutorelease); return _finalizable.ptr; } @@ -288,7 +293,7 @@ abstract final class _ObjCReference Pointer retainAndAutorelease() { final ptr = pointer; _retain(ptr); - c.objectAutorelease(ptr.cast()); + r.objectAutorelease(ptr.cast()); return ptr; } @@ -312,19 +317,19 @@ class _ObjCRefHolder> { } @pragma('vm:deeply-immutable') -final class ObjCObjectRef extends _ObjCReference { +final class ObjCObjectRef extends _ObjCReference { ObjCObjectRef(ObjectPtr ptr, {required super.retain, required super.release}) : super(_FinalizablePointer(ptr)); @override - void _retain(ObjectPtr ptr) => c.objectRetain(ptr); + void _retain(ObjectPtr ptr) => r.objectRetain(ptr); @override bool _isValid(ObjectPtr ptr) => _isValidObject(ptr); } /// Base class for all Objective-C objects. -class ObjCObject extends _ObjCRefHolder { +class ObjCObject extends _ObjCRefHolder { ObjCObject(ObjectPtr ptr, {required bool retain, required bool release}) : super(ObjCObjectRef(ptr, retain: retain, release: release)); } @@ -333,7 +338,7 @@ class ObjCObject extends _ObjCRefHolder { // readable memory, or be null. May (rarely) return false positives. bool _isValidObject(ObjectPtr ptr) { if (ptr == nullptr) return false; - return _isValidClass(c.getObjectClass(ptr)); + return _isValidClass(r.getObjectClass(ptr)); } final _allClasses = {}; @@ -348,7 +353,7 @@ bool _isValidClass(ObjectPtr clazz, {bool forceReloadClasses = false}) { // enabled, and only happens more than O(1) times if there are actually // invalid objects in use, which shouldn't happen in correct code. final countPtr = calloc(); - final classList = c.copyClassList(countPtr); + final classList = r.copyClassList(countPtr); final count = countPtr.value; calloc.free(countPtr); _allClasses.clear(); @@ -371,7 +376,7 @@ final class ObjCBlockRef extends _ObjCReference { : super(_FinalizablePointer(ptr)); @override - void _retain(BlockPtr ptr) => c.blockRetain(ptr.cast()); + void _retain(BlockPtr ptr) => r.blockRetain(ptr.cast()); @override bool _isValid(BlockPtr ptr) => c.isValidBlock(ptr); @@ -410,7 +415,7 @@ BlockPtr _newBlock( int flags, ) { final b = calloc.allocate(sizeOf()); - b.ref.isa = Native.addressOf>(c.NSConcreteGlobalBlock).cast(); + b.ref.isa = Native.addressOf>(r.NSConcreteGlobalBlock).cast(); b.ref.flags = flags; b.ref.reserved = 0; b.ref.invoke = invoke; @@ -418,11 +423,11 @@ BlockPtr _newBlock( b.ref.dispose_port = disposePort; b.ref.descriptor = descriptor; assert(c.isValidBlock(b)); - final copy = c.blockRetain(b.cast()).cast(); + final copy = r.blockRetain(b.cast()).cast(); calloc.free(b); assert( copy.ref.isa == - Native.addressOf>(c.NSConcreteMallocBlock).cast(), + Native.addressOf>(r.NSConcreteMallocBlock).cast(), ); assert(c.isValidBlock(copy)); return copy; diff --git a/pkgs/objective_c/lib/src/ns_input_stream.dart b/pkgs/objective_c/lib/src/ns_input_stream.dart index 21d693149e..50203170fb 100644 --- a/pkgs/objective_c/lib/src/ns_input_stream.dart +++ b/pkgs/objective_c/lib/src/ns_input_stream.dart @@ -2,7 +2,11 @@ import 'dart:async'; import 'dart:ffi'; import 'dart:isolate'; -import '../objective_c.dart'; +import 'autorelease.dart'; +import 'globals.dart'; +import 'ns_data.dart'; +import 'ns_dictionary.dart'; +import 'ns_string.dart'; import 'objective_c_bindings_generated.dart'; diff --git a/pkgs/objective_c/lib/src/ns_string.dart b/pkgs/objective_c/lib/src/ns_string.dart index 552b418e56..ca25a11a7e 100644 --- a/pkgs/objective_c/lib/src/ns_string.dart +++ b/pkgs/objective_c/lib/src/ns_string.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:ffi/ffi.dart'; + import 'objective_c_bindings_generated.dart'; extension StringToNSString on String { diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_exported.dart b/pkgs/objective_c/lib/src/objective_c_bindings_exported.dart index 00999dece2..0afebab91d 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_exported.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_exported.dart @@ -12,6 +12,12 @@ export 'objective_c_bindings_generated.dart' CGPoint, CGRect, CGSize, + DOBJCObservation, + DOBJCObservation$Methods, + DartInputStreamAdapter, + DartInputStreamAdapter$Methods, + DartInputStreamAdapterWeakHolder, + DartInputStreamAdapterWeakHolder$Methods, DartProtocol, DartProtocol$Methods, DartProtocolBuilder, @@ -95,18 +101,12 @@ export 'objective_c_bindings_generated.dart' NSItemProviderWriting$Builder, NSItemProviderWriting$Methods, NSKeyValueChange, - NSKeyValueChangeIndexesKey, - NSKeyValueChangeKindKey, - NSKeyValueChangeNewKey, - NSKeyValueChangeNotificationIsPriorKey, - NSKeyValueChangeOldKey, NSKeyValueObservingOptions, NSKeyValueSetMutationKind, NSLinguisticTaggerOptions, NSLocale, NSLocale$Methods, NSLocaleLanguageDirection, - NSLocalizedDescriptionKey, NSMethodSignature, NSMethodSignature$Methods, NSMutableArray, diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index 29448a42ec..24f36708b1 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// Bindings for `src/foundation.h`. +// Bindings for package:objective_c's ObjC code and the Foundation framework. // Regenerate bindings with `dart run tool/generate_code.dart`. // coverage:ignore-file @@ -11,116 +11,13 @@ // // Generated by `package:ffigen`. // ignore_for_file: type=lint, unused_import +@ffi.DefaultAsset('package:objective_c/objective_c.dylib') +library; + import 'dart:ffi' as ffi; import '../objective_c.dart' as objc; import 'package:ffi/ffi.dart' as pkg_ffi; -@ffi.Native>( - symbol: 'NSKeyValueChangeIndexesKey', -) -external ffi.Pointer _NSKeyValueChangeIndexesKey; - -NSString get NSKeyValueChangeIndexesKey => NSString.fromPointer( - _NSKeyValueChangeIndexesKey, - retain: true, - release: true, -); - -set NSKeyValueChangeIndexesKey(NSString value) { - NSString.fromPointer( - _NSKeyValueChangeIndexesKey, - retain: false, - release: true, - ).ref.release(); - _NSKeyValueChangeIndexesKey = value.ref.retainAndReturnPointer(); -} - -@ffi.Native>(symbol: 'NSKeyValueChangeKindKey') -external ffi.Pointer _NSKeyValueChangeKindKey; - -NSString get NSKeyValueChangeKindKey => - NSString.fromPointer(_NSKeyValueChangeKindKey, retain: true, release: true); - -set NSKeyValueChangeKindKey(NSString value) { - NSString.fromPointer( - _NSKeyValueChangeKindKey, - retain: false, - release: true, - ).ref.release(); - _NSKeyValueChangeKindKey = value.ref.retainAndReturnPointer(); -} - -@ffi.Native>(symbol: 'NSKeyValueChangeNewKey') -external ffi.Pointer _NSKeyValueChangeNewKey; - -NSString get NSKeyValueChangeNewKey => - NSString.fromPointer(_NSKeyValueChangeNewKey, retain: true, release: true); - -set NSKeyValueChangeNewKey(NSString value) { - NSString.fromPointer( - _NSKeyValueChangeNewKey, - retain: false, - release: true, - ).ref.release(); - _NSKeyValueChangeNewKey = value.ref.retainAndReturnPointer(); -} - -@ffi.Native>( - symbol: 'NSKeyValueChangeNotificationIsPriorKey', -) -external ffi.Pointer -_NSKeyValueChangeNotificationIsPriorKey; - -NSString get NSKeyValueChangeNotificationIsPriorKey => NSString.fromPointer( - _NSKeyValueChangeNotificationIsPriorKey, - retain: true, - release: true, -); - -set NSKeyValueChangeNotificationIsPriorKey(NSString value) { - NSString.fromPointer( - _NSKeyValueChangeNotificationIsPriorKey, - retain: false, - release: true, - ).ref.release(); - _NSKeyValueChangeNotificationIsPriorKey = value.ref.retainAndReturnPointer(); -} - -@ffi.Native>(symbol: 'NSKeyValueChangeOldKey') -external ffi.Pointer _NSKeyValueChangeOldKey; - -NSString get NSKeyValueChangeOldKey => - NSString.fromPointer(_NSKeyValueChangeOldKey, retain: true, release: true); - -set NSKeyValueChangeOldKey(NSString value) { - NSString.fromPointer( - _NSKeyValueChangeOldKey, - retain: false, - release: true, - ).ref.release(); - _NSKeyValueChangeOldKey = value.ref.retainAndReturnPointer(); -} - -@ffi.Native>( - symbol: 'NSLocalizedDescriptionKey', -) -external ffi.Pointer _NSLocalizedDescriptionKey; - -NSString get NSLocalizedDescriptionKey => NSString.fromPointer( - _NSLocalizedDescriptionKey, - retain: true, - release: true, -); - -set NSLocalizedDescriptionKey(NSString value) { - NSString.fromPointer( - _NSLocalizedDescriptionKey, - retain: false, - release: true, - ).ref.release(); - _NSLocalizedDescriptionKey = value.ref.retainAndReturnPointer(); -} - @ffi.Native< ffi.UnsignedLong Function( ffi.Pointer, diff --git a/pkgs/objective_c/lib/src/protocol_builder.dart b/pkgs/objective_c/lib/src/protocol_builder.dart index a0ca6dd49e..143d9975c9 100644 --- a/pkgs/objective_c/lib/src/protocol_builder.dart +++ b/pkgs/objective_c/lib/src/protocol_builder.dart @@ -12,6 +12,7 @@ import 'c_bindings_generated.dart' as c; import 'internal.dart' show FailedToLoadProtocolMethodException, GetProtocolName, ObjCBlockBase; import 'objective_c_bindings_generated.dart' as objc; +import 'runtime_bindings_generated.dart' as r; import 'selector.dart'; /// Helper class for building Objective C objects that implement protocols. @@ -31,7 +32,7 @@ class ObjCProtocolBuilder { /// /// Note: You cannot call this method after you have called [build]. void implementMethod( - Pointer sel, + Pointer sel, Pointer signature, Pointer trampoline, ObjCBlockBase block, @@ -91,8 +92,8 @@ class ObjCProtocolBuilder { /// want to implement. The generated bindings will include a /// [ObjCProtocolMethod] for each method of the protocol. class ObjCProtocolMethod { - final Pointer _proto; - final Pointer _sel; + final Pointer _proto; + final Pointer _sel; final Pointer _trampoline; final Pointer? _signature; final ObjCBlockBase Function(T) _createBlock; diff --git a/pkgs/objective_c/lib/src/runtime_bindings_generated.dart b/pkgs/objective_c/lib/src/runtime_bindings_generated.dart new file mode 100644 index 0000000000..67cdf86ebe --- /dev/null +++ b/pkgs/objective_c/lib/src/runtime_bindings_generated.dart @@ -0,0 +1,185 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Bindings for `src/objective_c_runtime.h`. +// Regenerate bindings with `dart run tool/generate_code.dart`. + +// ignore_for_file: always_specify_types +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: unused_element +// coverage:ignore-file + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint, unused_import +import 'dart:ffi' as ffi; + +@ffi.Array.multi([32]) +@ffi.Native>>(symbol: '_NSConcreteAutoBlock') +external ffi.Array> NSConcreteAutoBlock; + +@ffi.Array.multi([32]) +@ffi.Native>>( + symbol: '_NSConcreteFinalizingBlock', +) +external ffi.Array> NSConcreteFinalizingBlock; + +@ffi.Array.multi([32]) +@ffi.Native>>(symbol: '_NSConcreteGlobalBlock') +external ffi.Array> NSConcreteGlobalBlock; + +@ffi.Array.multi([32]) +@ffi.Native>>(symbol: '_NSConcreteMallocBlock') +external ffi.Array> NSConcreteMallocBlock; + +@ffi.Array.multi([32]) +@ffi.Native>>(symbol: '_NSConcreteStackBlock') +external ffi.Array> NSConcreteStackBlock; + +@ffi.Native>() +external ffi.Pointer NSKeyValueChangeIndexesKey; + +@ffi.Native>() +external ffi.Pointer NSKeyValueChangeKindKey; + +@ffi.Native>() +external ffi.Pointer NSKeyValueChangeNewKey; + +@ffi.Native>() +external ffi.Pointer NSKeyValueChangeNotificationIsPriorKey; + +@ffi.Native>() +external ffi.Pointer NSKeyValueChangeOldKey; + +@ffi.Native>() +external ffi.Pointer NSLocalizedDescriptionKey; + +@ffi.Native)>( + symbol: 'objc_autoreleasePoolPop', + isLeaf: true, +) +external void autoreleasePoolPop(ffi.Pointer pool); + +@ffi.Native Function()>( + symbol: 'objc_autoreleasePoolPush', + isLeaf: true, +) +external ffi.Pointer autoreleasePoolPush(); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'objc_retainBlock', + isLeaf: true, +) +external ffi.Pointer blockRetain( + ffi.Pointer object, +); + +@ffi.Native< + ffi.Pointer> Function( + ffi.Pointer, + ) +>(symbol: 'objc_copyClassList', isLeaf: true) +external ffi.Pointer> copyClassList( + ffi.Pointer count, +); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'objc_getClass', + isLeaf: true, +) +external ffi.Pointer getClass(ffi.Pointer name); + +@ffi.Native< + ObjCMethodDesc Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ) +>(symbol: 'protocol_getMethodDescription', isLeaf: true) +external ObjCMethodDesc getMethodDescription( + ffi.Pointer protocol, + ffi.Pointer sel, + bool isRequiredMethod, + bool isInstanceMethod, +); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'sel_getName', + isLeaf: true, +) +external ffi.Pointer getName(ffi.Pointer sel); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'object_getClass', + isLeaf: true, +) +external ffi.Pointer getObjectClass( + ffi.Pointer object, +); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'objc_getProtocol', + isLeaf: true, +) +external ffi.Pointer getProtocol(ffi.Pointer name); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'protocol_getName', + isLeaf: true, +) +external ffi.Pointer getProtocolName( + ffi.Pointer proto, +); + +@ffi.Native(symbol: 'objc_msgSend') +external void msgSend(); + +@ffi.Native(symbol: 'objc_msgSend_fpret') +external void msgSendFpret(); + +@ffi.Native(symbol: 'objc_msgSend_stret') +external void msgSendStret(); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'objc_autorelease', + isLeaf: true, +) +external ffi.Pointer objectAutorelease( + ffi.Pointer object, +); + +@ffi.Native)>( + symbol: 'objc_release', + isLeaf: true, +) +external void objectRelease(ffi.Pointer object); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'objc_retain', + isLeaf: true, +) +external ffi.Pointer objectRetain( + ffi.Pointer object, +); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'sel_registerName', + isLeaf: true, +) +external ffi.Pointer registerName(ffi.Pointer name); + +final class ObjCMethodDesc extends ffi.Struct { + external ffi.Pointer name; + + external ffi.Pointer types; +} + +final class ObjCObjectImpl extends ffi.Opaque {} + +final class ObjCProtocolImpl extends ffi.Opaque {} + +final class ObjCSelector extends ffi.Opaque {} diff --git a/pkgs/objective_c/lib/src/selector.dart b/pkgs/objective_c/lib/src/selector.dart index f50bcb23c7..03c5a63fa2 100644 --- a/pkgs/objective_c/lib/src/selector.dart +++ b/pkgs/objective_c/lib/src/selector.dart @@ -6,25 +6,25 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; -import 'c_bindings_generated.dart' as c; import 'internal.dart' as objc; +import 'runtime_bindings_generated.dart' as r; extension StringToSelector on String { /// Returns an Objective-C selector (aka `SEL`) for this [String]. /// /// This is equivalent to the Objective-C `@selector()` directive, or the /// `NSSelectorFromString` function. - Pointer toSelector() => objc.registerName(this); + Pointer toSelector() => objc.registerName(this); } -extension SelectorToString on Pointer { +extension SelectorToString on Pointer { /// Returns the string that this Objective-C selector represents. /// /// This is equivalent to the Objective-C `NSSelectorFromString` function. - String toDartString() => c.getName(this).cast().toDartString(); + String toDartString() => r.getName(this).cast().toDartString(); } extension RespondsToSelector on objc.ObjCObject { - bool respondsToSelector(Pointer sel) => + bool respondsToSelector(Pointer sel) => objc.respondsToSelector(ref.pointer, sel); } diff --git a/pkgs/objective_c/macos/Classes/objective_c.c b/pkgs/objective_c/macos/Classes/objective_c.c deleted file mode 100644 index 6d9c021cce..0000000000 --- a/pkgs/objective_c/macos/Classes/objective_c.c +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Relative import to be able to reuse the C sources. -// See the comment in ../objective_c.podspec for more information. -#include "../../src/objective_c.c" -#include "../../src/include/dart_api_dl.c" diff --git a/pkgs/objective_c/macos/Classes/objective_c.m b/pkgs/objective_c/macos/Classes/objective_c.m deleted file mode 100644 index bb195a9e0b..0000000000 --- a/pkgs/objective_c/macos/Classes/objective_c.m +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Relative import to be able to reuse the ObjC sources. -// See the comment in ../objective_c.podspec for more information. -#include "../../src/input_stream_adapter.m" -#include "../../src/objective_c.m" -#include "../../src/objective_c_bindings_generated.m" -#include "../../src/ns_number.m" -#include "../../src/observer.m" -#include "../../src/protocol.m" diff --git a/pkgs/objective_c/macos/objective_c.podspec b/pkgs/objective_c/macos/objective_c.podspec deleted file mode 100644 index f3ae43b6b3..0000000000 --- a/pkgs/objective_c/macos/objective_c.podspec +++ /dev/null @@ -1,27 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint objective_c.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'objective_c' - s.version = '0.0.1' - s.summary = 'A library to access Objective C from Flutter that acts as a support library for package:ffigen.' - s.description = <<-DESC -A library to access Objective C from Flutter that acts as a support library for package:ffigen. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - # This will ensure the source files in Classes/ are included in the native - # builds of apps using this FFI plugin. Podspec does not support relative - # paths, so Classes contains a forwarder C file that relatively imports - # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.dependency 'FlutterMacOS' - - s.platform = :osx, '10.11' - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.swift_version = '5.0' -end diff --git a/pkgs/objective_c/pubspec.yaml b/pkgs/objective_c/pubspec.yaml index 92d4f28721..1ce75534ff 100644 --- a/pkgs/objective_c/pubspec.yaml +++ b/pkgs/objective_c/pubspec.yaml @@ -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: 9.1.0 +version: 9.2.0-dev repository: https://github.com/dart-lang/native/tree/main/pkgs/objective_c issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aobjective_c @@ -15,36 +15,33 @@ topics: - codegen environment: - sdk: '>=3.8.0 <4.0.0' - flutter: '>=3.32.0' + sdk: '>=3.9.0-21.0.dev <4.0.0' dependencies: + code_assets: ^0.19.0 collection: ^1.19.1 ffi: ^2.1.0 - flutter: - sdk: flutter + hooks: ^0.20.5 + logging: ^1.3.0 + native_toolchain_c: ^0.17.2 pub_semver: ^2.1.4 dev_dependencies: args: ^2.6.0 dart_flutter_team_lints: ^3.5.2 ffigen: ^20.1.0 - flutter_test: - sdk: flutter native_test_helpers: path: ../native_test_helpers/ path: ^1.9.0 - test: ^1.21.1 + test: ^1.26.2 yaml: ^3.1.0 dependency_overrides: + code_assets: + path: ../code_assets ffigen: - path: ../ffigen/ - -flutter: - plugin: - platforms: - ios: - ffiPlugin: true - macos: - ffiPlugin: true + path: ../ffigen + hooks: + path: ../hooks + native_toolchain_c: + path: ../native_toolchain_c diff --git a/pkgs/objective_c/src/CMakeLists.txt b/pkgs/objective_c/src/CMakeLists.txt deleted file mode 100644 index 14fc5b5751..0000000000 --- a/pkgs/objective_c/src/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# The Flutter tooling requires that developers have CMake 3.10 or later -# installed. You should not increase this version, as doing so will cause -# the plugin to fail to compile for some customers of the plugin. -cmake_minimum_required(VERSION 3.10) - -project(objective_c_library VERSION 0.0.1 LANGUAGES C) - -add_library(objective_c SHARED - "objective_c.c" - "objective_c.m" - "protocol.m" - "include/dart_api_dl.c" -) - -target_link_options(objective_c PRIVATE "-undefined dynamic_lookup") - -set_target_properties(objective_c PROPERTIES - PUBLIC_HEADER objective_c.h - OUTPUT_NAME "objective_c" -) - -target_compile_definitions(objective_c PUBLIC DART_SHARED_LIB) diff --git a/pkgs/objective_c/src/objective_c.c b/pkgs/objective_c/src/objective_c.c index 5e7b895d42..1f3ccfd475 100644 --- a/pkgs/objective_c/src/objective_c.c +++ b/pkgs/objective_c/src/objective_c.c @@ -50,10 +50,6 @@ FFI_EXPORT bool* DOBJC_newFinalizableBool(Dart_Handle owner) { return pointer; } -FFI_EXPORT intptr_t DOBJC_initializeApi(void* data) { - return Dart_InitializeApiDL(data); -} - FFI_EXPORT DOBJC_Context* DOBJC_fillContext(DOBJC_Context* context) { context->version = 1; context->newWaiter = DOBJC_newWaiter; diff --git a/pkgs/objective_c/src/objective_c.h b/pkgs/objective_c/src/objective_c.h index 917c0a0b75..0f2763c991 100644 --- a/pkgs/objective_c/src/objective_c.h +++ b/pkgs/objective_c/src/objective_c.h @@ -9,6 +9,27 @@ #include "include/dart_api_dl.h" #include "objective_c_runtime.h" +// See https://clang.llvm.org/docs/Block-ABI-Apple.html +typedef struct _ObjCBlockDesc { + unsigned long int reserved; + unsigned long int size; // sizeof(ObjCBlockImpl) + void (*copy_helper)(void *dst, void *src); + void (*dispose_helper)(void *src); + const char *signature; +} ObjCBlockDesc; + +typedef struct _ObjCBlockImpl { + void *isa; // _NSConcreteGlobalBlock + int flags; + int reserved; + void *invoke; // RET (*invoke)(ObjCBlockImpl *, ARGS...); + ObjCBlockDesc *descriptor; + + // Captured variables follow. These are specific to our use case. + void *target; + Dart_Port dispose_port; +} ObjCBlockImpl; + // Initialize the Dart API. FFI_EXPORT intptr_t DOBJC_initializeApi(void *data); @@ -36,10 +57,6 @@ FFI_EXPORT bool *DOBJC_newFinalizableBool(Dart_Handle owner); // Runs fn(arg) on the main thread. If runOnMainThread is already running on the // main thread, fn(arg) is invoked synchronously. Otherwise it is dispatched to // the main thread (ie dispatch_async(dispatch_get_main_queue(), ...)). -// -// This assumes that the main thread is executing its queue. If not, #define -// NO_MAIN_THREAD_DISPATCH to disable this, and run fn(arg) synchronously. The -// flutter runner does execute the main dispatch queue, but the Dart VM doesn't. FFI_EXPORT void DOBJC_runOnMainThread(void (*fn)(void *), void *arg); // Functions for creating a waiter, signaling it, and waiting for the signal. A diff --git a/pkgs/objective_c/src/objective_c.m b/pkgs/objective_c/src/objective_c.m index c9b9f41202..4627b327d9 100644 --- a/pkgs/objective_c/src/objective_c.m +++ b/pkgs/objective_c/src/objective_c.m @@ -8,20 +8,26 @@ #import #include "ffi.h" +#include "include/dart_api_dl.h" #include "os_version.h" +_Atomic bool _mainThreadIsListening = false; + +FFI_EXPORT intptr_t DOBJC_initializeApi(void* data) { + dispatch_async(dispatch_get_main_queue(), ^{ + _mainThreadIsListening = true; + }); + return Dart_InitializeApiDL(data); +} + FFI_EXPORT void DOBJC_runOnMainThread(void (*fn)(void *), void *arg) { -#ifdef NO_MAIN_THREAD_DISPATCH - fn(arg); -#else - if ([NSThread isMainThread]) { + if (!_mainThreadIsListening || [NSThread isMainThread]) { fn(arg); } else { dispatch_async(dispatch_get_main_queue(), ^{ fn(arg); }); } -#endif } @interface DOBJCWaiter : NSObject {} diff --git a/pkgs/objective_c/src/objective_c_runtime.h b/pkgs/objective_c/src/objective_c_runtime.h index 04d5f8174f..33cffaaf8d 100644 --- a/pkgs/objective_c/src/objective_c_runtime.h +++ b/pkgs/objective_c/src/objective_c_runtime.h @@ -33,27 +33,6 @@ void objc_msgSend(void); void objc_msgSend_fpret(void); void objc_msgSend_stret(void); -// See https://clang.llvm.org/docs/Block-ABI-Apple.html -typedef struct _ObjCBlockDesc { - unsigned long int reserved; - unsigned long int size; // sizeof(ObjCBlockImpl) - void (*copy_helper)(void *dst, void *src); - void (*dispose_helper)(void *src); - const char *signature; -} ObjCBlockDesc; - -typedef struct _ObjCBlockImpl { - void *isa; // _NSConcreteGlobalBlock - int flags; - int reserved; - void *invoke; // RET (*invoke)(ObjCBlockImpl *, ARGS...); - ObjCBlockDesc *descriptor; - - // Captured variables follow. These are specific to our use case. - void *target; - Dart_Port dispose_port; -} ObjCBlockImpl; - // https://opensource.apple.com/source/libclosure/libclosure-38/Block_private.h extern void *_NSConcreteStackBlock[32]; extern void *_NSConcreteMallocBlock[32]; @@ -73,4 +52,11 @@ ObjCMethodDesc protocol_getMethodDescription( bool isInstanceMethod); const char *protocol_getName(ObjCProtocolImpl *proto); +extern const ObjCObjectImpl *NSKeyValueChangeIndexesKey; +extern const ObjCObjectImpl *NSKeyValueChangeKindKey; +extern const ObjCObjectImpl *NSKeyValueChangeNewKey; +extern const ObjCObjectImpl *NSKeyValueChangeNotificationIsPriorKey; +extern const ObjCObjectImpl *NSKeyValueChangeOldKey; +extern const ObjCObjectImpl *NSLocalizedDescriptionKey; + #endif // OBJECTIVE_C_SRC_OBJECTIVE_C_RUNTIME_H_ diff --git a/pkgs/objective_c/test/autorelease_test.dart b/pkgs/objective_c/test/autorelease_test.dart index b656539633..3a323920c0 100644 --- a/pkgs/objective_c/test/autorelease_test.dart +++ b/pkgs/objective_c/test/autorelease_test.dart @@ -15,11 +15,6 @@ import 'util.dart'; void main() { group('autoReleasePool', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('basics', () async { late Pointer pointer; autoReleasePool(() { diff --git a/pkgs/objective_c/test/cf_string_test.dart b/pkgs/objective_c/test/cf_string_test.dart index 84d76b1327..dbde1fb1fd 100644 --- a/pkgs/objective_c/test/cf_string_test.dart +++ b/pkgs/objective_c/test/cf_string_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('CFString', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - for (final s in ['Hello', '🇵🇬', 'Embedded\u0000Null']) { test('CFString conversions [$s]', () { final cfString = s diff --git a/pkgs/objective_c/test/converter_test.dart b/pkgs/objective_c/test/converter_test.dart index 97d215d168..7812f9caaf 100644 --- a/pkgs/objective_c/test/converter_test.dart +++ b/pkgs/objective_c/test/converter_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('converter', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('basics', () { final obj = NSObject(); expect(toObjCObject(obj), obj); diff --git a/pkgs/objective_c/test/generate_code_test.dart b/pkgs/objective_c/test/generate_code_test.dart index 7b839157c3..34bf0f8ec9 100644 --- a/pkgs/objective_c/test/generate_code_test.dart +++ b/pkgs/objective_c/test/generate_code_test.dart @@ -22,13 +22,22 @@ void main() { await expectLater(generate_code.run(format: true), completes); // Sanity check the generated code. + final rBindings = File( + 'lib/src/runtime_bindings_generated.dart', + ).readAsStringSync(); + expect(rBindings, contains('sel_registerName')); + expect(rBindings, contains('objc_msgSend')); + expect(rBindings, contains('_NSConcreteGlobalBlock')); + expect(rBindings, contains('ObjCObject')); + final cBindings = File( 'lib/src/c_bindings_generated.dart', ).readAsStringSync(); - expect(cBindings, contains('sel_registerName')); - expect(cBindings, contains('objc_msgSend')); - expect(cBindings, contains('_NSConcreteGlobalBlock')); - expect(cBindings, contains('ObjCBlock')); + expect(cBindings, contains('fillContext')); + expect(cBindings, contains('DOBJC_Context')); + expect(cBindings, contains('Dart_FinalizableHandle')); + expect(cBindings, contains('ILLEGAL_PORT')); + expect(cBindings, contains('ObjCBlockImpl')); final objcBindings = File( 'lib/src/objective_c_bindings_generated.dart', diff --git a/pkgs/objective_c/test/interface_lists_test.dart b/pkgs/objective_c/test/interface_lists_test.dart index e32e813b9d..19837be516 100644 --- a/pkgs/objective_c/test/interface_lists_test.dart +++ b/pkgs/objective_c/test/interface_lists_test.dart @@ -106,11 +106,6 @@ void main() { ); }); - test('All code genned globals are included in the list', () { - final allGlobals = findBindings(RegExp(r'^\w+ get (\w+) =>')); - expectSetsEqual('generated globals', objCBuiltInGlobals, allGlobals); - }); - test('No stubs', () { final stubRegExp = RegExp(r'\Wstub\W'); expect(bindings.where(stubRegExp.hasMatch).toList(), []); diff --git a/pkgs/objective_c/test/ns_input_stream_test.dart b/pkgs/objective_c/test/ns_input_stream_test.dart index e6540bf972..6c04dbc88b 100644 --- a/pkgs/objective_c/test/ns_input_stream_test.dart +++ b/pkgs/objective_c/test/ns_input_stream_test.dart @@ -15,8 +15,6 @@ import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'package:objective_c/objective_c.dart'; -import 'package:objective_c/src/objective_c_bindings_generated.dart' - show DartInputStreamAdapter, DartInputStreamAdapter$Methods; import 'package:test/test.dart'; import 'util.dart'; @@ -42,11 +40,6 @@ Future<(int, Uint8List, bool, NSStreamStatus, NSError?)> read( void main() { group('NSInputStream', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - group('toNSInputStream', () { group('empty', () { late NSInputStream inputStream; diff --git a/pkgs/objective_c/test/ns_mutable_data_test.dart b/pkgs/objective_c/test/ns_mutable_data_test.dart index 57e1448427..970ca59766 100644 --- a/pkgs/objective_c/test/ns_mutable_data_test.dart +++ b/pkgs/objective_c/test/ns_mutable_data_test.dart @@ -12,15 +12,8 @@ import 'package:ffi/ffi.dart'; import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSData', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - group('toNSData', () { test('empty', () { final data = [].toNSMutableData(); diff --git a/pkgs/objective_c/test/nsarray_test.dart b/pkgs/objective_c/test/nsarray_test.dart index aee40573c5..7b410fa983 100644 --- a/pkgs/objective_c/test/nsarray_test.dart +++ b/pkgs/objective_c/test/nsarray_test.dart @@ -15,11 +15,6 @@ import 'util.dart'; void main() { group('NSArray', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('filled', () { final obj = NSObject(); final array = NSArray.filled(3, obj).asDart(); diff --git a/pkgs/objective_c/test/nsdata_test.dart b/pkgs/objective_c/test/nsdata_test.dart index 6c6250480b..99f9f2d593 100644 --- a/pkgs/objective_c/test/nsdata_test.dart +++ b/pkgs/objective_c/test/nsdata_test.dart @@ -12,15 +12,8 @@ import 'package:ffi/ffi.dart'; import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSData', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - group('toNSData', () { test('empty', () { final data = [].toNSData(); diff --git a/pkgs/objective_c/test/nsdate_test.dart b/pkgs/objective_c/test/nsdate_test.dart index 61155cb87e..ccb3e508c5 100644 --- a/pkgs/objective_c/test/nsdate_test.dart +++ b/pkgs/objective_c/test/nsdate_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSDate', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('from DateTime', () { final dartFirstAppeared = DateTime.utc(2011, 10, 10); final nsDate = dartFirstAppeared.toNSDate(); diff --git a/pkgs/objective_c/test/nsdictionary_test.dart b/pkgs/objective_c/test/nsdictionary_test.dart index 4086e82054..e7afb6d2ee 100644 --- a/pkgs/objective_c/test/nsdictionary_test.dart +++ b/pkgs/objective_c/test/nsdictionary_test.dart @@ -15,11 +15,6 @@ import 'util.dart'; void main() { group('NSDictionary', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('of', () { final obj1 = 'obj1'.toNSString(); final obj2 = 'obj2'.toNSString(); diff --git a/pkgs/objective_c/test/nsmutablearray_test.dart b/pkgs/objective_c/test/nsmutablearray_test.dart index c0bc94e305..0c754cb5dc 100644 --- a/pkgs/objective_c/test/nsmutablearray_test.dart +++ b/pkgs/objective_c/test/nsmutablearray_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSMutableArray', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('filled', () { final obj = NSObject(); final array = NSMutableArray.filled(3, obj).asDart(); diff --git a/pkgs/objective_c/test/nsmutabledictionary_test.dart b/pkgs/objective_c/test/nsmutabledictionary_test.dart index 2b858b47ff..2a8bc00208 100644 --- a/pkgs/objective_c/test/nsmutabledictionary_test.dart +++ b/pkgs/objective_c/test/nsmutabledictionary_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSMutableDictionary', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('of', () { final obj1 = 'obj1'.toNSString(); final obj2 = 'obj2'.toNSString(); diff --git a/pkgs/objective_c/test/nsmutableset_test.dart b/pkgs/objective_c/test/nsmutableset_test.dart index 51d25435a6..4873ab03d2 100644 --- a/pkgs/objective_c/test/nsmutableset_test.dart +++ b/pkgs/objective_c/test/nsmutableset_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSMutableSet', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('of', () { final obj1 = NSObject(); final obj2 = NSObject(); diff --git a/pkgs/objective_c/test/nsnumber_test.dart b/pkgs/objective_c/test/nsnumber_test.dart index bcecd1e937..4cca1eb1fb 100644 --- a/pkgs/objective_c/test/nsnumber_test.dart +++ b/pkgs/objective_c/test/nsnumber_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSNumber', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('from double', () { final n = 1.23.toNSNumber(); diff --git a/pkgs/objective_c/test/nsset_test.dart b/pkgs/objective_c/test/nsset_test.dart index be615f8b59..90f6f3f7f9 100644 --- a/pkgs/objective_c/test/nsset_test.dart +++ b/pkgs/objective_c/test/nsset_test.dart @@ -15,11 +15,6 @@ import 'util.dart'; void main() { group('NSSet', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('of', () { final obj1 = NSObject(); final obj2 = NSObject(); diff --git a/pkgs/objective_c/test/nsstring_test.dart b/pkgs/objective_c/test/nsstring_test.dart index c58ab33bab..9aaf5052ee 100644 --- a/pkgs/objective_c/test/nsstring_test.dart +++ b/pkgs/objective_c/test/nsstring_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('NSString', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - for (final s in ['Hello', '🇵🇬', 'Embedded\u0000Null']) { test('NSString to/from Dart string [$s]', () { final ns1 = NSString(s); diff --git a/pkgs/objective_c/test/observer_test.dart b/pkgs/objective_c/test/observer_test.dart index 5b9c10290e..c5e17a6760 100644 --- a/pkgs/objective_c/test/observer_test.dart +++ b/pkgs/objective_c/test/observer_test.dart @@ -15,11 +15,6 @@ import 'util.dart'; void main() { group('Observer', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('receive updates', () { // Using NSProgress here because it's already part of our generated // bindings and has a property with a getter and setter. diff --git a/pkgs/objective_c/test/os_version_test.dart b/pkgs/objective_c/test/os_version_test.dart index 8a5a82491f..aed4c57f1d 100644 --- a/pkgs/objective_c/test/os_version_test.dart +++ b/pkgs/objective_c/test/os_version_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('osVersion', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('getter', () { // macOS 11 was released in 2020 and isn't supported anymore. final oldVersion = Version(11, 0, 0); diff --git a/pkgs/objective_c/test/selector_test.dart b/pkgs/objective_c/test/selector_test.dart index cf2d68d79f..9a96dd1a7f 100644 --- a/pkgs/objective_c/test/selector_test.dart +++ b/pkgs/objective_c/test/selector_test.dart @@ -6,20 +6,11 @@ @TestOn('mac-os') library; -import 'dart:ffi'; - import 'package:objective_c/objective_c.dart'; import 'package:test/test.dart'; -import 'util.dart'; - void main() { group('Selector', () { - setUpAll(() { - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(testDylib); - }); - test('from String and back', () { expect('hello'.toSelector().toDartString(), 'hello'); expect(''.toSelector().toDartString(), ''); diff --git a/pkgs/objective_c/test/util.dart b/pkgs/objective_c/test/util.dart index 3623142b6c..d0300e8eb3 100644 --- a/pkgs/objective_c/test/util.dart +++ b/pkgs/objective_c/test/util.dart @@ -10,7 +10,6 @@ import 'package:objective_c/objective_c.dart'; import 'package:objective_c/src/internal.dart' as internal_for_testing show isValidClass; -import 'package:path/path.dart' as p; final _executeInternalCommand = () { try { @@ -67,6 +66,3 @@ int objectRetainCount(Pointer object) { } String pkgDir = findPackageRoot('objective_c').toFilePath(); - -// TODO(https://github.com/dart-lang/native/issues/1068): Remove this. -String testDylib = p.join(pkgDir, 'test', 'objective_c.dylib'); diff --git a/pkgs/objective_c/tool/generate_code.dart b/pkgs/objective_c/tool/generate_code.dart index 7a5119b158..3e90345299 100644 --- a/pkgs/objective_c/tool/generate_code.dart +++ b/pkgs/objective_c/tool/generate_code.dart @@ -11,8 +11,10 @@ import 'package:args/args.dart'; import 'package:ffigen/src/executables/ffigen.dart' as ffigen; import 'package:yaml/yaml.dart'; +const runtimeConfig = 'ffigen_runtime.yaml'; const cConfig = 'ffigen_c.yaml'; const objcConfig = 'ffigen_objc.yaml'; +const runtimeBindings = 'lib/src/runtime_bindings_generated.dart'; const cBindings = 'lib/src/c_bindings_generated.dart'; const objcBindings = 'lib/src/objective_c_bindings_generated.dart'; const objcExports = 'lib/src/objective_c_bindings_exported.dart'; @@ -21,16 +23,7 @@ const builtInTypes = '../ffigen/lib/src/code_generator/objc_built_in_types.dart'; const interfaceListTest = 'test/interface_lists_test.dart'; -const privateInterfaces = { - 'DartInputStreamAdapter', - 'DartInputStreamAdapterWeakHolder', - 'DOBJCObservation', -}; - -final privateMethods = { - for (final name in privateInterfaces) '$name\$Methods', -}; -final privateClasses = privateInterfaces.union(privateMethods); +const ffigenFlags = ['--no-format', '-v', 'severe', '--config']; void dartCmd(List args) { final exec = Platform.resolvedExecutable; @@ -131,11 +124,10 @@ ${elements.join('\n')} exports.addAll([for (final name in protocols) '$name\$Methods']); exports.addAll([for (final name in protocols) '$name\$Builder']); writeDecls('objCBuiltInCategories', 'objc-categories'); - writeDecls('objCBuiltInGlobals', 'globals'); File(out).writeAsStringSync(s.toString()); - return exports.difference(privateClasses).toList()..sort(); + return exports.toList()..sort(); } void writeExports(List exports, String out) { @@ -153,22 +145,32 @@ export 'objective_c_bindings_generated.dart' } Future run({required bool format}) async { + print('Generating runtime bindings...'); + await ffigen.main([...ffigenFlags, runtimeConfig]); + print('Generating C bindings...'); - await ffigen.main(['--no-format', '-v', 'severe', '--config', cConfig]); + await ffigen.main([...ffigenFlags, cConfig]); print('Generating ObjC bindings...'); - await ffigen.main(['--no-format', '-v', 'severe', '--config', objcConfig]); + await ffigen.main([...ffigenFlags, objcConfig]); mergeExtraMethods(objcBindings, parseExtraMethods(extraMethodsFile)); print('Generating objc_built_in_types.dart...'); final exports = writeBuiltInTypes(objcConfig, builtInTypes); - print('Generating objective_c_bindings_exported.dart...'); + print('Generating objc_bindings_exported.dart...'); writeExports(exports, objcExports); if (format) { print('Formatting bindings...'); - dartCmd(['format', cBindings, objcBindings, builtInTypes, objcExports]); + dartCmd([ + 'format', + runtimeBindings, + cBindings, + objcBindings, + builtInTypes, + objcExports, + ]); } print('Running tests...'); diff --git a/pkgs/swift2objc/lib/src/generate_wrapper.dart b/pkgs/swift2objc/lib/src/generate_wrapper.dart index 04a4549375..dcc2651cb3 100644 --- a/pkgs/swift2objc/lib/src/generate_wrapper.dart +++ b/pkgs/swift2objc/lib/src/generate_wrapper.dart @@ -41,6 +41,7 @@ Future _generateWrapper( tempDir = Directory.fromUri(config.tempDir!); deleteTempDirWhenDone = false; } + tempDir.createSync(); final sourceModules = []; final mergedSymbolgraph = ParsedSymbolgraph(); diff --git a/pkgs/swift2objc/test/integration/temp/.gitignore b/pkgs/swift2objc/test/integration/temp/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/pkgs/swift2objc/test/integration/temp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/pkgs/swift2objc/test/unit/temp/.gitignore b/pkgs/swift2objc/test/unit/temp/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/pkgs/swift2objc/test/unit/temp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/pkgs/swiftgen/example/.gitignore b/pkgs/swiftgen/example/.gitignore deleted file mode 100644 index a6d7ecd9ea..0000000000 --- a/pkgs/swiftgen/example/.gitignore +++ /dev/null @@ -1 +0,0 @@ -temp/ diff --git a/pkgs/swiftgen/example/avf_audio_bindings.dart b/pkgs/swiftgen/example/avf_audio_bindings.dart index c26529a6f9..3bd6ffa250 100644 --- a/pkgs/swiftgen/example/avf_audio_bindings.dart +++ b/pkgs/swiftgen/example/avf_audio_bindings.dart @@ -628,87 +628,119 @@ extension AVAudioPlayerWrapper$Methods on AVAudioPlayerWrapper { } /// initWithContentsOf:error: - AVAudioPlayerWrapper? initWithContentsOf( - objc.NSURL url, { - required ffi.Pointer> error, - }) { + AVAudioPlayerWrapper? initWithContentsOf(objc.NSURL url) { objc.checkOsVersionInternal( 'AVAudioPlayerWrapper.initWithContentsOf:error:', macOS: (false, (10, 7, 0)), ); - final $ret = _objc_msgSend_1lhpu4m( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOf_error_, - url.ref.pointer, - error, - ); - return $ret.address == 0 - ? null - : AVAudioPlayerWrapper.fromPointer($ret, retain: false, release: true); + final $err = pkg_ffi.calloc>(); + try { + final $ret = _objc_msgSend_1lhpu4m( + object$.ref.retainAndReturnPointer(), + _sel_initWithContentsOf_error_, + url.ref.pointer, + $err, + ); + objc.NSErrorException.checkErrorPointer($err.value); + return $ret.address == 0 + ? null + : AVAudioPlayerWrapper.fromPointer( + $ret, + retain: false, + release: true, + ); + } finally { + pkg_ffi.calloc.free($err); + } } /// initWithContentsOf:fileTypeHint:error: AVAudioPlayerWrapper? initWithContentsOf$1( objc.NSURL url, { objc.NSString? fileTypeHint, - required ffi.Pointer> error, }) { objc.checkOsVersionInternal( 'AVAudioPlayerWrapper.initWithContentsOf:fileTypeHint:error:', macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_1pnyuds( - object$.ref.retainAndReturnPointer(), - _sel_initWithContentsOf_fileTypeHint_error_, - url.ref.pointer, - fileTypeHint?.ref.pointer ?? ffi.nullptr, - error, - ); - return $ret.address == 0 - ? null - : AVAudioPlayerWrapper.fromPointer($ret, retain: false, release: true); + final $err = pkg_ffi.calloc>(); + try { + final $ret = _objc_msgSend_1pnyuds( + object$.ref.retainAndReturnPointer(), + _sel_initWithContentsOf_fileTypeHint_error_, + url.ref.pointer, + fileTypeHint?.ref.pointer ?? ffi.nullptr, + $err, + ); + objc.NSErrorException.checkErrorPointer($err.value); + return $ret.address == 0 + ? null + : AVAudioPlayerWrapper.fromPointer( + $ret, + retain: false, + release: true, + ); + } finally { + pkg_ffi.calloc.free($err); + } } /// initWithData:error: - AVAudioPlayerWrapper? initWithData( - objc.NSData data, { - required ffi.Pointer> error, - }) { + AVAudioPlayerWrapper? initWithData(objc.NSData data) { objc.checkOsVersionInternal( 'AVAudioPlayerWrapper.initWithData:error:', macOS: (false, (10, 7, 0)), ); - final $ret = _objc_msgSend_1lhpu4m( - object$.ref.retainAndReturnPointer(), - _sel_initWithData_error_, - data.ref.pointer, - error, - ); - return $ret.address == 0 - ? null - : AVAudioPlayerWrapper.fromPointer($ret, retain: false, release: true); + final $err = pkg_ffi.calloc>(); + try { + final $ret = _objc_msgSend_1lhpu4m( + object$.ref.retainAndReturnPointer(), + _sel_initWithData_error_, + data.ref.pointer, + $err, + ); + objc.NSErrorException.checkErrorPointer($err.value); + return $ret.address == 0 + ? null + : AVAudioPlayerWrapper.fromPointer( + $ret, + retain: false, + release: true, + ); + } finally { + pkg_ffi.calloc.free($err); + } } /// initWithData:fileTypeHint:error: AVAudioPlayerWrapper? initWithData$1( objc.NSData data, { objc.NSString? fileTypeHint, - required ffi.Pointer> error, }) { objc.checkOsVersionInternal( 'AVAudioPlayerWrapper.initWithData:fileTypeHint:error:', macOS: (false, (10, 9, 0)), ); - final $ret = _objc_msgSend_1pnyuds( - object$.ref.retainAndReturnPointer(), - _sel_initWithData_fileTypeHint_error_, - data.ref.pointer, - fileTypeHint?.ref.pointer ?? ffi.nullptr, - error, - ); - return $ret.address == 0 - ? null - : AVAudioPlayerWrapper.fromPointer($ret, retain: false, release: true); + final $err = pkg_ffi.calloc>(); + try { + final $ret = _objc_msgSend_1pnyuds( + object$.ref.retainAndReturnPointer(), + _sel_initWithData_fileTypeHint_error_, + data.ref.pointer, + fileTypeHint?.ref.pointer ?? ffi.nullptr, + $err, + ); + objc.NSErrorException.checkErrorPointer($err.value); + return $ret.address == 0 + ? null + : AVAudioPlayerWrapper.fromPointer( + $ret, + retain: false, + release: true, + ); + } finally { + pkg_ffi.calloc.free($err); + } } /// isMeteringEnabled diff --git a/pkgs/swiftgen/example/play_audio.dart b/pkgs/swiftgen/example/play_audio.dart index 86ae151562..fdb630e0c1 100644 --- a/pkgs/swiftgen/example/play_audio.dart +++ b/pkgs/swiftgen/example/play_audio.dart @@ -7,9 +7,6 @@ import 'dart:io'; import 'package:objective_c/objective_c.dart'; -// TODO(https://github.com/dart-lang/native/issues/1068): Remove this. -import '../../objective_c/test/setup.dart' as objc_setup; - import 'avf_audio_bindings.dart'; const _dylibPath = @@ -23,17 +20,13 @@ void main(List args) async { return; } - objc_setup.main([]); DynamicLibrary.open(_dylibPath); DynamicLibrary.open(Platform.script.resolve(_wrapperDylib).toFilePath()); for (final file in args) { final fileStr = NSString(file); print('Loading ${fileStr.toDartString()}'); final fileUrl = NSURL.fileURLWithPath(fileStr); - final player = AVAudioPlayerWrapper.alloc().initWithContentsOf( - fileUrl, - error: nullptr, - ); + final player = AVAudioPlayerWrapper.alloc().initWithContentsOf(fileUrl); if (player == null) { print('Failed to load audio'); continue; diff --git a/pkgs/swiftgen/example/pubspec.yaml b/pkgs/swiftgen/example/pubspec.yaml index f26a4b7b5d..9bced04de2 100644 --- a/pkgs/swiftgen/example/pubspec.yaml +++ b/pkgs/swiftgen/example/pubspec.yaml @@ -12,9 +12,9 @@ environment: dependencies: ffi: ^2.1.0 - ffigen: ^20.0.0-dev.1 + ffigen: ^20.0.0 logging: ^1.3.0 - objective_c: ^8.0.0 + objective_c: ^9.1.0-dev pub_semver: ^2.2.0 swiftgen: path: .. diff --git a/pkgs/swiftgen/test/integration/classes_test.dart b/pkgs/swiftgen/test/integration/classes_test.dart index 6f28ef17d4..6d6109bdff 100644 --- a/pkgs/swiftgen/test/integration/classes_test.dart +++ b/pkgs/swiftgen/test/integration/classes_test.dart @@ -18,9 +18,6 @@ void main() { final gen = TestGenerator('classes'); await gen.generateAndVerifyBindings(); DynamicLibrary.open(gen.dylibFile); - - // TODO(https://github.com/dart-lang/native/issues/1068): Remove this. - DynamicLibrary.open(objCTestDylib); }); test('method invocation', () { diff --git a/pkgs/swiftgen/test/integration/temp/.gitignore b/pkgs/swiftgen/test/integration/temp/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/pkgs/swiftgen/test/integration/temp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/pkgs/swiftgen/test/integration/util.dart b/pkgs/swiftgen/test/integration/util.dart index d40638cf24..b54dc493cf 100644 --- a/pkgs/swiftgen/test/integration/util.dart +++ b/pkgs/swiftgen/test/integration/util.dart @@ -14,15 +14,6 @@ import 'package:test/test.dart'; String pkgDir = findPackageRoot('swiftgen').toFilePath(); -// TODO(https://github.com/dart-lang/native/issues/1068): Remove this. -String objCTestDylib = path.join( - pkgDir, - '..', - 'objective_c', - 'test', - 'objective_c.dylib', -); - Future hostTarget = Target.host(); class TestGenerator {