is StoreKit framework available ?

I tried to access some features of the StoreKit framework but it didn’t seems to work…

With this simple lines of code :

Declare Function NSClassFromString Lib "Foundation" (name As CFStringRef) As Ptr dim storeProductViewController as Ptr = NSClassFromString("SKStoreProductViewController")
the storeProductViewController pointer is null

Did I miss something ?

No, it’s not available. Right now the only way to link to other frameworks it to call one of the functions of the framework (not a selector on one of the classes in the framework, an actual framework function) so that the compiler is forced to link to the framework. This is because all declares which use selectors are silently soft declares so they are not resolved at compile time. We need to add a way to choose frameworks for the compiler to link against. There is a feedback case for this <https://xojo.com/issue/38186> but it is only visible to Alpha/Beta

Now is visible to everybody

You can load frameworks at runtime by calling dlopen.

But, Joe, how do we call Dlopen for an iOS build ?

Good to know, Joe
Can you give an example for the syntax to use?

[code]Sub LoadLibrary(filename As CString)
Declare Function dlopen Lib “/usr/lib/libSystem.dylib” ( filename As CString, flag As Int32 ) As Ptr
Declare Function dlerror Lib “/usr/lib/libSystem.dylib” () As CString
Const RTLD_LAZY = 1
Const RTLD_LOCAL = 4

Dim result As Ptr = dlopen(filename, RTLD_LAZY Or RTLD_LOCAL)
If result = Nil Then
Dim reason As Text = Text.FromCString(dlerror(), Xojo.Core.TextEncoding.UTF8)
Dim exc As New Xojo.Core.InvalidArgumentException
exc.Reason = reason
Raise exc
End If
End Sub[/code]

Thanks!

Excellent, thanks Joe! That opens up many possibilities. Do we need to worry about closing the framework or will that happen automatically when the app is closed?

I’ll go out of my way to explicitly say don’t close the framework via dlclose. Using dlclose is almost always the wrong thing to do, since the dynamic library may have done things that result in code loaded in the application referring to the dynamic library being unloaded.

For example, if the dynamic library passed a CFString to another framework, that framework may have called CFRetain and held onto it. If the dynamic library were to be unloaded, Bad Things would happen.

Great, thanks.

I would highly recommend using CFBundle or NSBundle to load frameworks.

Why? It just calls dlopen internally…

I prefer to use higher level APIs when possible.

Hi guys.

Thank you for the replies.

I tried to display an app store sheet view but nothing appears :frowning:

The simulator doesn’t allow to display the app store and this is less easy to debug on the device.
The code I tried to implement is based on this : http://www.techotopia.com/index.php/Making_Store_Purchases_with_the_SKStoreProductViewController_Class

if there is interested, I could spend some time writing a wrapper for StoreKit for iOS.
But that will not be easy.

[quote=173108:@Christian Schmitz]if there is interested, I could spend some time writing a wrapper for StoreKit for iOS.
But that will not be easy.[/quote]

In app purchase is a vital component for some marketing aspects to iOS apps. I am sure you would have a market if you could provide a solution.

Don’t you have a solution for Mac OS X already ?

christian please start coding

Yes, I have it for OS X, but could add one for iOS.

From what I can gather, a big part of iOS apps marketing is based on $0.99 apps with in app purchase for more features.

The app I have currently in the iOS app store offers a couple fonts, but the whole collection comprises a total of 30 font styles : dotted, with or without guidelines, with or without arrows, heavy, outline… If user could buy each font by simply click a button, I am sure it would sell more than having to shop iTunes.

From what I understand, a lot of apps rely on in app purchase for game levels, “Pro” features, and so on.

Your many OS X customers would no doubt appreciate being able to rely on MBS for iOS. I am one of them :slight_smile: