You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7efeacc
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: Sources/SwiftJavaDocumentation/Documentation.docc/ReducingBinarySize.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,13 @@
2
2
3
3
When using the `jextract` tool to wrap your Swift APIs as a Java library, several compiler and linker options can substantially reduce the final binary size by stripping dead code that would otherwise be retained.
4
4
5
+
## Overview
6
+
7
+
The compiler and linker options below trim the shipped library by stripping
8
+
Swift symbols that JNI never calls, then dead-stripping the resulting
9
+
unreachable code. Applied together, they can significantly reduce the final
10
+
`.so`/`.dylib` size compared to a default release build.
11
+
5
12
### Requirements
6
13
7
14
Full binary-size optimization requires **Swift 6.3 or later**. Swift 6.3 introduced the `@used` attribute, which `JExtractSwiftPlugin` attaches to every generated JNI entry point so the compiler cannot eliminate them before the linker has a chance to see them.
Copy file name to clipboardExpand all lines: Sources/SwiftJavaDocumentation/Documentation.docc/SwiftJavaConfigFile.md
+42-5Lines changed: 42 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,13 @@
2
2
3
3
SwiftJava tools can be configured using the `swift-java.config` file.
4
4
5
+
## Overview
6
+
7
+
The `swift-java.config` file lives alongside each target that needs
8
+
swift-java code generation. It selects tool modes, sets output paths,
9
+
and controls per-mode filters. Below: the file layout, then the full
10
+
list of supported keys.
11
+
5
12
### The swift-java.config file
6
13
7
14
You can refer to the `SwiftJavaConfigurationShared/Configuration` struct to learn about the supported options.
@@ -13,7 +20,7 @@ please refer to the options documentation for details on their behavior.
13
20
14
21
The configuration is a JSON 5 file, which among other things allows `//` and `/* */` comments, so feel free to add line comments explaining rationale for some of the settings in your configuration.
15
22
16
-
## Supported configuration options
23
+
###Supported configuration options
17
24
18
25
<!-- DO NOT EDIT TEXT INSIDE THE SWIFT_JAVA_CONFIG_DOCS BLOCK -->
19
26
<!-- Use the ./scripts/generate-config-docs.py to re-generate -->
@@ -231,9 +238,9 @@ If set, only generate bindings for this single Swift type name
231
238
-**Type:**`String?`
232
239
233
240
If set, JExtract (JNI mode) will write a linker version script to this
234
-
path, listing all generated JNI ``@_cdecl`` entry-point symbols as
241
+
path, listing all generated JNI `@_cdecl` entry-point symbols as
235
242
global exports and hiding everything else with `local: *`. Pass this
236
-
file to the linker via ``-Xlinker --version-script=<path>`` to enable
243
+
file to the linker via `-Xlinker --version-script=<path>` to enable
237
244
precise dead-code elimination of unused Swift code in the final shared
238
245
library.
239
246
@@ -413,8 +420,18 @@ The Java class path that should be passed along to the swift-java tool.
413
420
-**Default:** empty dictionary (`[:]`)
414
421
415
422
The Java classes that should be translated to Swift. The keys are
416
-
canonical Java class names (e.g., java.util.Vector) and the values are
417
-
the corresponding Swift names (e.g., JavaVector).
423
+
canonical Java class names (e.g., java.util.ArrayList) and the values are
424
+
the corresponding Swift names (e.g., JavaArrayList).
425
+
426
+
Example:
427
+
```json
428
+
{
429
+
"classes": {
430
+
"java.util.ArrayList": "JavaArrayList",
431
+
"java.util.HashMap": "JavaHashMap"
432
+
}
433
+
}
434
+
```
418
435
419
436
---
420
437
@@ -424,6 +441,16 @@ the corresponding Swift names (e.g., JavaVector).
424
441
425
442
Compile for the specified Java SE release.
426
443
444
+
`JavaVersion` is an integer identifying a Java SE release, in the same
445
+
shape as `javaSourceLevel`. Supported values:
446
+
447
+
-`17`
448
+
-`18`
449
+
-`21`
450
+
-`22`
451
+
-`24`
452
+
-`25`
453
+
427
454
---
428
455
429
456
#### targetCompatibility
@@ -432,6 +459,16 @@ Compile for the specified Java SE release.
432
459
433
460
Generate class files suitable for the specified Java SE release.
434
461
462
+
`JavaVersion` is an integer identifying a Java SE release, in the same
0 commit comments