From e5cde4635f83683146e4743064ed40691625289f Mon Sep 17 00:00:00 2001 From: Gabriele Mondada Date: Fri, 27 Mar 2026 19:17:08 +0100 Subject: [PATCH 1/2] Fix JNI symbols not exposed in release mode --- Sources/SwiftJavaMacros/ImplementsJavaMacro.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift b/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift index 02a784bec..e6e17b1cb 100644 --- a/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift +++ b/Sources/SwiftJavaMacros/ImplementsJavaMacro.swift @@ -210,7 +210,7 @@ extension JavaImplementationMacro: PeerMacro { exposedMembers.append( """ @_cdecl(\(literal: cName)) - func \(context.makeUniqueName(swiftName))(\(raw: cParameters.map{ $0.description }.joined(separator: ", ")))\(raw: cReturnType) { + public func \(context.makeUniqueName(swiftName))(\(raw: cParameters.map{ $0.description }.joined(separator: ", ")))\(raw: cReturnType) { \(body) } """ From 8ee7f7ba07f2dfe9f4b945dcd49be80c03e4cf82 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Sun, 29 Mar 2026 17:39:11 +0900 Subject: [PATCH 2/2] fix tests to accept the expected public --- .../JavaImplementationMacroTests.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift b/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift index 2019acd67..5dcd60a07 100644 --- a/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift +++ b/Tests/SwiftJavaMacrosTests/JavaImplementationMacroTests.swift @@ -45,7 +45,7 @@ class JavaImplementationMacroTests: XCTestCase { } @_cdecl("Java_org_swift_example_Hello_1World_test_1method") - func __macro_local_11test_methodfMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_11test_methodfMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { let obj = HelloWorld(javaThis: thisObj, environment: environment!) return obj.test_method() .getJNILocalRefValue(in: environment) @@ -75,7 +75,7 @@ class JavaImplementationMacroTests: XCTestCase { } @_cdecl("Java_com_example_test_MyClass_simpleMethod") - func __macro_local_12simpleMethodfMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_12simpleMethodfMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { let obj = MyClass(javaThis: thisObj, environment: environment!) return obj.simpleMethod() .getJNILocalRefValue(in: environment) @@ -105,7 +105,7 @@ class JavaImplementationMacroTests: XCTestCase { } @_cdecl("Java_org_example_Utils_static_1helper") - func __macro_local_13static_helperfMu_(environment: UnsafeMutablePointer!, thisClass: jclass) -> String.JNIType { + public func __macro_local_13static_helperfMu_(environment: UnsafeMutablePointer!, thisClass: jclass) -> String.JNIType { return Utils.static_helper(environment: environment) .getJNILocalRefValue(in: environment) } @@ -142,14 +142,14 @@ class JavaImplementationMacroTests: XCTestCase { } @_cdecl("Java_test_Class_1With_1Underscores_method_1one") - func __macro_local_10method_onefMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_10method_onefMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { let obj = ClassWithUnderscores(javaThis: thisObj, environment: environment!) return obj.method_one() .getJNILocalRefValue(in: environment) } @_cdecl("Java_test_Class_1With_1Underscores_method_1two") - func __macro_local_10method_twofMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { + public func __macro_local_10method_twofMu_(environment: UnsafeMutablePointer!, thisObj: jobject) -> Int32.JNIType { let obj = ClassWithUnderscores(javaThis: thisObj, environment: environment!) return obj.method_two() .getJNILocalRefValue(in: environment) @@ -187,13 +187,13 @@ class JavaImplementationMacroTests: XCTestCase { } @_cdecl("Java_org_swift_swiftkit_core_collections_SwiftDictionaryMap__00024size") - func __macro_local_5_sizefMu_(environment: UnsafeMutablePointer!, thisClass: jclass, pointer: Int64.JNIType) -> Int32.JNIType { + public func __macro_local_5_sizefMu_(environment: UnsafeMutablePointer!, thisClass: jclass, pointer: Int64.JNIType) -> Int32.JNIType { return SwiftDictionaryMapJava._size(environment: environment, pointer: Int64(fromJNI: pointer, in: environment!)) .getJNILocalRefValue(in: environment) } @_cdecl("Java_org_swift_swiftkit_core_collections_SwiftDictionaryMap__00024destroy") - func __macro_local_8_destroyfMu_(environment: UnsafeMutablePointer!, thisClass: jclass, pointer: Int64.JNIType) { + public func __macro_local_8_destroyfMu_(environment: UnsafeMutablePointer!, thisClass: jclass, pointer: Int64.JNIType) { return SwiftDictionaryMapJava._destroy(environment: environment, pointer: Int64(fromJNI: pointer, in: environment!)) } """, @@ -221,7 +221,7 @@ class JavaImplementationMacroTests: XCTestCase { } @_cdecl("Java_org_example_Processor_process_1data") - func __macro_local_12process_datafMu_(environment: UnsafeMutablePointer!, thisObj: jobject) { + public func __macro_local_12process_datafMu_(environment: UnsafeMutablePointer!, thisObj: jobject) { let obj = Processor(javaThis: thisObj, environment: environment!) return obj.process_data() }