# Using Swift

**URL:** https://forums.swift.org/c/swift-users/15.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [About the Using Swift category](https://forums.swift.org/t/about-the-using-swift-category/21)

<div class="topic-metadata">

**Author:** [@system](https://forums.swift.org/u/system)\
**Replies:** 0\
**Last updated:** [January 18, 2018, 7:44am UTC](https://forums.swift.org/t/about-the-using-swift-category/21 "2018-01-18T07:44:47Z")

</div>

This area is intended for users to get help with or ask questions about Swift or its related tools. Beginner questions welcome! This category is not for discussion about work being done to the language itself. This ca…

---

## [Use Swift's type system to restrict values](https://forums.swift.org/t/use-swifts-type-system-to-restrict-values/70919)

<div class="topic-metadata">

**Author:** [@wigging](https://forums.swift.org/u/wigging)\
**Replies:** 22\
**Last updated:** [October 30, 2026, 1:25pm UTC](https://forums.swift.org/t/use-swifts-type-system-to-restrict-values/70919 "2026-10-30T13:25:56Z")

</div>

I would like to restrict a function input to the values of 1, 2, or 3. In the example below, the doSomething() function throws an error if the scale input is not 1, 2, or 3. But is there a way to handle this without havi…

---

## [Rethinking propagation of ~Copyable and ~Escapable constraints](https://forums.swift.org/t/rethinking-propagation-of-copyable-and-escapable-constraints/90324)

<div class="topic-metadata">

**Author:** [@juliand665](https://forums.swift.org/u/juliand665)\
**Replies:** 6\
**Last updated:** [October 30, 2026, 9:13am UTC](https://forums.swift.org/t/rethinking-propagation-of-copyable-and-escapable-constraints/90324 "2026-10-30T09:13:38Z")

</div>

I've been writing a lot of code lately using ~Copyable and ~Escapable, and I keep butting heads with the compiler automatically inserting Copyable and Escapable constraints on protocols that refine ~Copyable and ~Escapab…

---

## [Difficulties using pre-releases of swift packages](https://forums.swift.org/t/difficulties-using-pre-releases-of-swift-packages/90336)

<div class="topic-metadata">

**Author:** [@samuelmurray](https://forums.swift.org/u/samuelmurray)\
**Replies:** 0\
**Last updated:** [October 29, 2026, 10:21pm UTC](https://forums.swift.org/t/difficulties-using-pre-releases-of-swift-packages/90336 "2026-10-29T22:21:46Z")

</div>

This is how I understand pre-release versions to work in SPM: If package C has versions "1.0.0" and "1.1.0-alpha", and application A depends on C using .package(id: "C", from: "1.0.0"), only version "1.0.0" will be cons…

---

## [Behavior of @ \_inheritActorContext in Global vs Instance Actors](https://forums.swift.org/t/behavior-of-inheritactorcontext-in-global-vs-instance-actors/90196)

<div class="topic-metadata">

**Author:** [@owenkealey](https://forums.swift.org/u/owenkealey)\
**Replies:** 7\
**Last updated:** [October 26, 2026, 9:05pm UTC](https://forums.swift.org/t/behavior-of-inheritactorcontext-in-global-vs-instance-actors/90196 "2026-10-26T21:05:54Z")

</div>

Follow up question after reading through Why is a Task closure defined in an Actor's method nonisolated? - #17 by NotTheNHK Calling foo on the below results in two prints for "MainActor". This makes sense to me -- foo i…

---

## [Allocations instrument fails to attach to SwiftPM executable target](https://forums.swift.org/t/allocations-instrument-fails-to-attach-to-swiftpm-executable-target/81093)

<div class="topic-metadata">

**Author:** [@svmkr](https://forums.swift.org/u/svmkr)\
**Replies:** 4\
**Last updated:** [October 25, 2026, 8:16pm UTC](https://forums.swift.org/t/allocations-instrument-fails-to-attach-to-swiftpm-executable-target/81093 "2026-10-25T20:16:50Z")

</div>

Let's say we have simple CLI application defined in SPM, eg simplest hello world generated using swift package init --name MyCLI --type executable I open it in Xcode (16.4, 26 beta 3, doesn't matter) and press cmd + i t…

---

## [Is @resultBuilder broken on Linux](https://forums.swift.org/t/is-resultbuilder-broken-on-linux/90257)

<div class="topic-metadata">

**Author:** [@eueu](https://forums.swift.org/u/eueu)\
**Replies:** 2\
**Last updated:** [October 25, 2026, 3:29pm UTC](https://forums.swift.org/t/is-resultbuilder-broken-on-linux/90257 "2026-10-25T15:29:20Z")

</div>

I'm trying to use @resultBuilderresultBuilderresultBuilderresultBuilder on Linux, my compiler is 6.2.4, but it is consistently rewriting the closure in crazy ways. For instance, if there is an array builder defined, it …

---

## [Can I use the Swift logo for use in swift plugins?](https://forums.swift.org/t/can-i-use-the-swift-logo-for-use-in-swift-plugins/90229)

<div class="topic-metadata">

**Author:** [@quitelight](https://forums.swift.org/u/quitelight)\
**Replies:** 2\
**Last updated:** [October 25, 2026, 2:11am UTC](https://forums.swift.org/t/can-i-use-the-swift-logo-for-use-in-swift-plugins/90229 "2026-10-25T02:11:27Z")

</div>

Hi there, I'm thinking of publishing my own Swift plugins for Jetbrains IDEs and VS Code IDEs (yes I know they already exist but I want to have a crack anyway). I'd like to use the Swift Logo (without modification) for…

---

## [Stale view update in \`willSet\` (Observation & SwiftUI)?](https://forums.swift.org/t/stale-view-update-in-willset-observation-swiftui/90131)

<div class="topic-metadata">

**Author:** [@oscbyspro](https://forums.swift.org/u/oscbyspro)\
**Replies:** 0\
**Last updated:** [October 18, 2026, 6:36am UTC](https://forums.swift.org/t/stale-view-update-in-willset-observation-swiftui/90131 "2026-10-18T06:36:12Z")

</div>

I have encountered a synchronization issue while developing my iOS app where two parts of a SwiftUI view graph disagree on the same @MainActor @Observable view model state. Imagine two views that access currentValue in t…

---

## [Using SF-0011 with protocols](https://forums.swift.org/t/using-sf-0011-with-protocols/90115)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 0\
**Last updated:** [October 16, 2026, 10:19am UTC](https://forums.swift.org/t/using-sf-0011-with-protocols/90115 "2026-10-16T10:19:14Z")

</div>

Because conformance to AnyObject is not the same as subtyping of any AnyObject, SF-0011 does not allow to use existentials of AnyObject-constrained protocols as Subject, unless they are marked as @objc. protocol MySubje…

---

## [Revisiting reliable testing of concurrent code](https://forums.swift.org/t/revisiting-reliable-testing-of-concurrent-code/88910)

<div class="topic-metadata">

**Author:** [@erikbasargin](https://forums.swift.org/u/erikbasargin)\
**Replies:** 7\
**Last updated:** [October 15, 2026, 8:07pm UTC](https://forums.swift.org/t/revisiting-reliable-testing-of-concurrent-code/88910 "2026-10-15T20:07:36Z")

</div>

Hello everyone! I'd like to revisit the topic of reliably testing concurrent Swift code and gather your opinions. The original discussion is a few years old now, the follow-up on task executors is also no longer new, an…

---

## [Updating array slices doesn't show error/warning in the editor](https://forums.swift.org/t/updating-array-slices-doesnt-show-error-warning-in-the-editor/90034)

<div class="topic-metadata">

**Author:** [@arunkumar413](https://forums.swift.org/u/arunkumar413)\
**Replies:** 5\
**Last updated:** [October 15, 2026, 4:36am UTC](https://forums.swift.org/t/updating-array-slices-doesnt-show-error-warning-in-the-editor/90034 "2026-10-15T04:36:14Z")

</div>

Hi Team, I was playing with arrays and its slices. I noticed that the editor doesn't show the error or warning if I'm trying to update/insert an element in the slice. My thinking is that as the slice sliceNames is decla…

---

## [@available and #available](https://forums.swift.org/t/available-and-available/90062)

<div class="topic-metadata">

**Author:** [@somu](https://forums.swift.org/u/somu)\
**Replies:** 6\
**Last updated:** [October 14, 2026, 11:42pm UTC](https://forums.swift.org/t/available-and-available/90062 "2026-10-14T23:42:09Z")

</div>

Overview There is an enum Engine in the framework which has a case only available iOS 27 onwards I have an enum Car which uses the Engine in a switch statement Question Is there a better way to implement Car.engine? I…

---

## [Trying to get crash backtracing to work on Windows](https://forums.swift.org/t/trying-to-get-crash-backtracing-to-work-on-windows/89054)

<div class="topic-metadata">

**Author:** [@ktraunmueller](https://forums.swift.org/u/ktraunmueller)\
**Replies:** 13\
**Last updated:** [October 14, 2026, 5:23pm UTC](https://forums.swift.org/t/trying-to-get-crash-backtracing-to-work-on-windows/89054 "2026-10-14T17:23:35Z")

</div>

I am trying to get the Swift runtime's crash backtracing to work for my Swift (Windows App SDK) GUI app (as a starting point for building some crash reporting service around that later on). I am using a very recent Swif…

---

## [Syntax for \`nonsiolated(nonsending)\` closure literal?](https://forums.swift.org/t/syntax-for-nonsiolated-nonsending-closure-literal/90038)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 3\
**Last updated:** [October 14, 2026, 5:22pm UTC](https://forums.swift.org/t/syntax-for-nonsiolated-nonsending-closure-literal/90038 "2026-10-14T17:22:52Z")

</div>

I'm trying to audit cases of nonisolated async functions in our codebase. I'm getting a warning for closure literals: await withTaskCancellationHandler { // warning: Feature 'NonisolatedNonsendingByDefault' will cause …

---

## [PSA: Swift 6.4.0 breaks non-inlined macros from reading from disk on linux](https://forums.swift.org/t/psa-swift-6-4-0-breaks-non-inlined-macros-from-reading-from-disk-on-linux/89862)

<div class="topic-metadata">

**Author:** [@RandomHashTags](https://forums.swift.org/u/RandomHashTags)\
**Replies:** 5\
**Last updated:** [October 13, 2026, 6:59pm UTC](https://forums.swift.org/t/psa-swift-6-4-0-breaks-non-inlined-macros-from-reading-from-disk-on-linux/89862 "2026-10-13T18:59:51Z")

</div>

As the title states, I am observing my macros that read from disk to no longer work as expected on Linux using the 6.4.0 toolchain. However, they do work as expected if I inline the macro and when expanding it. Is this …

---

## [\[6.4\] Runtime Crash from SwiftUI parameter packs](https://forums.swift.org/t/6-4-runtime-crash-from-swiftui-parameter-packs/90043)

<div class="topic-metadata">

**Author:** [@vanvoorden](https://forums.swift.org/u/vanvoorden)\
**Replies:** 0\
**Last updated:** [October 13, 2026, 5:21pm UTC](https://forums.swift.org/t/6-4-runtime-crash-from-swiftui-parameter-packs/90043 "2026-10-13T17:21:30Z")

</div>

I would really like some help to bring this runtime crash over the finish line and hopefully find a fix. Anyone that can help triage or debug can please comment here or on the tasks. This SwiftUI app will instacrash whe…

---

## [Benchmarking different RegEx implementations](https://forums.swift.org/t/benchmarking-different-regex-implementations/90008)

<div class="topic-metadata">

**Author:** [@LeoAvMo](https://forums.swift.org/u/LeoAvMo)\
**Replies:** 3\
**Last updated:** [October 12, 2026, 10:43pm UTC](https://forums.swift.org/t/benchmarking-different-regex-implementations/90008 "2026-10-12T22:43:55Z")

</div>

As part of my compilers class, the teacher told me that we will be coming across with Regular Expressions (RegEx). Since I want to do the project in Swift, I tried experimenting today with the ways to do RegExs. After so…

---

## [Swift Setup Error in Windows 11](https://forums.swift.org/t/swift-setup-error-in-windows-11/90001)

<div class="topic-metadata">

**Author:** [@PardeepBagga](https://forums.swift.org/u/PardeepBagga)\
**Replies:** 3\
**Last updated:** [October 11, 2026, 3:09pm UTC](https://forums.swift.org/t/swift-setup-error-in-windows-11/90001 "2026-10-11T15:09:42Z")

</div>

I am getting this error again and again. plese help error: 'mycli': Invalid manifest (compiled with: \["C:\\Users\\parde\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.4.0+Asserts\\usr\\bin\\swiftc.exe", "-vfsoverlay", "C:\\Users\\…

---

## [Swift Concurrency - never main thread](https://forums.swift.org/t/swift-concurrency-never-main-thread/89978)

<div class="topic-metadata">

**Author:** [@Jon889](https://forums.swift.org/u/Jon889)\
**Replies:** 2\
**Last updated:** [October 10, 2026, 4:08pm UTC](https://forums.swift.org/t/swift-concurrency-never-main-thread/89978 "2026-10-10T16:08:21Z")

</div>

I have a function from a legacy library which asserts that it's not running on the main thread: func foo() { if Thread.isMainThread { assertionFailure("should not be called from the main thread") return } // .…

---

## [Strange behavior of borrowing param](https://forums.swift.org/t/strange-behavior-of-borrowing-param/89888)

<div class="topic-metadata">

**Author:** [@giik](https://forums.swift.org/u/giik)\
**Replies:** 5\
**Last updated:** [October 10, 2026, 9:40am UTC](https://forums.swift.org/t/strange-behavior-of-borrowing-param/89888 "2026-10-10T09:40:47Z")

</div>

The compiler (Swift 6.4/macOS 27.0.1) rejects the following code with 'previousSnapshot' cannot be captured by an escaping closure since it is a borrowed parameter and two locations are indicated (see // rejected! below…

---

## [Attempting to use Dependency injection](https://forums.swift.org/t/attempting-to-use-dependency-injection/89900)

<div class="topic-metadata">

**Author:** [@somu](https://forums.swift.org/u/somu)\
**Replies:** 17\
**Last updated:** [October 9, 2026, 2:43pm UTC](https://forums.swift.org/t/attempting-to-use-dependency-injection/89900 "2026-10-09T14:43:11Z")

</div>

Hi, I have a class called Box that I use in production. The initializer takes in no arguments. However for some SwiftUI previews / test cases I would like that class to be initialized with some values. I don't want t…

---

## [Is it possible to enable a trait for a target within the same package](https://forums.swift.org/t/is-it-possible-to-enable-a-trait-for-a-target-within-the-same-package/89805)

<div class="topic-metadata">

**Author:** [@BitByAVampire](https://forums.swift.org/u/BitByAVampire)\
**Replies:** 1\
**Last updated:** [October 7, 2026, 2:05pm UTC](https://forums.swift.org/t/is-it-possible-to-enable-a-trait-for-a-target-within-the-same-package/89805 "2026-10-07T14:05:24Z")

</div>

Let's say i have a module A that depends on Module B in the same package, and B has a trait that is optionally enabled. Can A add B as a dependency with the trait enabled, just for A?

---

## [openKylin show picture use swift GUI](https://forums.swift.org/t/openkylin-show-picture-use-swift-gui/89929)

<div class="topic-metadata">

**Author:** [@liyuansi](https://forums.swift.org/u/liyuansi)\
**Replies:** 0\
**Last updated:** [October 7, 2026, 12:51am UTC](https://forums.swift.org/t/openkylin-show-picture-use-swift-gui/89929 "2026-10-07T00:51:32Z")

</div>

openKylin show picture use swift GUI git clone https://gitcode.com/liyuansi2222/helloworld-swift-gui.git cd helloworld-swift-gui swift build swift run the result go out . the important two line are this: l…

---

## [Unorthodox recursive data structures](https://forums.swift.org/t/unorthodox-recursive-data-structures/89885)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 2\
**Last updated:** [October 4, 2026, 10:28am UTC](https://forums.swift.org/t/unorthodox-recursive-data-structures/89885 "2026-10-04T10:28:48Z")

</div>

The topic name is a bit misleading as what's discussed here: could be mutable could be truly allocation free, could be stack allocated or in some cases uses heap allocation behind the curtains. could be truly dynamic (…

---

## [SwiftData + Transferable](https://forums.swift.org/t/swiftdata-transferable/82299)

<div class="topic-metadata">

**Author:** [@bdkjones](https://forums.swift.org/u/bdkjones)\
**Replies:** 1\
**Last updated:** [October 3, 2026, 9:19pm UTC](https://forums.swift.org/t/swiftdata-transferable/82299 "2026-10-03T21:19:26Z")

</div>

Suppose we have a SwiftData Model: @Model class Contact { var firstName: String? var lastName: String? } We make this model Codable (I’ll skip showing the implementation; it’s standard). Now we want to allow o…

---

## [Lazy NSObject + deinit = trap](https://forums.swift.org/t/lazy-nsobject-deinit-trap/89879)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 0\
**Last updated:** [October 3, 2026, 8:18pm UTC](https://forums.swift.org/t/lazy-nsobject-deinit-trap/89879 "2026-10-03T20:18:07Z")

</div>

Found an interesting foot-gun (only traps with NSObject classes and only with Foundation on Apple platforms): import Foundation class C: NSObject { lazy var foo: Int = { // Thread 1: abort with payload or r…

---

## [Passing String and Data sequences to sqlite\_carray\_bind](https://forums.swift.org/t/passing-string-and-data-sequences-to-sqlite-carray-bind/89832)

<div class="topic-metadata">

**Author:** [@prathameshk](https://forums.swift.org/u/prathameshk)\
**Replies:** 3\
**Last updated:** [October 3, 2026, 8:51am UTC](https://forums.swift.org/t/passing-string-and-data-sequences-to-sqlite-carray-bind/89832 "2026-10-03T08:51:34Z")

</div>

I'm trying to work with sqlite\_carray\_bind from the sqlite library. Here is what I have working for binding a sequence of strings: func bind\<S: Sequence\<String\>\>(strings: S, to statement: OpaquePointer?, at index: Int3…

---

## [After await, it doesn't return to the main thread](https://forums.swift.org/t/after-await-it-doesnt-return-to-the-main-thread/88359)

<div class="topic-metadata">

**Author:** [@carlhung](https://forums.swift.org/u/carlhung)\
**Replies:** 33\
**Last updated:** [October 2, 2026, 2:58pm UTC](https://forums.swift.org/t/after-await-it-doesnt-return-to-the-main-thread/88359 "2026-10-02T14:58:20Z")

</div>

@main struct StrictPlayground { // @MainActor // uncomment it, it will get the same result. static func main() async throws { print("1,", Thread.isMainThread) try await run() print("3,", Thread.isMainThre…

---

## [Default actor isolation and deinit](https://forums.swift.org/t/default-actor-isolation-and-deinit/84511)

<div class="topic-metadata">

**Author:** [@Aquis](https://forums.swift.org/u/Aquis)\
**Replies:** 6\
**Last updated:** [October 2, 2026, 3:11am UTC](https://forums.swift.org/t/default-actor-isolation-and-deinit/84511 "2026-10-02T03:11:47Z")

</div>

Consider this example: class Base { } class Sub: Base { deinit { } } This produces an error when compiled with -default-isolation MainActor: error: nonisolated deinitializer 'deinit' has different actor isolatio…

[Next page](https://forums.swift.org/c/swift-users/15.md?page=1)
