StoreKit Api Deprication

Hi
with SKProductsRequest in StoreKit library is depricated and in ios 18.4 emulator I can not list my subscription items.

According to apple documentation swift based Storekit2 api must be used which is swift api as I understand.

Can anyone help me how can do it with moe sdk?

Thanks.

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.

I hope this helps!

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.

Thanks.

You have basically two options:

  1. Manual binding
  2. Automatic binding

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.

Thank you again so much,
I will try first approach.
Best regards Berstanio.

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 ?

Any idea to solve this problem?

thanks.

Here is my sample project:
test_swift.zip (5.2 MB)

@sebastian
You need to disable Enable Debug Dylib Support in the Build Settings of the XCode project. Then it works fine for me.

Thank you so much @Berstanio it works like charm.
You are the lifesaver. :grinning: :pray: