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
Java2Swift: Produce a protocol to aid with native method implementation
When an imported Java class has native methods that we expect to implement
from Swift, create a protocol names <Swift Type>NativeMethods that declares
all of the methods that need to be implemented.
From the user perspective, one should make the `@JavaImplements` extension
conform to this protocol. Then, the compiler will ensure that the right
Swift methods exist with the right signatures. Note that the user is
still responsible for ensuring that the appropriate `@JavaImplements` and
`@JavaMethod` annotations are present.
Copy file name to clipboardExpand all lines: USER_GUIDE.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -249,7 +249,7 @@ public class HelloSwift {
249
249
}
250
250
```
251
251
252
-
On the Swift side, the Java class needs to have been exposed to Swift through `Java2Swift.config`, e.g.,:
252
+
On the Swift side, the Java class needs to be exposed to Swift through `Java2Swift.config`, e.g.,:
253
253
254
254
```swift
255
255
{
@@ -259,11 +259,11 @@ On the Swift side, the Java class needs to have been exposed to Swift through `J
259
259
}
260
260
```
261
261
262
-
Implementations of `native` methods are written in an extension of the Swift type that has been marked with `@JavaImplements`. The methods themselves must be marked with `@JavaMethod`, indicating that they are available to Java as well. For example:
262
+
Implementations of `native` methods are written in an extension of the Swift type that has been marked with `@JavaImplements`. The methods themselves must be marked with `@JavaMethod`, indicating that they are available to Java as well. To help ensure that the Swift code implements all of the `native` methods with the right signatures, JavaKit produces a protocol with the Swift type name suffixed by `NativeMethods`. Declare conformance to that protocol and implement its requirements, for example:
0 commit comments