Better error reporting when an expected bridged method is not found
@aabewhite ci sta già lavorando.
Dal 10/5/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
- Lingua principale
- Swift
- Stelle
- 7
- Fork
- 8
- Merge medio
- 1g 2h
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di skiptools/skip-bridge
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
skiptools/skip-bridge#114 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
skiptools/skip-bridge#113 · 2 commenti ·
-
Complex closure crashes when being executedForse già presa @piercifani l’ha presa 43 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
skiptools/skip-bridge#101 · 1 commento ·
-
Overridden constructor does not generate correct override bridgeForse di nuovo libera @aabewhite l’ha presa 550 giorni fa e non c’è nessuna pull request aperta. Aperta
skiptools/skip-bridge#86 · 1 commento · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
skiptools/skip-bridge#83 ·
Tutte le issue di skiptools/skip-bridge
Issue simili
-
Swift: lenient_serde_types does not bypass the unsupported-attribute error when the type has aliasesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
googleapis/google-cloud-swift#1741 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
haacked/switchboard#662 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
AndroidAssetManager(env:peer:) in AssetURLProtocol.swift doesn't compile for Android on the Swift nightlyForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100