From 8fca17e21fff10b5a921a0ac286d5dde3747797e Mon Sep 17 00:00:00 2001 From: Mads Odgaard Date: Fri, 10 Jul 2026 12:25:00 +0200 Subject: [PATCH 1/2] add docs to proguard --- .../Documentation.docc/Android.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md b/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md index 67d16de86..76539d207 100644 --- a/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md +++ b/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md @@ -1,4 +1,20 @@ -# Android +# Android + +## R8/Proguard Rules + +Since swift-java uses JNI and reflection APIs, we must tell the R8 optimizer to ignore our wrapped our types, +otherwise we will into runtime crashes, because types are stripped from the APK/AAR. + +The `SwiftKit` Java library already contains a [Proguard consumer file](https://developer.anbdroid.com/topic/performance/app-optimization/library-optimization), +which is automatically detected by R8, so any `org.swift.swiftkit` types are already ignored. +However, you must still provide rules for your own types. + +For example, if your library is named is `org.swift.exampleapp`, then add the following rules to your proguard file: + +``` +-keep class org.swift.exampleapp.** { *; } +-keep interface org.swift.exampleapp.** { *; } +``` ## Android Core Library Desugaring From 46424b1a8864c7752291e0bc2f20ad9087df3027 Mon Sep 17 00:00:00 2001 From: Mads Odgaard Date: Fri, 10 Jul 2026 12:26:35 +0200 Subject: [PATCH 2/2] typos --- Sources/SwiftJavaDocumentation/Documentation.docc/Android.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md b/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md index 76539d207..38b740175 100644 --- a/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md +++ b/Sources/SwiftJavaDocumentation/Documentation.docc/Android.md @@ -2,8 +2,8 @@ ## R8/Proguard Rules -Since swift-java uses JNI and reflection APIs, we must tell the R8 optimizer to ignore our wrapped our types, -otherwise we will into runtime crashes, because types are stripped from the APK/AAR. +Since swift-java uses JNI and reflection APIs, we must tell the R8 optimizer to ignore our wrapped types, +otherwise we will run into runtime crashes, because types are stripped from the APK/AAR. The `SwiftKit` Java library already contains a [Proguard consumer file](https://developer.anbdroid.com/topic/performance/app-optimization/library-optimization), which is automatically detected by R8, so any `org.swift.swiftkit` types are already ignored.