Skip to content

Release build failed to validate because the result dynamic link library doesn't export native method symbols #492

@rayman-zhao

Description

@rayman-zhao

Steps to reproduce on macOS 26 :

  1. Git clone the main branch;
  2. In the swift-java/Samples/JavaKitSampleApp folder, run "swift build";
  3. The debug build works perfectly, ci-validate.sh passed;
  4. Then create release build by running "swift build -c release";
  5. Validate result based on the ci-validate.sh script;

Result:

java -cp .build/plugins/outputs/javakitsampleapp/JavaKitExample/destination/JavaCompilerPlugin/Java -Djava.library.path=.build/release "com.example.swift.JavaKitSampleMain"

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'int com.example.swift.HelloSwift.sayHello(int, int)'
at com.example.swift.HelloSwift.sayHello(Native Method)
at com.example.swift.JavaKitSampleMain.main(JavaKitSampleMain.java:23)

The nm tool shows the release build missing exports native functions similar to debug build:

0000000000002a20 T _Java_com_example_swift_HelloSwift_sayHello
00000000000041d0 T _Java_com_example_swift_HelloSwift_throwMessageFromSwift

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions