Hi,
yes, Swift-only API’s are unfortunatly not easy with MOE.
With MOE 2.0 and if this project matures, we will be able to integrate it: GitHub - swiftlang/swift-java
However, until that is possible, the workflow looks the following:
In Xcode, you need to write your own swift wrapper/abstraction around the StoreKit 2 functions you need. You can then export these Swift wrappers to C or ObjC. Then you can bind your exported C/ObjC wrappers in MOE and call them.
Thank you Berstanio,
I was searching and I found a sample project in github with short youtube:
As you say in that project swift files connected to xcode with wrapper class and it can be used in regular objective-c classes.
I will try to do that, but can you give me a link to sample code or can you share a code snippets that how can I bind objectivec file to java side.
Sorry for my question, my ios knowledge is not good.
If you just need a small surface between Java ↔ StoreKit, I would recommend going for number one.
The easiest way would be, to write C functions/export the swift functions as C functions.
Then on the java side, just create a new class MyBinding, annotate it with @Runtime(CRuntime.class) and then you can do
@CFunction
public static native void function_name();
If you need more complex ObjC bindings, you can still go for number one and take inspiration from the iOS SDK binding code shipped with the moe-sdk.
Or for second you would need NatJGen. The closest to a sample project is this:
And to generate the binding code you can do ./gradlew moeNatJGen
For automatic binding generation I also recommend installing the IntelliJ plugin, as it supports better integration.
Hello Berstanio, after adding a Swift file to the Xcode project and when I try to build project in Xcode, it throws the following error:
ld: -pagezero_size can only be used when linking a main executable
As I understand this parameter is comes from MOE_PAGEZERO section and inserted “Other linker flags” subsection of “Linking-General” section.
But beside that project able to run from android studio but eventually project will need to be build from Xcode to be published to the App Store isn’t it ?