Skip to content

Sharpie errors #1

@kerams

Description

@kerams

Hello, I am trying to follow the instructions, but sharpie is giving me more than 50 errors (problems proccessing header files or something), but it does actually create ApiDefinitions.cs.

import Foundation
import StoreKit;

// xcodebuild -create-xcframework -framework Build/Products/Release-iphoneos/StoreKit2.framework -framework Build/Products/Release-iphonesimulator/StoreKit2.framework -output a.xcframework
// sharpie bind Build/Products/Release-iphoneos/StoreKit2.framework/Headers/StoreKit2-Swift.h --sdk iphoneos18.4

@objc public final class StoreKit2Bindings : NSObject
{
    @objc public static func showManageSubscriptions(in scene: UIWindowScene) async throws {
        try await AppStore.showManageSubscriptions(in: scene)
    }
    
    @objc public static func products(in productIds: [String]) async throws -> [ProductInfo]
    {
        let ps = try await Product.products(for: productIds)
        return ps.map { ProductInfo(x: $0) }
    }
}

@objc public class ProductInfo: NSObject {
    @objc public let id: String
    @objc public let price: NSDecimalNumber
    @objc public let displayPrice: String
    @objc public let desc: String

    internal init(x: Product)
    {
        self.price = NSDecimalNumber(decimal: x.price)
        self.displayPrice = x.displayPrice
        self.id = x.id
        self.desc = x.description
    }
}
using System;
using Foundation;
using ObjCRuntime;
using UIKit;

// @interface ProductInfo
[DisableDefaultCtor]
interface ProductInfo
{
	// @property (readonly, nonatomic, strong) NSString * _Nonnull id;
	[Export ("id", ArgumentSemantic.Strong)]
	string Id { get; }

	// @property (readonly, nonatomic, strong) NSDecimalNumber * _Nonnull price;
	[Export ("price", ArgumentSemantic.Strong)]
	NSDecimalNumber Price { get; }

	// @property (readonly, nonatomic, strong) NSString * _Nonnull displayPrice;
	[Export ("displayPrice", ArgumentSemantic.Strong)]
	string DisplayPrice { get; }

	// @property (readonly, nonatomic, strong) NSString * _Nonnull desc;
	[Export ("desc", ArgumentSemantic.Strong)]
	string Desc { get; }
}

// @interface StoreKit2Bindings
interface StoreKit2Bindings
{
	// +(void)showManageSubscriptionsIn:(UIWindowScene * _Nonnull)scene completionHandler:(void (^ _Nonnull)(int * _Nullable))completionHandler;
	[Static]
	[Export ("showManageSubscriptionsIn:completionHandler:")]
	unsafe void ShowManageSubscriptionsIn (UIWindowScene scene, Action<int*> completionHandler);

	// +(void)productsIn:(id)productIds completionHandler:(void (^ _Nonnull)(int))completionHandler;
	[Static]
	[Export ("productsIn:completionHandler:")]
	void ProductsIn (NSObject productIds, Action<int> completionHandler);
}

However, it does not look right compared to your sample:

// +(void)showManageSubscriptionsIn:(UIWindowScene * _Nonnull)scene completionHandler:(void (^ _Nonnull)(NSError * _Nullable))completionHandler;
[Static]
[Export ("showManageSubscriptionsIn:completionHandler:")]
void ShowManageSubscriptionsIn (UIWindowScene scene, Action<NSError> completionHandler);

The callback in my ShowManageSubscriptionsIn returns a pointer instead of NSError. productIds in the second method is NSObject instead of string[], and the method also does not reference ProductInfo, which is supposed to be the return type.

Do you have any clue what's going wrong?

I am using XCode 16.3, iphone SDK 18.4, and sharpie installed via brew. I also don't know Swift or how to really use xcode either, so this could all be due to some blatant mistake on my part.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions