skiptools / skiptools/skip-bridge

Better error reporting when an expected bridged method is not found

Open
#85 0 comments 0 reactions 1 assignee View on GitHub

@aabewhite is already working on this.

Since May 10, 2025.

enhancement
Dominant language
Swift
Stars
6
Forks
7
PR merge metrics
No merged PRs in 30d

Description

The R8/proguard process for Android release builds will often minify (i.e., mangle) Java names. When the Swift side of the bridge attempts to look up a method name that cannot be found like so:

let Java_set_count_methodID = Java_class.getMethodID(name: "setCount", sig: "(I)V")!

the program will simply crash with the unhelpful error:

Fatal error: Unexpectedly found nil while unwrapping an Optional value

What we might instead do is have the method lookup happen in a forced try! with a throwable function, so the error log will at least contain the name of the method that was sought:

let Java_set_count_methodID = try! Java_class.getMethodIDAndThrowErrorIfMissing(name: "setCount", sig: "(I)V")

That way, we can get an error like:

Fatal error: Could not find Java method setCount on the class APIClient bridged from APIClient.swift:1234 (release mode; did you add it to your proguard-rules.pro file?)

This will at least provide some guidance to the user at development time (and in Crashlytics reports if it happens in a deployed app) about the potential cause of the method not being found.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.