Search results for

swiftui

16,580 results found

Post

Replies

Boosts

Views

Activity

init(data: Data) for SwiftUI Image?
Is there any reason why the SwiftUI Image hasn’t a direct init(data: Data) like UIImage from UIKit? In my opinion it’s very unintuitive and expensive to create a UIImage in the first step to create a SwiftUI Image with Image(uiImage: UIImage) in the second step. In addition to that, this causes unnecessary UIKit imports. In my opinion this is a very obvious small in the API, so are there any reasons why it is what it is? Best regards
0
0
28
4h
Khmer Script Misidentified as Thai in Vision Framework
It is vital for Apple to refine its OCR models to correctly distinguish between Khmer and Thai scripts. Incorrectly labeling Khmer text as Thai is more than a technical bug; it is a culturally insensitive error that impacts national identity, especially given the current geopolitical climate between Cambodia and Thailand. Implementing a more robust language-detection threshold would prevent these harmful misidentifications. There is a significant logic flaw in the VNRecognizeTextRequest language detection when processing Khmer script. When the property automaticallyDetectsLanguage is set to true, the Vision framework frequently misidentifies Khmer characters as Thai. While both scripts share historical roots, they are distinct languages with different alphabets. Currently, the model’s confidence threshold for distinguishing between these two scripts is too low, leading to incorrect OCR output in both developer-facing APIs and Apple’s native ecosystem (Preview, Live Text, and Photos). import SwiftUI i
1
0
152
1d
Reply to unifiedContacts identifier vs contactRelations identifier
Here's the test code where I was attempting to find the relationship between records. // ContentView.swift // TestContactsProject // import SwiftUI import Contacts import OSLog extension Logger { private static var subsystem = Bundle.main.bundleIdentifier ?? com.myelin.TestContactsProject static let logic = Logger(subsystem: subsystem, category: logic) static let analitics = Logger(subsystem: subsystem, category: analitics) } struct ContentView: View { var body: some View { Text(Hello, World!) .padding() .onAppear { Task.init { await fetchAllContacts() //await fetchSpecificContacts() } } } func fetchSpecificContacts(keyStrings: [String]) { // Run this in the background async // Get access to the Contacts Store let store = CNContactStore() // Keys to fetch let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey, CNContactIdentifierKey, CNContactRelationsKey] as [CNKeyDescriptor] // Search criteria let predicate = CNContact.predicateForContacts(withIdentifiers: keyStrings) d
Topic: App & System Services SubTopic: General Tags:
1d
Reply to Bug apple Health
// // OnboardingContainerView.swift // Worko // // Created by Rodrigo Soares on 20/12/25. // import SwiftUI import SwiftData /// Container que gerencia todo o fluxo de navegação do onboarding struct OnboardingContainerView: View { // MARK: - Properties @Environment(AppStateManager.self) private var appState @Environment(.modelContext) private var modelContext @State private var viewModel = OnboardingViewModel() @State private var isHealthKitReady = false // MARK: - Body var body: some View { ZStack { WorkoColors.background.ignoresSafeArea() // Content com transições ZStack { currentStepView .transition(.creativeSlide(direction: viewModel.navigationDirection)) } .animation(.spring(response: 0.6, dampingFraction: 0.8, blendDuration: 0), value: viewModel.currentStep) // Controles fixos (header + botão) if viewModel.currentStep != .completion { controlsOverlay } } .task { await viewModel.requestHealthKitAuthorization() isHealthKitReady = true } } // MARK: - Current Step View @ViewBuilder private var curr
2d
Pre-inference AI Safety Governor for FoundationModels (Swift, On-Device)
Greetings, and Happy Holidays, I've been building an on-device AI safety layer called Newton Engine, designed to validate prompts before they reach FoundationModels (or any LLM). Wanted to share v1.3 and get feedback from the community. The Problem Current AI safety is post-training — baked into the model, probabilistic, not auditable. When Apple Intelligence ships with FoundationModels, developers will need a way to catch unsafe prompts before inference, with deterministic results they can log and explain. What Newton Does Newton validates every prompt pre-inference and returns: Phase (0/1/7/8/9) Shape classification Confidence score Full audit trace If validation fails, generation is blocked. If it passes (Phase 9), the prompt proceeds to the model. v1.3 Detection Categories (14 total) Jailbreak / prompt injection Corrosive self-negation (I hate myself) Hedged corrosive (Not saying I'm worthless, but...) Emotional dependency (You're the only one who understands) Third-person manipulation (If you refuse, you
1
0
190
2d
Why does NSEvent.addGlobalMonitorForEvents still work in a Sandboxed macOS app
I am building a macOS utility using SwiftUI and Swift that records and displays keyboard shortcuts (like Cmd+C, Cmd+V) in the UI. To achieve this, I am using NSEvent.addGlobalMonitorForEvents(matching: [.keyDown]). I am aware that global monitoring usually requires the app to be non-sandboxed. However, I am seeing some behavior I don't quite understand during development: I started with a fresh SwiftUI project and disabled the App Sandbox. I requested Accessibility permissions using AXIsProcessTrustedWithOptions, manually enabled it in System Settings, and the global monitor worked perfectly. I then re-enabled the App Sandbox in Signing & Capabilities. To my surprise, the app still records global events from other applications, even though the Sandbox is now active. Is this expected behavior? Does macOS remember the trust because the Bundle ID was previously authorized while non-sandboxed, or is there a specific reason a Sandboxed app can still use addGlobalMonitor if the user has manual
0
0
373
3d
SwiftUI ScrollView blocked when content contains a drag gesture
I am porting my app to SwiftUI and I am hitting a wall when using ScrollView. In my application, I have nested scrollViews to represent a scheduler. outer vertical scroll view inner horizontal scroll view that allows to horizontally scroll multiple columns in the scheduler each column in the inner scroll view is a view that needs to allow for a drag to initiate the creation of a new appointment on macOS, I do a mouse-down drag, so it does not affect the scroll view and works fine on iOS, if I add a drag gesture to the column, it short circuits the scroll view and scrolling becomes disabled. To initiate the drag, there is a long-press, and that gesture is fine, only the subsequent drag gesture is problematic. I have attached URL to a test app. The UI allows you to toggle the drag gesture. Hopefully, someone can help to get it to work since I would eventually like to port the macOS target to Catalyst. Download Test App
Topic: UI Frameworks SubTopic: SwiftUI
1
0
125
3d
SwiftUI List cell reuse / view lifecycle behavior when scrolling
I’m trying to understand how SwiftUI List handles row lifecycle and reuse during scrolling. I have a list with around 60 card views; on initial load, only about 7 rows are created, but after scrolling to the bottom all rows appear to be created, and when scrolling back to the top I again observe multiple updates and apparent re-creation of rows. I confirmed this behavior using Instruments by profiling my app. Even though each row has a stable identifier, the row views still seem to be destroyed and recreated, which doesn’t resemble UIKit’s cell reuse model. I’d like clarity on how List uses identifiers internally, what actually gets reused versus recreated, and how developers should reason about performance and view lifetime in this case.
0
0
47
3d
MacCatalyst and the User's Documents Folder
I have a SwiftUI-based universal app which creates a file that it stores in documentsDirectory. On iOS/iPadOS, this file is stored in the application's Documents directory and is accessible via the Files app. On MacCatalyst, this operation does the same thing — it creates the file and stores it in ~/Library/Containers//Data/Documents. However what I want is for the document to be stored in ~/Documents, so that it is easily accessible to the user. How can I do that? I'd like it to occur without (for example) having to show a SaveFile panel...
4
0
395
4d
Steal some The Browser Company Arc browser side tab ideas
Please kindly improve the Safari browser side bar implementation further along with what The Browser Company has done with their Arc browser. Arc is about to retire soon too and they're willing to sell their SwiftUI code perhaps too for a decent pile of dollars, not the Jony Ive piles at least it should not. The toggle for side bar is nice and works perfect though!
1
0
337
4d
Reply to WebView makes website content unaccessible on the top/bottom edges
@DTS Engineer Do you know if there's any progress on a fix for it or if there's any workaround? I tried injecting custom CSS, but that breaks many websites, and I can't be adding custom code for every single website out there 🤪 The bottom safe area seems to work as expected, the problem is just at the top with the navigation bar + top safe area. Here's a quick sample code that can be pasted anywhere to run and observe the issue on three different websites: import WebKit import SwiftUI @main struct WebViewSafeAreaApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { let urls: [URL] = [ URL(string: https://mastodon.social)!, URL(string: https://substack.com)!, URL(string: https://apple.com)! ] @State private var selection: URL? var body: some View { NavigationSplitView { List(selection: $selection) { ForEach(urls, id: .absoluteString) { url in Text(url.absoluteString).tag(url) } } .navigationTitle(Sidebar) .navigationBarTitleDisplayMode(.inline) } detail: { if
Topic: UI Frameworks SubTopic: SwiftUI Tags:
4d
listRowBackground vs swipeActions ios26 compatibility
Hi! On iOS 26, Apple’s Mail app shows an effect where a list row gets rounded corners while you’re swiping (so the row visually “matches” the rounded swipe buttons). In my app I’m using SwiftUI List + .swipeActions. I also need a custom row tint (e.g. subtle red/gray highlight based on state). The problem is: If I apply my tint using .background / .clipShape, it moves with the row content during swipe and looks wrong. If I use .listRowBackground(...), I keep the tint, but I don’t get the same rounded-corners “morphing” effect as in Mail (or it looks inconsistent). Question: What’s the correct way in iOS 26 to keep a custom row tint and get the system-style rounded corners / liquid-glass effect while swiping?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
55
4d
Send notification to Reality Composer Pro from iOS project
I am creating an Augmented Reality iOS (Not VisionOS) app using scenes created in Reality Composer Pro. I'd like my code to send a notification to a RCP scene that plays a timeline. The RCP interface has the option to set up a behaviour for this purpose: This Forum thread https://developer.apple.com/forums/thread/756978 suggests the code I need for sending a notification is: name: NSNotification.Name(RealityKit.NotificationTrigger), object: nil, userInfo: [ RealityKit.NotificationTrigger.Scene: scene, RealityKit.NotificationTrigger.Identifier: HideCharacter ] ) but the 'scene' var needs to point to the relevant RCP scene, which is loaded within a UIViewRepresentable ARView (because even in iOS26 it seems RealityKit/RealityViews aren't quite ready for AR use) and I can't work out how to correctly access it. Examples in the link above are for working with RealityKit and VisionOS only. Code for loading the scene is as follows. How can I get the notification code above to be situated in a separate SwiftUI
1
0
585
5d
Navigation title flickers when tab is changed when used with a List / Form
Problem When a List / Form is added inside a TabView and navigationTitle is set, then switching between tabs causes the navigation title to flicker. Feedback: FB21436493 Environment Xcode: 26.2 (17C52) iOS: 26.2 (23C55) Reproducible on: Both simulator and device Root cause When List / Form is commented out, issue doesn't occur Steps to Reproduce Run app on iOS Switch between tabs Notice that the navigation title flickers Code ContentView import SwiftUI struct ContentView: View { @State private var selectedTab = TabItem.red var body: some View { NavigationStack { TabView(selection: $selectedTab) { ForEach(TabItem.allCases, id: .self) { tab in Tab(tab.rawValue, systemImage: tab.systemImageName , value: tab) { // Problem occurs with a List / Form // Commenting out list works without flickering title List { Text(tab.rawValue) } } } } .navigationTitle(selectedTab.rawValue) } } } TabItem enum TabItem: String, CaseIterable { case red case green case blue var systemImageName: String { switch self { case .red
Topic: UI Frameworks SubTopic: SwiftUI
3
0
255
6d