Skip to content

Use-cases for Swift interop in .NET 10 #95636

Closed
@kotlarmilos

Description

@kotlarmilos

Overview

This issue presents use-cases we want to support. They are required to define and limit the scope of Swift interop effort in .NET 10. While it's difficult to clearly specify the exact Swift language features that will be supported in the next release, we can establish our definition of done.

Milestone 1 – StoreKit2 purchase MVP

Implement basic purchase functionality without UI components. Below is an example of Swift pseudo code.

func requestProducts() async {
    do {
        let storeProducts = try await Product.products(for: productIdentifiers)
        products = storeProducts
    } catch {
        print("Error fetching products: \(error)")
    }
}

func purchase(_ product: Product) async throws -> Transaction? {
    let result = try await product.purchase()
    return result
}

Objectives

  • Establish projection tooling skeleton: parsers->marshalers->emitters
  • Project structs and it's members
  • Project Swift runtime features: metadata, value witness table, and async
  • Project optional types
  • Project Swift errors/exceptions in C#
  • Project StoreKit2 types with its members needed for the basic purchase functionality. Specifically:
    • struct Product : Swift.Identifiable {}

Deliverables

Risks

  • Work items are too broad, which may affect group focus
  • Significant fundamental work on the projection tooling in a single iteration

Milestone 2 – Subscriptions and list purchased products

Implement advanced purchase experience with subscriptions and list of already purchased products. Below is an example of Swift pseudo code.

func updateProductStatus() async {
    var purchasedProducts: [Product] = []

    for await result in Transaction.currentEntitlements {
        do {
            switch transaction.productType {
            case .nonConsumable:
                //
            case .nonRenewable:
                // 
            case .autoRenewable:
                // 
            default:
                break
            }
        } catch {
            print("Transaction failed verification: \(error)")
        }
    }
}

Objectives

  • Project enums and it's members
  • Project StoreKit2 types needed for subscriptions purchase functionality. Specifically:
    • struct Transaction : Swift.Identifiable {}
    • struct Product.Subscription* : Swift.Identifiable {}

Deliverables

Risks

  • Limited functionality due to dependencies on other frameworks

Milestone 3 – Pack StoreKit2 bindings in the experimental NuGet

Pack and distribute StoreKit2 bindings for supported scenarios.

Objectives

  • Implement in-app purchase using StoreKit bindings NuGet
  • Make the projection tooling extensible and ensure it outputs only supported types
  • Implement simple KPI metrics

Deliverables

Risks

  • Limited functionality due to dependencies on other frameworks
  • Incomplete / non-functional bindings
  • Poor UX

Note

This effort is experimental and not officially supported.

Metadata

Metadata

Assignees

Labels

User StoryA single user-facing feature. Can be grouped under an epic.area-Metaos-iosApple iOSos-mac-os-xmacOS aka OSXtrackingThis issue is tracking the completion of other related issues.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions