Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
58 tasks
Tracked by #95638
kotlarmilos opened this issue Dec 5, 2023 · 5 comments
Open
58 tasks
Tracked by #95638

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

kotlarmilos opened this issue Dec 5, 2023 · 5 comments
Assignees
Labels
area-Meta os-ios Apple iOS os-mac-os-x macOS aka OSX tracking This issue is tracking the completion of other related issues. User Story A single user-facing feature. Can be grouped under an epic.
Milestone

Comments

@kotlarmilos
Copy link
Member

kotlarmilos commented Dec 5, 2023

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, with focus on two key areas: functionality and performance.

Hiking app

We want to develop an experimental .NET iOS app which will serve as a base for implementing use-cases that showcase the capabilities of Swift interop. Selected functionalities from the app will be calling into Swift-only frameworks to demonstrate capabilities of the Swift interop. The app and corresponding bindings will not be officially supported.

Users of the app will be able to explore trails, authenticate using Apple ID, purchase a trail, and record a hike.

In-app purchase example

This example demonstrates in-app purchases and reviews using StoreKit2 framework. On the "Explore" page, items will be available for purchase via the products method. When the purchase button is clicked, it triggers the purchase method.

Target APIs:

  • PaymentMethodBinding
struct PaymentMethodBinding : Swift.Sendable, Swift.Hashable, Swift.Identifiable {}
  • Transaction
struct Transaction : Swift.Identifiable {}
  • Reason
struct Reason : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable, Swift.Sendable {}
  • RevocationReason
struct RevocationReason : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable {}
  • OfferType
struct OfferType : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable {}
  • OwnershipType
struct OwnershipType : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable {}
  • Offer
struct Offer : Swift.Equatable, Swift.Hashable, Swift.Sendable {}
  • PaymentMode
struct PaymentMode : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable, Swift.Sendable {}
  • Transactions
struct Transactions : _Concurrency.AsyncSequence {}
  • AsyncIterator
struct AsyncIterator : _Concurrency.AsyncIteratorProtocol {}
  • Environment
struct Environment : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable, Swift.Sendable {}
  • PurchaseIntent
struct PurchaseIntent : Swift.Equatable, Swift.Identifiable, Swift.Sendable {}
  • PurchaseIntents
struct PurchaseIntents : _Concurrency.AsyncSequence {}
  • Storefront
struct Storefront : Swift.Identifiable, Swift.Sendable {}
  • Storefronts
struct Storefronts : _Concurrency.AsyncSequence, Swift.Sendable {}
  • SubscriptionPeriod
struct SubscriptionPeriod : Swift.Equatable, Swift.Hashable {}
  • FormatStyle
struct FormatStyle : Foundation.FormatStyle {}
  • SubscriptionOffer
struct SubscriptionOffer : Swift.Equatable, Swift.Hashable {}
  • Signature
struct Signature : Swift.Equatable, Swift.Hashable, Swift.Sendable {}
  • Token
struct Token : Swift.Hashable, Swift.Sendable {}
  • RenewalState
struct RenewalState : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable {}
  • RenewalInfo
struct RenewalInfo {}
  • ExpirationReason
struct ExpirationReason : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable {}
  • Status
struct Status : Swift.Equatable, Swift.Hashable {}
  • Statuses
struct Statuses : _Concurrency.AsyncSequence {}
  • PromotionInfo
struct PromotionInfo : Swift.Equatable {}
  • AppTransaction
struct AppTransaction : Swift.Sendable {}
  • SubscriptionInfo
struct SubscriptionInfo : Swift.Equatable, Swift.Hashable {}
  • Message
struct Message : Swift.Sendable {}
  • Messages
struct Messages : _Concurrency.AsyncSequence, Swift.Sendable {}
  • PurchaseOption
struct PurchaseOption : Swift.Equatable, Swift.Hashable {}
  • Product
struct Product : Swift.Identifiable {}
  • ProductType
struct ProductType : Swift.RawRepresentable, Swift.Equatable, Swift.Hashable {}
  • PaymentMethodBindingError
enum PaymentMethodBindingError : Foundation.LocalizedError {}
  • RefundRequestError
enum RefundRequestError : Swift.Error {}
  • RefundRequestStatus
enum RefundRequestStatus {}
  • AppStore
enum AppStore {}
  • Unit
enum Unit : Swift.Equatable, Swift.Hashable {}
  • ExternalPurchase
enum ExternalPurchase : Swift.Sendable {}
  • NoticeResult
enum NoticeResult : Swift.Hashable, Swift.Sendable {}
  • ExternalPurchaseLink
enum ExternalPurchaseLink : Swift.Sendable {}
  • ExternalLinkAccount
enum ExternalLinkAccount : Swift.Sendable {}
  • ExternalPurchaseCustomLink
enum ExternalPurchaseCustomLink : Swift.Sendable {}
  • NoticeType
enum NoticeType : Swift.Int, Swift.Hashable, Swift.Sendable {}
  • PriceIncreaseStatus
enum PriceIncreaseStatus : Swift.Equatable, Swift.Hashable {}
  • VerificationResult
enum VerificationResult<SignedType> {}
  • VerificationError
enum VerificationError : Swift.Error {}
  • Visibility
enum Visibility : Swift.Int, Swift.Equatable, Swift.Hashable {}
  • StoreKitError
enum StoreKitError : Swift.Error {}
  • BackingValue
enum BackingValue : Swift.Equatable, Swift.Hashable {}
  • PurchaseResult
enum PurchaseResult {}
  • PrchaseError
enum PurchaseError : Swift.Error {}

Authentication example

This example demonstrates the authentication feature using the built-in SignInWithAppleButton on the “Login” page. Users can authenticate using their Apple ID, providing a seamless login experience.

Target APIs:

  • SignInWithAppleButton
@_Concurrency.MainActor @preconcurrency struct SignInWithAppleButton : SwiftUICore.View {}
  • SignInWithAppleButton.Label
struct Label {
    public static let signIn: _AuthenticationServices_SwiftUI.SignInWithAppleButton.Label
    public static let `continue`: _AuthenticationServices_SwiftUI.SignInWithAppleButton.Label
    public static let signUp: _AuthenticationServices_SwiftUI.SignInWithAppleButton.Label
}
  • SignInWithAppleButton.Style
struct Style {
    public static let black: _AuthenticationServices_SwiftUI.SignInWithAppleButton.Style
    public static let white: _AuthenticationServices_SwiftUI.SignInWithAppleButton.Style
    public static let whiteOutline: _AuthenticationServices_SwiftUI.SignInWithAppleButton.Style
}

SwiftUI views example

This example demonstrates how .NET developers can integrate native SwiftUI controls into MAUI-based applications, leveraging native UI controls for a seamless user experience.

This example implements SwiftUI views and serves as a foundation for the next examples. The “Login” page includes a login button and text. The main menu contains "Explore" and "My Trails" pages. The "Explore" page displays a list of available trails for purchase. Each item includes an image, text, and a "Buy" button. “Trail details” page displays an image and description. If the trail is not purchased, there is a "Purchase" button and an image; if it is purchased, there is a "Start/Stop" button and a map with start and end pins.

Views and controls should be sourced from the SwiftUI framework.

Target APIs:

Note

The .NET iOS app with generated bindings will be experimental in .NET 10 and will not be officially supported.

@kotlarmilos kotlarmilos added area-Meta User Story A single user-facing feature. Can be grouped under an epic. labels Dec 5, 2023
@kotlarmilos kotlarmilos added this to the 9.0.0 milestone Dec 5, 2023
@kotlarmilos kotlarmilos self-assigned this Dec 5, 2023
@ghost
Copy link

ghost commented Dec 5, 2023

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

This issue tracks the top-level scenarios for end-users regarding .NET Swift interop. The goal is to demonstrate the practical application of .NET Swift interop within Maui scenarios. One possible approach is to select an existing Maui sample from https://github.com/dotnet/maui-samples and improve it by incorporating native libraries and widgets, such as UIKit or SwiftUI. There are some other ideas, which may be desirable but not required, and will be added later.

Below is a list of tasks that needs to be implemented. Please note that the breakdown of the issues does not impose hard deadlines. If some of the functionality does not get upstreamed for a particular preview version, this issue will be updated accordingly.

Tasks

.NET9 Preview 1

  • Compile a list of libraries and features to support in .NET 9
  • Select Maui applications to showcase the .NET Swift interop
  • Propose design for VSCode extension

.NET9 Preview 2

  • Update Maui applications to utilize the .NET Swift interop
  • Implement and deploy the VSCode extension

.NET9 Preview 3

  • Implement telemetry for BTfS usage
  • Write a blog post that showcases the usage of .NET Swift interop

.NET9 Preview 4

TBD

Author: kotlarmilos
Assignees: kotlarmilos
Labels:

area-Meta, User Story

Milestone: 9.0.0

@kotlarmilos kotlarmilos changed the title [Tracking] End-users scenarios for .NET Swift interop in .NET 9 [Tracking] End-users scenarios for .NET Swift interop Dec 5, 2023
@kotlarmilos kotlarmilos changed the title [Tracking] End-users scenarios for .NET Swift interop [Tracking] End-user scenarios for .NET Swift interop Dec 5, 2023
@kotlarmilos kotlarmilos added the tracking This issue is tracking the completion of other related issues. label Dec 5, 2023
@kotlarmilos kotlarmilos changed the title [Tracking] End-user scenarios for .NET Swift interop End-user scenarios for .NET Swift interop Dec 5, 2023
@kotlarmilos kotlarmilos changed the title End-user scenarios for .NET Swift interop Crat Feb 12, 2024
@kotlarmilos kotlarmilos changed the title Crat Create dev templates for CryptoKit library Feb 12, 2024
@kotlarmilos kotlarmilos changed the title Create dev templates for CryptoKit library End-user scenarios for .NET Swift interop Feb 22, 2024
@jeffhandley jeffhandley added os-mac-os-x macOS aka OSX os-ios Apple iOS labels Aug 6, 2024
@vitek-karas vitek-karas modified the milestones: 9.0.0, 10.0.0 Aug 22, 2024
@kotlarmilos kotlarmilos changed the title End-user scenarios for .NET Swift interop Use-cases for Swift interop in .NET 10 Oct 8, 2024
@clarky07
Copy link

clarky07 commented Dec 5, 2024

I think live activity support would make sense for this (and lots of other use cases). Just commenting here as a suggestion I got from another issue.

@kotlarmilos
Copy link
Member Author

Thanks, there is a tracking issue: xamarin/xamarin-macios#17038

@amirvenus
Copy link

There are also some libraries available in Swift such as Apple's MLX.

It would be great if one could easily interop into Swift from .net.

@kotlarmilos
Copy link
Member Author

There are also some libraries available in Swift such as Apple's MLX.

Created a tracking issue: xamarin/xamarin-macios#21811

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Meta os-ios Apple iOS os-mac-os-x macOS aka OSX tracking This issue is tracking the completion of other related issues. User Story A single user-facing feature. Can be grouped under an epic.
Projects
None yet
Development

No branches or pull requests

5 participants