# \#uikit

**URL:** https://forums.swift.org/tag/uikit/109.md

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

---

## [Dismissing to one of the previous ViewControllers and passing a value](https://forums.swift.org/t/dismissing-to-one-of-the-previous-viewcontrollers-and-passing-a-value/88144)

<div class="topic-metadata">

**Author:** [@Neph](https://forums.swift.org/u/Neph)\
**Replies:** 15\
**Last updated:** [July 17, 2026, 6:14pm UTC](https://forums.swift.org/t/dismissing-to-one-of-the-previous-viewcontrollers-and-passing-a-value/88144 "2026-07-17T18:14:25Z")

</div>

I've got the following setup: VC1 -\> VC2 -\> VC3 VC1 has a button that, when clicked, does a couple of things, then presents VC2. VC2 has a similar button and presents VC3. VC3 has a text field and a button. When the …

---

## [Swift 6 strict concurrency + UIKit DiffableDataSource: Main actor-isolated conformance ... cannot satisfy Sendable type parameter](https://forums.swift.org/t/swift-6-strict-concurrency-uikit-diffabledatasource-main-actor-isolated-conformance-cannot-satisfy-sendable-type-parameter/86272)

<div class="topic-metadata">

**Author:** [@BoseSj](https://forums.swift.org/u/BoseSj)\
**Replies:** 5\
**Last updated:** [April 27, 2026, 10:19am UTC](https://forums.swift.org/t/swift-6-strict-concurrency-uikit-diffabledatasource-main-actor-isolated-conformance-cannot-satisfy-sendable-type-parameter/86272 "2026-04-27T10:19:35Z")

</div>

Hi all, I’m hitting what looks like a strict-concurrency isolation issue when using UITable​View​Diffable​Data​Source in a UIKit app under Swift 6 mode. I can work around it, but I want to confirm the correct model and…

---

## [UITableViewDiffableDataSource cannot use struct when Default Actor isolation=Main Actor](https://forums.swift.org/t/uitableviewdiffabledatasource-cannot-use-struct-when-default-actor-isolation-main-actor/84359)

<div class="topic-metadata">

**Author:** [@xdkhan](https://forums.swift.org/u/xdkhan)\
**Replies:** 2\
**Last updated:** [January 26, 2026, 10:21am UTC](https://forums.swift.org/t/uitableviewdiffabledatasource-cannot-use-struct-when-default-actor-isolation-main-actor/84359 "2026-01-26T10:21:59Z")

</div>

import UIKit struct Song: Hashable, Sendable { let id: UUID let name: String } enum Section: String, Hashable, Sendable { case main } class ListViewController: UIViewController { var dataSource: UITabl…

---

## ["Attribute can only be applied to types, not declarations" error](https://forums.swift.org/t/attribute-can-only-be-applied-to-types-not-declarations-error/82769)

<div class="topic-metadata">

**Author:** [@itx-alihamza](https://forums.swift.org/u/itx-alihamza)\
**Replies:** 4\
**Last updated:** [October 21, 2025, 9:20am UTC](https://forums.swift.org/t/attribute-can-only-be-applied-to-types-not-declarations-error/82769 "2025-10-21T09:20:14Z")

</div>

I am gettting this error Attrubute can only be applied to types not declarations even though my ReminderRow is of enum type. import UIKit @unchecked enum ReminderRow : Hashable, Sendable { case date case…

---

## [Unexpected UIApplication behavior under Swift Concurrency](https://forums.swift.org/t/unexpected-uiapplication-behavior-under-swift-concurrency/82160)

<div class="topic-metadata">

**Author:** [@TimofeiKarpovR](https://forums.swift.org/u/TimofeiKarpovR)\
**Replies:** 10\
**Last updated:** [September 17, 2025, 6:26pm UTC](https://forums.swift.org/t/unexpected-uiapplication-behavior-under-swift-concurrency/82160 "2025-09-17T18:26:07Z")

</div>

Hello, Calling UIApplication from a non-main-actor context triggers Main Thread Checker at runtime. Code sample: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() …

---

## [Injecting Declarative Genes into UIKit - DSL Construction Practices Based on @resultBuilder](https://forums.swift.org/t/injecting-declarative-genes-into-uikit-dsl-construction-practices-based-on-resultbuilder/80231)

<div class="topic-metadata">

**Author:** [@ymhtgrv](https://forums.swift.org/u/ymhtgrv)\
**Replies:** 0\
**Last updated:** [May 31, 2025, 3:40pm UTC](https://forums.swift.org/t/injecting-declarative-genes-into-uikit-dsl-construction-practices-based-on-resultbuilder/80231 "2025-05-31T15:40:32Z")

</div>

Declarative Revolution for UIKit: Applying @resultBuilder in UIStackView - SwiftlyUI The @resultBuilder feature introduced in iOS 13 opened a ​​new paradigm of metaprogramming​​ for Swift. Its greatest value lies in enab…

---

## [UIInspector - Runtime UI Debugging Tool for iOS](https://forums.swift.org/t/uiinspector-runtime-ui-debugging-tool-for-ios/80109)

<div class="topic-metadata">

**Author:** [@dankinsoid](https://forums.swift.org/u/dankinsoid)\
**Replies:** 0\
**Last updated:** [May 24, 2025, 10:35pm UTC](https://forums.swift.org/t/uiinspector-runtime-ui-debugging-tool-for-ios/80109 "2025-05-24T22:35:41Z")

</div>

I'm glad to share UIInspector, a debugging tool It's designed as a lightweight alternative to Xcode's built-in inspector tools. What is UIInspector? UIInspector is a runtime debugging tool that overlays directly on top …

---

## [What is the correct way to call UIApplication.shared.beginBackgroundTask no on the main thread?](https://forums.swift.org/t/what-is-the-correct-way-to-call-uiapplication-shared-beginbackgroundtask-no-on-the-main-thread/75196)

<div class="topic-metadata">

**Author:** [@nomnom](https://forums.swift.org/u/nomnom)\
**Replies:** 5\
**Last updated:** [October 11, 2024, 3:52pm UTC](https://forums.swift.org/t/what-is-the-correct-way-to-call-uiapplication-shared-beginbackgroundtask-no-on-the-main-thread/75196 "2024-10-11T15:52:51Z")

</div>

This is my newbie implementation for beginBackgroundTask @MainActor class BackgroundTaskManager { var backgroundTaskID: UIBackgroundTaskIdentifier = .invalid func startBackgroundTask() { backgroundTas…

---

## [InjectPreview Macro for InjectionIII](https://forums.swift.org/t/injectpreview-macro-for-injectioniii/75004)

<div class="topic-metadata">

**Author:** [@dankinsoid](https://forums.swift.org/u/dankinsoid)\
**Replies:** 0\
**Last updated:** [September 28, 2024, 6:14pm UTC](https://forums.swift.org/t/injectpreview-macro-for-injectioniii/75004 "2024-09-28T18:14:03Z")

</div>

InjectPreview Macro for InjectionIII I've created a small package with custom Swift macros that integrate with the InjectionIII tool, allowing live previews of SwiftUI views, UIViews, and UIViewControllers during runtime…

---

## [Swift package: Colors](https://forums.swift.org/t/swift-package-colors/74824)

<div class="topic-metadata">

**Author:** [@0xWDG](https://forums.swift.org/u/0xWDG)\
**Replies:** 0\
**Last updated:** [September 21, 2024, 9:18am UTC](https://forums.swift.org/t/swift-package-colors/74824 "2024-09-21T09:18:33Z")

</div>

If you are developing for multiple Apple patforms, you may have noticed that when it comes to Colors, there are some differences between the different platforms. For example, the UIColor class is used in iOS, NSColor in…

---

## [How to save complex model with UIImages?](https://forums.swift.org/t/how-to-save-complex-model-with-uiimages/73730)

<div class="topic-metadata">

**Author:** [@mirovinden](https://forums.swift.org/u/mirovinden)\
**Replies:** 0\
**Last updated:** [August 6, 2024, 1:08pm UTC](https://forums.swift.org/t/how-to-save-complex-model-with-uiimages/73730 "2024-08-06T13:08:03Z")

</div>

I’m working on an iOS project where I have a complex model containing several nested submodels. Here’s a simplified version of my model: struct CollageConfiguration { var gridConfig: GridConfiguration var backgr…

---

## [Is it possible to use new Observation Framework with UIKit?](https://forums.swift.org/t/is-it-possible-to-use-new-observation-framework-with-uikit/65780)

<div class="topic-metadata">

**Author:** [@ibrahimcetin](https://forums.swift.org/u/ibrahimcetin)\
**Replies:** 5\
**Last updated:** [July 27, 2024, 9:38am UTC](https://forums.swift.org/t/is-it-possible-to-use-new-observation-framework-with-uikit/65780 "2024-07-27T09:38:59Z")

</div>

Apple released their new Observation Framework in WWDC23 and they use it with SwiftUI. I've seen lots of resources about how to use it with SwiftUI but I cannot find anything how can I use it with UIKit. So, I am curious…

---

## [New developer, need help displaying on screen](https://forums.swift.org/t/new-developer-need-help-displaying-on-screen/73085)

<div class="topic-metadata">

**Author:** [@wilsoc31](https://forums.swift.org/u/wilsoc31)\
**Replies:** 4\
**Last updated:** [July 11, 2024, 3:15pm UTC](https://forums.swift.org/t/new-developer-need-help-displaying-on-screen/73085 "2024-07-11T15:15:01Z")

</div>

brand new newbie developer to xcode. so im doing an api call and getting back data from a mysql database. in the xcode preview window im getting data, but i cant figure out how to tie it to the screen when going into the…

---

## [How to program (and teach programming) using value semantics](https://forums.swift.org/t/how-to-program-and-teach-programming-using-value-semantics/53566)

<div class="topic-metadata">

**Author:** [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Replies:** 14\
**Last updated:** [June 29, 2024, 6:29am UTC](https://forums.swift.org/t/how-to-program-and-teach-programming-using-value-semantics/53566 "2024-06-29T06:29:51Z")

</div>

Starting a new thread to continue a discussion started here: Introducing Swift in higher education It's API-decoupled through use of a name; you can always change the typealias definition later. Of course if you need …

---

## [Do I need to explicitly annotate UIViewController subclasses' instance methods with @MainActor?](https://forums.swift.org/t/do-i-need-to-explicitly-annotate-uiviewcontroller-subclasses-instance-methods-with-mainactor/72614)

<div class="topic-metadata">

**Author:** [@HoustonDuane](https://forums.swift.org/u/HoustonDuane)\
**Replies:** 2\
**Last updated:** [June 20, 2024, 5:05am UTC](https://forums.swift.org/t/do-i-need-to-explicitly-annotate-uiviewcontroller-subclasses-instance-methods-with-mainactor/72614 "2024-06-20T05:05:11Z")

</div>

Hi all, I'm trying to adopt async-await into my existing UIKit codebase (I finally could just elevate the deployment target to iOS 13 thanks to Xcode 16, so there is barely any SwiftUI code in my codebase), but unfortuna…

---

## [Is it incorrect to use Array.forEach with strict concurrency?](https://forums.swift.org/t/is-it-incorrect-to-use-array-foreach-with-strict-concurrency/72520)

<div class="topic-metadata">

**Author:** [@ddenis](https://forums.swift.org/u/ddenis)\
**Replies:** 10\
**Last updated:** [June 17, 2024, 9:21pm UTC](https://forums.swift.org/t/is-it-incorrect-to-use-array-foreach-with-strict-concurrency/72520 "2024-06-17T21:21:55Z")

</div>

In my UIKit code I have this pattern of using forEach function to add subviews e.g. \[ view1, view2 \].forEach(stackView.addArrangedSubviews) However now with Strict Concurrency enabled I get a warning Converting f…

---

## [I made a little SwiftPM Package that uses UIKit. How can I run tests from command line](https://forums.swift.org/t/i-made-a-little-swiftpm-package-that-uses-uikit-how-can-i-run-tests-from-command-line/50399)

<div class="topic-metadata">

**Author:** [@nacho4d](https://forums.swift.org/u/nacho4d)\
**Replies:** 5\
**Last updated:** [February 15, 2024, 3:52am UTC](https://forums.swift.org/t/i-made-a-little-swiftpm-package-that-uses-uikit-how-can-i-run-tests-from-command-line/50399 "2024-02-15T03:52:59Z")

</div>

Hello swift community I am trying to decompose my big iOS app into small packages. In the process of it, I found some problems when trying to test SPM with iOS specific (UIKit) stuff in it. I have made one small SPM Pa…

---

## [Building with older Xcode version](https://forums.swift.org/t/building-with-older-xcode-version/69298)

<div class="topic-metadata">

**Author:** [@pyretttt](https://forums.swift.org/u/pyretttt)\
**Replies:** 4\
**Last updated:** [January 8, 2024, 9:07am UTC](https://forums.swift.org/t/building-with-older-xcode-version/69298 "2024-01-08T09:07:11Z")

</div>

Hi there. I've just recalled time when Xcode 13 was released and latter version of UIKit contained a bug with UINavigationBar API. I was expecting that bug will be noticed as soon newer iOS will be released. As UIKit li…

---

## [Use of UIKit in unit testing performance affected?](https://forums.swift.org/t/use-of-uikit-in-unit-testing-performance-affected/68988)

<div class="topic-metadata">

**Author:** [@chrome09](https://forums.swift.org/u/chrome09)\
**Replies:** 0\
**Last updated:** [December 14, 2023, 10:43am UTC](https://forums.swift.org/t/use-of-uikit-in-unit-testing-performance-affected/68988 "2023-12-14T10:43:21Z")

</div>

In general, is there any performance penalty induced, if one were to import UIKit in unit testing target in an iOS project? I have no objective way to say if this is true or false. I would assume that potentially this co…

---

## [Can I not contribute to UIColor?](https://forums.swift.org/t/can-i-not-contribute-to-uicolor/68449)

<div class="topic-metadata">

**Author:** [@Kobe24](https://forums.swift.org/u/Kobe24)\
**Replies:** 4\
**Last updated:** [November 18, 2023, 3:24am UTC](https://forums.swift.org/t/can-i-not-contribute-to-uicolor/68449 "2023-11-18T03:24:46Z")

</div>

Hello, I am a student studying iOS development in Korea. I am curious whether it's not possible to contribute to UIColor, so I'm leaving this question. I wanted to contribute to Swift and thought of a way to contribute…

---

## [\[Pitch\] UIColor initialization using HEX value and Alpha value](https://forums.swift.org/t/pitch-uicolor-initialization-using-hex-value-and-alpha-value/68467)

<div class="topic-metadata">

**Author:** [@Kobe24](https://forums.swift.org/u/Kobe24)\
**Replies:** 6\
**Last updated:** [November 15, 2023, 3:19am UTC](https://forums.swift.org/t/pitch-uicolor-initialization-using-hex-value-and-alpha-value/68467 "2023-11-15T03:19:40Z")

</div>

UIColor initialization using HEX value and Alpha value. Authors: Kobe Introduction In this proposal, we introduce an initializer for UIColor that includes Hex values and alpha values, allowing for easy conversion of a …

---

## [Announcing Atoms - A new state management library](https://forums.swift.org/t/announcing-atoms-a-new-state-management-library/64702)

<div class="topic-metadata">

**Author:** [@johanthorell](https://forums.swift.org/u/johanthorell)\
**Replies:** 3\
**Last updated:** [May 1, 2023, 2:04pm UTC](https://forums.swift.org/t/announcing-atoms-a-new-state-management-library/64702 "2023-05-01T14:04:53Z")

</div>

Hello everyone! I’m really excited to share some new open source I’ve been working for a while. Atoms is a state management library created specifically for use with SwiftUI. Its inspiration comes from Jotai, a popular…

---

## [Creating UITableView with parent-child cells (Tree Structure)](https://forums.swift.org/t/creating-uitableview-with-parent-child-cells-tree-structure/64672)

<div class="topic-metadata">

**Author:** [@ganaraj-savant](https://forums.swift.org/u/ganaraj-savant)\
**Replies:** 5\
**Last updated:** [April 29, 2023, 3:32pm UTC](https://forums.swift.org/t/creating-uitableview-with-parent-child-cells-tree-structure/64672 "2023-04-29T15:32:40Z")

</div>

Hi, I'm trying to implement a custom tableview which when tapped on a cell should expand and display its child cells, which further might have their children. Tapping again on the cell should collapse the view. My data …

---

## [UIKit init error?](https://forums.swift.org/t/uikit-init-error/63543)

<div class="topic-metadata">

**Author:** [@yan1](https://forums.swift.org/u/yan1)\
**Replies:** 2\
**Last updated:** [March 6, 2023, 3:44pm UTC](https://forums.swift.org/t/uikit-init-error/63543 "2023-03-06T15:44:13Z")

</div>

When i run the main app, print 0 ????? The child init failed. It passed build. i create a Module 1 framework, the main app use it. Something wrong. Module 1: import UIKit public protocol Initializable { init()…

---

## [SE-0383: Deprecate \`@UIApplicationMain\` and \`@NSApplicationMain\`](https://forums.swift.org/t/se-0383-deprecate-uiapplicationmain-and-nsapplicationmain/62375)

<div class="topic-metadata">

**Author:** [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Replies:** 11\
**Last updated:** [January 18, 2023, 11:19pm UTC](https://forums.swift.org/t/se-0383-deprecate-uiapplicationmain-and-nsapplicationmain/62375 "2023-01-18T23:19:57Z")

</div>

Hello, Swift community! The review of SE-0383: Deprecate @UIApplicationMain and @NSApplicationMain begins now and runs through January 16th, 2023. Reviews are an important part of the Swift evolution process. All revie…

---

## [\[Accepted\] SE-0383: Deprecate \`@UIApplicationMain\` and \`@NSApplicationMain\`](https://forums.swift.org/t/accepted-se-0383-deprecate-uiapplicationmain-and-nsapplicationmain/62645)

<div class="topic-metadata">

**Author:** [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Replies:** 0\
**Last updated:** [January 18, 2023, 11:19pm UTC](https://forums.swift.org/t/accepted-se-0383-deprecate-uiapplicationmain-and-nsapplicationmain/62645 "2023-01-18T23:19:34Z")

</div>

Hello, Swift community. The review of SE-0383 ran from January 3rd through January 16th, 2023. Feedback in the review was light but strongly positive, and the Language Workgroup agrees with the community that this is a…

---

## [I have problem when I want show alert error message inside in other alert action](https://forums.swift.org/t/i-have-problem-when-i-want-show-alert-error-message-inside-in-other-alert-action/61470)

<div class="topic-metadata">

**Author:** [@NikiBer](https://forums.swift.org/u/NikiBer)\
**Replies:** 1\
**Last updated:** [November 16, 2022, 2:54pm UTC](https://forums.swift.org/t/i-have-problem-when-i-want-show-alert-error-message-inside-in-other-alert-action/61470 "2022-11-16T14:54:04Z")

</div>

I'm trying show error message and success after make delete request but the app crashed when call another method with error message. @IBAction func deleteAccountAction(\_ sender: Any) { let userID = prefs.value(f…

---

## [UIApplication.shared is undefined during app launch, but it works!](https://forums.swift.org/t/uiapplication-shared-is-undefined-during-app-launch-but-it-works/60859)

<div class="topic-metadata">

**Author:** [@hmlongco](https://forums.swift.org/u/hmlongco)\
**Replies:** 9\
**Last updated:** [October 14, 2022, 7:16pm UTC](https://forums.swift.org/t/uiapplication-shared-is-undefined-during-app-launch-but-it-works/60859 "2022-10-14T19:16:25Z")

</div>

So do the following. We're only concerned about the init statement here, body is standard and unimportant. @main struct SomeApp: App { init() { print(UIApplication.shared) // Crash = EXC\_BAD\_ACCESS (code=1, …

---

## [How to display an image on a navigation right bar button](https://forums.swift.org/t/how-to-display-an-image-on-a-navigation-right-bar-button/59917)

<div class="topic-metadata">

**Author:** [@jp1995](https://forums.swift.org/u/jp1995)\
**Replies:** 0\
**Last updated:** [August 26, 2022, 8:02pm UTC](https://forums.swift.org/t/how-to-display-an-image-on-a-navigation-right-bar-button/59917 "2022-08-26T20:02:23Z")

</div>

I am trying to display a printer icon next to the share button; the print button works but it doesn't show the image.It's invisible How do I fix this ? It's built using code.

---

## [How to get a pixel precise image from CGPoints?](https://forums.swift.org/t/how-to-get-a-pixel-precise-image-from-cgpoints/59156)

<div class="topic-metadata">

**Author:** [@Mahmoud-Aziz](https://forums.swift.org/u/Mahmoud-Aziz)\
**Replies:** 5\
**Last updated:** [July 23, 2022, 9:13pm UTC](https://forums.swift.org/t/how-to-get-a-pixel-precise-image-from-cgpoints/59156 "2022-07-23T21:13:07Z")

</div>

I'm trying to make some kind of pencil signature view in my app, I did it with the help of this func: func drawLine(from fromPoint: CGPoint, to toPoint: CGPoint) { UIGraphicsBeginImageContext(canvasImageVie…

[Next page](https://forums.swift.org/tag/uikit/109.md?match_all_tags=true&page=1&tags%5B%5D=uikit)
