swiftlang / swiftlang/swift-java
Unable to use Swift function that returns String on Java side
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.2k
- Forks
- 123
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 16
Description
I'm using jextract-swift to create Java Classes for the Sources/MySwiftLibrary/SwiftKitSamleApp for the sample SwiftKitSampleApp.
I created the following function just to test something in HelloJava2Swift.swift
public func retrieveToken() -> String {
return "test"
}
But when I try to do the following in MySwiftLibraryTest.java
@Test
void call_retrieveToken() {
MySwiftLibrary.retrieveToken();
assertNotNull(MySwiftLibrary.retrieveToken$address());
}
It gives the following error
I'm probably forgetting something important.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the retrieveToken declaration in Sources/MySwiftLibrary/HelloJava2Swift.swift and the generated call in MySwiftLibraryTest.java. Reproduce the failure using the jextract-swift-generated MySwiftLibrary classes, then determine what prevents a Swift String return from being called on the Java side. Done means the Java test can call retrieveToken() and assert that retrieveToken$address() is not null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, swift
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100