I'm very new to iOS, moving from Android development.
We have an Android application which has several libraries which we're using J2ObjC to translate into Objective C.
I've been gradually bringing over the libraries and so far, so good.
However, after translating Google's GSON library I have an issue where if I try and use the translated method toJsonWithId
I come across problems:
let gson = ComGoogleGsonGson()
let swiftTest = GsonSwiftTest()
swiftTest.name = "Ricky"
print(gson.toJsonWithId(swiftTest))
I receive the following error:
libc++abi.dylib: terminating with uncaught exception of type JavaLangAssertionError
Further it shows:
Terminating app due to uncaught exception 'JavaLangAssertionError', reason: 'unknown Java type encoding'
My Swift class is:
import Foundation
@objc
public class GsonSwiftTest : NSObject {
var name:String?
}
If I instead use an Objective C class in my Swift project, add it to the bridging header and use the Objective C class it works fine.
I believe this is a misunderstanding on my part, but I can't find the answer as to why this won't work. Checking the J2ObjC source code shows the error is raised when the type of class can't be found.
If anyone could help explain the reasons for this issue, it'd be appreciated.
Thanks!