Closed
Description
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
- [Swift runtime features] Implement Swift metadata runtimelab#2838
- [Swift runtime features] Implement Swift value witness tables support runtimelab#2840
- [Swift language features] Implement Swift structs in C# runtimelab#2822
- [Swift language features] Implement Swift.Optional in C# runtimelab#2929
- [Swift language features] Implement Swift async runtimelab#2837
- [Swift language features] Implement Swift.Array in C# runtimelab#2833
- [Swift language features] Implement generic methods runtimelab#2940
- [Projection tooling] Implement type database runtimelab#2842
- [Swift language features] Implement Swift.Set in C# runtimelab#2834
- [Swift language features] Implement Swift.String in C# runtimelab#2831
- [Swift language features] Bind property getters runtimelab#2986
- [Swift language features] Implement
Foundation.Data
in C# runtimelab#2992
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
- [Swift language features] Implement Swift generics support for structs runtimelab#2930
- [Swift language features] Implement Swift generics support for enums runtimelab#2931
- [Swift language feature] Support async generics methods & special-case Array/Set bound generics methods runtimelab#3001
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
- [Projection tooling] Add symbols from dynamic library to type database runtimelab#2918
- [Swift ABI compatibility] Implement correct memory handling in C# bindings runtimelab#2851
- [Swift shipping] Implement testing framework runtimelab#2850
Risks
- Limited functionality due to dependencies on other frameworks
- Incomplete / non-functional bindings
- Poor UX
Note
This effort is experimental and not officially supported.