Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Konstantin 🔭
@konstantin@hachyderm.io  ·  activity timestamp 2 weeks ago

Does anyone know if #Swift has something like the experimental flags in #Kotlin? Example: I want to publish a very edgy-probably-only-works-on-my-iPhone API in a library but I want to make it very clear to people using the API that they're walking on unstable grounds

#IndieDev

  • Copy link
  • Flag this post
  • Block
Ole Begemann
@ole@chaos.social replied  ·  activity timestamp 2 weeks ago

@konstantin Package traits (https://github.com/swiftlang/swift-evolution/blob/main/proposals/0450-swiftpm-package-traits.md) seem to be SwiftPM’s modern solution for optional package features that clients need to enable manually. I’d say a trait named “experimental” or “unstable” makes the intent pretty clear.

GitHub

swift-evolution/proposals/0450-swiftpm-package-traits.md at main · swiftlang/swift-evolution

This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swiftlang/swift-evolution
  • Copy link
  • Flag this comment
  • Block
Konstantin 🔭
@konstantin@hachyderm.io replied  ·  activity timestamp 2 weeks ago

@ole thank you! I will check it out

  • Copy link
  • Flag this comment
  • Block
Christian Tietze
@ctietze@mastodon.social replied  ·  activity timestamp 2 weeks ago

@konstantin you can use compiler flags or environment variables, but IIRC they don't get passed on from Xcode app builds like they do when you build the lib from the CLI 🤔

  • Copy link
  • Flag this comment
  • Block
Konstantin 🔭
@konstantin@hachyderm.io replied  ·  activity timestamp 2 weeks ago

@ctietze That's a lot of work maybe 😅. I'm asking for https://github.com/TootSDK/TootSDK/pull/392 - @dale_price had an excellent idea that we can support some "alpha" APIs from Mastodon but I want to make it clear that it's early days. One way is maybe using the underscore prefix in the name but I can't think of a solid, universally understood way of indicating experiments in Swift.

  • Copy link
  • Flag this comment
  • Block
Konstantin 🔭
@konstantin@hachyderm.io replied  ·  activity timestamp 2 weeks ago

@ctietze @dale_price Oh I found this! https://varanios.com/articles/spi-or-how-to-develop-better-apis-in-swift/

A method marked with `@_spi(Experimental)` requires a `@_spi(Experimental)` to opt in. That's not bad maybe

VaraniOS

@_spi or How to develop better APIs in Swift | VaraniOS

Learn the fundamentals of System Programming Interfaces (SPIs) and how to leverage them in Swift.
  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login