Skip to content

[pigeon] void method generation for Swift produces PlatformException #111083

@timukasr

Description

@timukasr

Steps to Reproduce

Sample pigeon file:

import 'package:pigeon/pigeon.dart';

@ConfigurePigeon(
  PigeonOptions(
    dartOut: 'lib/generated/test_api.dart',
    swiftOut: 'ios/Runner/TestApi.swift',
  ),
)
@HostApi()
abstract class TestApi {
  void test();
}

Implementation in Swift:

class MyTestApi: NSObject, TestApi {
    func test() {
        print("test method called in swift")
    }
}

Usage in Flutter:

try {
  await TestApi().test();
 debugPrint('test method called');
} catch (e, stackTrace) {
  debugPrint('Test method failed. $e $stackTrace');
}

Expected results:
test method called is logged

Actual results:
Following is logged:

test method called in swift
flutter: Test method failed. PlatformException(channel-error, Unable to establish connection on channel., null, null) #0      TestApi.test
package:sk/generated/test_api.dart:30
flutter: <asynchronous suspension>
flutter: #1      _MainScreenState.build.<anonymous closure>
package:sk/…/main_screen/main_screen.dart:90
flutter: <asynchronous suspension>
flutter:

So method in Swift side is called, but handling the response on Flutter side by pigeon fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listc: crashStack traces logged to the consolefound in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions