Swift is a powerful and intuitive programming language for Apple platforms and beyond.

Posts under Swift tag

200 Posts

Post

Replies

Boosts

Views

Activity

Programming Languages Resources
This topic area is about the programming languages themselves, not about any specific API or tool. If you have an API question, go to the top level and look for a subtopic for that API. If you have a question about Apple developer tools, start in the Developer Tools & Services topic. For Swift questions: If your question is about the SwiftUI framework, start in UI Frameworks > SwiftUI. If your question is specific to the Swift Playground app, ask over in Developer Tools & Services > Swift Playground If you’re interested in the Swift open source effort — that includes the evolution of the language, the open source tools and libraries, and Swift on non-Apple platforms — check out Swift Forums If your question is about the Swift language, that’s on topic for Programming Languages > Swift, but you might have more luck asking it in Swift Forums > Using Swift. General: Forums topic: Programming Languages Swift: Forums subtopic: Programming Languages > Swift Forums tags: Swift Developer > Swift website Swift Programming Language website The Swift Programming Language documentation Swift Forums website, and specifically Swift Forums > Using Swift Swift Package Index website Concurrency Resources, which covers Swift concurrency How to think properly about binding memory Swift Forums thread Other: Forums subtopic: Programming Languages > Generic Forums tags: Objective-C Programming with Objective-C archived documentation Objective-C Runtime documentation Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com"
0
0
2.9k
Oct ’25
Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
Xcode tells me Previewing in executable targets now requires a new build layout for unoptimized builds. Either set ENABLE_DEBUG_DYLIB to YES for this target, or break out your preview code into a separate framework with its own scheme. How do enable that in Package.swift. swiftSettings don't work (.define and unsafeFlags with -D ...). Creating a library product that the executable then depends on doesn't help either. I have two targets, one is an executable target. The #Preview macro is in the non-executable target.
3
2
422
2h
SensorKit: didFetchResult not being called
Hello, I have an app for a research study that has been approved and authorized to use SensorKit. All my permissions, entitlements and authorizations are in order, but I still can't get any data. The didFetchResult is not being called even though didCompleteFetch is called. I have waited for over 24 hours, but it still returns no samples. Please, I would appreciate any help on this issue. Thank you func sensorReader( _ reader: SRSensorReader, fetchingRequest: SRFetchRequest, didFetchResult result: SRFetchResult<AnyObject> ) { receivedResultsInCurrentFetch = true print("✅ SensorKit fetch result received for: \(sensorKey)") AppLogger.shared.log("SensorKit fetch result received for \(sensorKey)") if let sample = result.sample as? T { print("✅ SensorKit sample matched expected type for \(sensorKey): \(T.self)") AppLogger.shared.log("SensorKit sample matched expected type for \(sensorKey): \(T.self)") processSample(sample) } else { print("❌ SensorKit sample did not match expected type for \(sensorKey): \(T.self)") AppLogger.shared.log("SensorKit sample did not match expected type for \(sensorKey): \(T.self)") } } func sensorReader(_ reader: SRSensorReader, didCompleteFetch request: SRFetchRequest) { if receivedResultsInCurrentFetch, let lastRequestedUpperBound { session.setSensorKitLastFetchTime(lastRequestedUpperBound, for: sensorKey) print("✅ SensorKit fetch completed with samples for \(sensorKey). Checkpoint updated.") } else { print("⚠️ SensorKit fetch completed for \(sensorKey) with no samples.") AppLogger.shared.log("SensorKit fetch completed for \(sensorKey) with no samples. Keeping previous checkpoint so delayed SensorKit data is not skipped.") } isFetchInFlight = false completePendingFetches(success: true) print("✅ SensorKit fetch completed for: \(sensorKey)") AppLogger.shared.log("Fetch request completed for sensor type: \(T.self)") }
1
0
134
3h
Xcode 27 beta 3 linker warning: points before section start and the target atom is ambiguous
I am testing an existing iOS app with Xcode 27 beta 3. The build succeeds, but I am seeing a new linker warning from Swift Package product targets. ld: warning: address=0xF496F points before section(28) start and the target atom is ambiguous Environment: Xcode 27.0 beta 3 Build version: 27A5218g Platform: iOS Simulator Configuration: Debug Project type: iOS app with Swift Package dependencies, also embedding a watchOS app Build command: DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer \ xcodebuild -project MyWeight/MyWeight.xcodeproj \ -scheme MyWeight \ -configuration Debug \ -destination "generic/platform=iOS Simulator" \ build The build succeeds: ** BUILD SUCCEEDED ** Warnings: MyWeight/MyWeightKit/Package.swift: MyWeightKit-watchOS-product: ld: warning: address=0xF493F points before section(28) start and the target atom is ambiguous MyWeight/MyWeightKit/Package.swift: MyWeightKit-iOS-product: ld: warning: address=0xF496F points before section(28) start and the target atom is ambiguous Both warnings appear during the link step for Swift Package product framework targets. Is this a known issue in Xcode 27 beta 3? Does it indicate a real issue in the produced simulator binary, or is it likely a linker/debug-info diagnostic?
0
0
17
16h
关于我使用Swift和Metal制作的神经网络引擎
我今年18岁。没有机器学习背景,没有上过大学,高中都没去上,没有导师。 几天前我盯着一张纸发呆。突然想:为什么计算机神经网络一定要是2D的?可以模拟生物吗?为什么一定要在平面上算?如果多个平面,岂不是翻倍?如果把六张纸想象成一个魔方,六个面各自承载神经元,八条体对角线变成新的通信通道会怎么样? 我真的很喜欢折腾这些,然后我立刻制定了详细计划,使用AI工具辅助写下了第一个 kernel。跑崩了。我又重新想了一下,和qq群友分享了我的目标,又写。又崩。连续几十次。没有 PyTorch,没有 TensorFlow,没有 CUDA。只有Swift和Metal。因为我的电脑显卡是AMD Vega 64,没装任何框架辅助,因为我想明白最底层的运行方式是什么原理。 这就是CubeNN。 ##以下为AI的详细解答,内容与架构改动太多,我在这里一次讲不清楚 它是什么 一个用魔方几何作为计算架构的神经网络引擎。 标准 Transformer: 把数据排成一行,O(n²) 地互相看 CubeNN: 把数据分布在 14 个面上,只在该看的地方看 6 个标准面 → 块稀疏注意力(粗看全局 + 细看局部) 8 个 X 面对角线 → 跨面信息桥(不做 Attention,只负责传递) 每轮:6 面算 → 投影到 8 X 面 → 上采样精炼 → 融合回 6 面 最关键的是 Cube Cascade——一个树+链级联推理: 树阶段: 1 个魔方 spawn 8 个 → 8 个 spawn 64 个 → 73 个并行探索 GPU 上同时跑,选最优路径 链阶段: 最优叶子无限深度精炼 3-5 步收敛,方差提升 ~7% 怎么实现的 纯 Swift + Metal。零依赖。零框架。 // 大致代码就是这些 import Metal import Foundation let device = MTLCreateSystemDefaultDevice()! let library = try! device.makeLibrary(filepath: "cube_nn.metallib") // ...12 个 GPU kernel,12,000 次 dispatch 关键技术决策: 单 Command Buffer:整个树阶段 73 个魔方的全部 kernel dispatch 打包进一个 CB,0 次 CPU-GPU 同步 Pipeline State 缓存:编码从 1022ms 降到 42ms Buffer 偏移:所有 73 个魔方的 14 个面存进一个连续 buffer,kernel 通过 buffer(15) 传偏移量 FP16:N≥64 时半精度提速 21% 性能 ##经过测试,但是因设备差异可能不准确,仅参考 AMD Radeon RX Vega 64 (2017 年显卡, 14nm, 295W): 规模 神经元 魔方数 耗时 N=32 6,144 73 (树) 435ms N=64 24,576 21 (树) 817ms N=128 98,304 1 116ms N=32 全连接 Attention 每层 201M FLOP → CubeNN 块稀疏 370K FLOP (544× 减少) N=128 全连接需要 32GB 显存(物理上不存在)→ CubeNN 用 192KB N=256 全连接需要 2.2T FLOP → CubeNN 52M FLOP (42,300× 减少) 代码体积:161KB。 对比 PyTorch 的 800MB。 我经历了什么 这个项目最困难的不是写 kernel,是在没有任何人告诉我"能不能做"的情况下,靠反复试错找到路。 第一次试图跑 73 个魔方,GPU 直接 hang 了。花了 3 天定位到是 Command Buffer 堆叠过多。 改了 single encoder 方案,又碰上 SIGILL——Metal 不允许 makeBuffer(length: 0),B=0 时创建了零长度 buffer。 想用 threadgroup memory 做 kernel fusion,结果跨 threadgroup 读不到数据,才明白 LDS 是 per-group 的。 N=64 的 FP16 要手动写 float↔half 转换函数,因为 macOS 11 上 Float16 类型被标为 unavailable。 每一次崩溃都教会我一个 Metal 的底层细节。没有人教我,但 Metal 的报错信息就是最好的老师。 为什么发在 Apple 开发者论坛 因为这是为苹果生态而生的项目。CubeNN 从头到尾只用了两个东西:Swift 和 Metal。它不需要移植就能跑在任何 Apple Silicon Mac 上(API兼容)。如果未来能把部分 kernel 映射到 Neural Engine,效率会再翻几倍。 我想问 Apple 的 Metal 工程师和 Core ML 团队: ** 有没有更好的 GPU 任务调度方式?**目前表现仍然欠佳(对于我这个完美主义者来说),可能改得有点乱了 有没有兴趣评估这个架构在 M4 上的表现? 我手里只有 Vega 64。M4 GPU + ANE方法 跑 CubeNN 会是什么效果? 源代码 ├── run.swift # 统一 CLI,参数化 N/B/depth ├── src/ │ ├── cube_nn.metal # FP16 kernel │ └── cube_nn_fp32.metal # FP32 kernel └── benchmarks/ # 实测数据 如果你读到了这里——谢谢你。一个门外汉靠痴狂的,纯粹到几乎是妄想的主意和Metal走到了这里。我懂的不是很多,如果这个架构有任何价值,我想让它变得更好。任何建议、批评、或者指教,都非常欢迎。
1
0
233
22h
Task alive duration when device is locked
Hello everybody. I have a Swift Task which calls 2(minimum) to 3 (maximum) REST calls sequentially upon specific cases. They are not long run processes like files. I am wondering what is the alive duration of a Task if the device is locked. I noticed that sometimes it is executed in the background properly, some others is paused and resumed when the device is unlocked again and sometime we got timeout (in more than 10 minutes). Is any official time limit documented where the iOS system suspends a Task?
1
0
105
1d
Issue with Auto-Blur Effect of NSScrollViews under NSToolbar, Ref: WWDC25
Hello, I'm building an app that is designed to largely mimick Apple's own audio auto-switch behavior when switching between different audio output devices like MacBook Pro speakers and AirPods. The purpose is to "lend a hand" to certain apps, like CrossOver (wine) ran x68-64 apps that don't seem to respond well to CoreAudio changing the audio output after the x68-64 program has already init its audio after startup. Thus, I don't actually need much of a GUI except for a few specific features, and perhaps later some ehancements I'd like to add that can make use of a proper GUI. I've decided to implement the MacOS Tahoe Apple Liquid Glass UI to keep the user experience as streamlined and intuitive as possible. I've largely been successful: The GitHub page goes into greater detail showing the greater context of the AppKit API's I'm using to achieve this UI design. There is just one issue I haven't been able to solve, how to get the sidebar tab(s) to blur when scrolled underneath the Window Controls (Traffic Light) buttons. These tabs are part of a NSScrollView underneath the NSToolbar aligned from the top-most left and right window edges, but split from the right-hand content side via NSSplitViewController > NSSplitViewItem (again exact topology is at the page "link" below). On the content side (right side), I used NSSplitViewItemAccessoryViewController to create the blur zone so that when its own NSScrollView content is scrolled upwards, past the toolbar NSToolbar, it would apply a progressive tint+blur effect, just as Apple has implemented in their own apps. This wasn't really automatic since I did have to elect to use it as part of a MacOS 26.1+ specific class (NSScrollEdgeEffectStyle), but it's working on the content side nonetheless: Now I am trying to get the same effect working on the sidebar side and am having issues with this. Please see the page below as it summarizes our test attempts with greater detail. I've only gotten this far by reading "obscure" comments in the SDK's so I'm really hoping this is just a ID10T error in that I've missed something. Note: even though I only have 3 tabs currently in the sidebar NSScrollView, I will eventually populate this further, especially with some user configurable stuff on my roadmap. That said, the sidebar is only "scrollable" right now because I've left the "vertical scroll elasticity" enabled, intentionally. (.verticalScrollElasticity [IS NOT] .none! Therefore, I can still "scroll" the enumerated tabs inside the sidebar's NSScrollView upward behind the Traffic Light buttons, to validate if the blur+tint effect is being rendered. I say all of that to ask if, perhaps, the reason that the blur+tint effect is not rendering in the Window could be because there's not enough content to render in the sidebar to produce a scrollbar, and simply leaving .verticalScrollElasticity "enabled" is not sufficient to produce this effect? I don't know that for sure, but it's the only thing I can think of at this point. Its not obvious to me though. This app is written entirely in Swift (v6.3.3) and will require a minimum of MacOS Tahoe 26.1.X due to the AppKit API's I'm using (namely NSScrollEdgeEffectStyle). GitHub Page documenting issue in greater detail (remove the spaces): HT TP S:// gitdev.brianbutts.me /sidebar-scroll-edge-blur. html
1
0
57
2d
Archived apps crash before main() after strip -S -T corrupts dyld chained fixups (FB23528109, Xcode 26.3-27.0b2)
We root-caused a launch crash that only affects ARCHIVED builds (Run/Debug works, simulator works) and filed it as FB23528109. Posting the details here because the crash signatures are hard to search for and other teams are likely to hit this as they adopt Swift 6.3 toolchains. SYMPTOM The archived app crashes before main() on device, on every launch. Depending on which orphaned pointer gets read first, the crash looks like one of these: EXC_BREAKPOINT, "pointer authentication trap DA", inside swift_conformsToProtocolMaybeInstantiateSuperclasses / _searchConformancesByMangledTypeName (often with a Firebase or other +load frame below it; that frame is just the first conformance scan at launch, not the cause) EXC_BAD_ACCESS KERN_INVALID_ADDRESS at a small, raw unslid address (e.g. 0xc118), inside dyld: resolveRebase <- objc_visitor::forEachClass <- dyld4::PrebuiltObjC::make Debug builds, simulator builds and Xcode Run builds are all fine, because the corruption happens in the Strip build phase, which only runs for Archive/install builds. ROOT CAUSE (two defects combine) strip -S -T (what Xcode runs on embedded frameworks during Archive when STRIP_SWIFT_SYMBOLS = YES) corrupts dyld chained fixups. When strip removes a Swift weak-definition symbol that has a GOT bind, it converts the bind into a rebase to the local definition (correct) but writes the converted entry with next = 0 (incorrect). That terminates the 16 KB page's fixup chain early, and every fixup after the converted slot in the same page is orphaned: dyld never processes it, so raw chain-encoding bytes get read as pointers at launch. The bug is present in every strip we tested: Xcode 26.3, 26.4, 26.4.1, 26.5, 26.6 and 27.0 beta 2. strip -S and strip -S -x (without -T) do not corrupt. Starting with Swift 6.3.0 (Xcode 26.4.0), the compiler emits the trigger pattern for ordinary code: cross-module references to a non-final class's stored-property accessors become weak-def-coalesce binds (Swift 6.2.4 emits none). So apps that embed a multi-module Swift dynamic framework (e.g. an SPM package built as one dynamic framework) started getting corrupted by their own default Archive pipeline when they moved past Xcode 26.3. HOW TO CHECK IF YOU ARE AFFECTED Compare the fixups of a framework binary inside your archive against a Run build of the same code: xcrun dyld_info -fixups YourApp.app/Frameworks/YourKit.framework/YourKit If fixups that exist in the Run build are missing after the archive's strip step (in particular __got slots and anything after them in the same 16 KB page), you are affected. Also: any GOT bind of a Swift ($s...) symbol in the pre-strip binary is a red flag. WORKAROUND Set STRIP_SWIFT_SYMBOLS = NO (optionally STRIP_STYLE = non-global, i.e. strip -S -x, which kept the size cost to about +4% for us). Important: if the affected framework is a Swift package product, these must be passed as xcodebuild command-line overrides (e.g. xcodebuild ... STRIP_SWIFT_SYMBOLS=NO STRIP_STYLE=non-global); xcconfig files do not apply to package targets. REPRO FB23528109 contains a complete minimal reproducer (4 small C files + 1 trivial Swift file, no proprietary code): a 30-second CLI script whose host binary segfaults through an orphaned pointer, and a default-settings Xcode project whose Run build works while its archived build crashes pre-main on device, identically for archives produced by Xcode 26.3.0, 26.4.0 and 26.6 (crash logs for each attached in the FB). Happy to share more details from the investigation if anyone is debugging the same signatures.
1
0
83
4d
UITabBarAppearance with iOS27 Beta
iOS Version: iOS 27 Beta Xcode: Xcode27 Beta 2 I have a custom UITabBar subclass. The tab bar items are visible and selectable, and the selected state works, but the title color in the normal state is always rendered as white, even though I set a different normal title color. Simplified code let normalColor = UIColor.gray let selectedColor = UIColor.orange let bgColor = UIColor.black let font = UIFont.systemFont(ofSize: 10, weight: .semibold) let appearance = UITabBarAppearance() appearance.configureWithOpaqueBackground() appearance.backgroundEffect = nil appearance.backgroundColor = bgColor appearance.shadowColor = .clear let itemAppearance = appearance.stackedLayoutAppearance itemAppearance.normal.titleTextAttributes = [ .font: font, .foregroundColor: normalColor ] itemAppearance.selected.titleTextAttributes = [ .font: font, .foregroundColor: selectedColor ] itemAppearance.normal.iconColor = normalColor itemAppearance.selected.iconColor = selectedColor appearance.stackedLayoutAppearance = itemAppearance appearance.inlineLayoutAppearance = itemAppearance appearance.compactInlineLayoutAppearance = itemAppearance tabBar.standardAppearance = appearance if #available(iOS 15.0, *) { tabBar.scrollEdgeAppearance = appearance } tabBar.backgroundColor = bgColor tabBar.isTranslucent = false The problem: The selected title/icon color works. The normal title color is ignored and stays white. This happens after moving to the newer tab bar appearance behavior / Liquid Glass environment. Question: Is there any additional configuration required for UITabBarAppearance so that the normal UITabBarItem title color is respected? Could unselectedItemTintColor, tintColor, scrollEdgeAppearance, or Liquid Glass behavior override normal.titleTextAttributes?
3
0
106
5d
HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall
Environment: iPhone 13 Pro, iOS 26.5. Affects a single user out of many; cannot reproduce on any of our test devices. We use HKStatisticsCollectionQuery to read step counts for a statistics screen. For one specific user, the query's initialResultsHandler appears to deliver results == nil (the success branch never runs), so our completion is never called and the screen shows an infinite spinner. private let store = HKHealthStore() func fetchHourlyStepCounts(for day: Date, completion: @escaping ([Int]) -> Void) { guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let calendar = Calendar.current let startOfDay = calendar.startOfDay(for: day) var hourly = DateComponents() hourly.hour = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: nil, options: .cumulativeSum, anchorDate: startOfDay, intervalComponents: hourly ) query.initialResultsHandler = { _, collection, error in guard let collection else { // For the affected user, execution seems to reach here (collection == nil). // Adding logging of the HKError + authorization status for the next occurrence. return } var counts: [Int] = [] let end = calendar.date(byAdding: .day, value: 1, to: startOfDay)! collection.enumerateStatistics(from: startOfDay, to: end) { stats, _ in let steps = stats.sumQuantity()?.doubleValue(for: .count()) ?? 0 counts.append(Int(steps)) } DispatchQueue.main.async { completion(counts) } } store.execute(query) } What we've confirmed / ruled out: Read authorization for stepCount is granted (the user toggled it ON in the HealthKit sheet on video). The Apple Health app shows step data for this user (so data exists). A coarser query (2-year interval) for the same user succeeds, while the hourly query appears to fail — same type / predicate / options / auth. Symptom persists across app reinstall and device reboot, and re-granting Health permission. Permission denial returns empty results (per Apple docs), not an error — so this isn't simple denial. Not errorDatabaseInaccessible as far as we can tell (foreground, device unlocked). Questions: What can cause HKStatisticsCollectionQuery.initialResultsHandler to return results == nil (with an error) persistently for one device/account, when read auth is granted and data exists? Can errorHealthDataRestricted occur without an MDM/supervised profile (i.e., on a normal consumer device)? What device/account states actually trigger it? Is it expected that a coarse-interval query succeeds while an hourly-interval query on the same type fails for the same user? We're adding logging of the actual HKError code + authorizationStatus for the next occurrence, but would appreciate any insight on what conditions produce this.
0
0
114
1w
Xcode 27: huge build size jump, spike in "Class X is implemented in both" warnings
The compiled size of my app (DerivedData/*/Build/Products/Debug-iphonesimulator/AppName.app) jumped 200 MB (926 MB-> 1.12 GB) just by compiling with Xcode 27 beta 2 (currently the latest). I can compile with Xcode 27, but when I run it on a simulator it crashes on launch. I get the same type of crash when running my unit tests. I'm getting a lot of warnings in the debug console about "Class X is implemented in both". I asked Claude to analyze the .app files to find the difference. Yes, I have a lot of internal and external packages/frameworks. Xcode26 ships 128 frameworks including 14 *_PackageProduct.framework dynamic frameworks (Logger_…, APICore_…, SplitManager_…, Apollo_…, PerModel_…, AppGateway_…, etc.). Xcode 27 ships 114 — all 14 of those dynamic package frameworks are gone. Xcode 27 changed the default and now links those SPM package products statically into every framework that consumes them. Counting framework binaries that carry their own copy of a package's Swift type metadata: ┌──────────────┬────────────┬─────────────┐ │ Package │ Xcode 26 │ Xcode 27 b2 │ ├──────────────┼────────────┼─────────────┤ │ Logger │ 12 │ 79 │ ├──────────────┼────────────┼─────────────┤ │ APICore │ 3 │ 45 │ ├──────────────┼────────────┼─────────────┤ │ SplitManager │ 1 │ 20 │ ├──────────────┼────────────┼─────────────┤ │ PerModel │ 1 │ 24 │ ├──────────────┼────────────┼─────────────┤ │ AppGateway │ 1 │ 20 │ └──────────────┴────────────┴─────────────┘ 79 copies of Logger's types instead of 1. That's the runtime problem: duplicate Swift type metadata / Objective-C class registration → "Class … is implemented in both …, one of the two will be used" and, when type identity or singletons matter, crashes. It hits unit tests hardest because the test bundle re-links the same static package that the host app's frameworks already contain. I worked on it a bit trying to switch my packages and frameworks to load dynamically. But that only gets so far as 3rd party packages like Apollo (for GraphQL) don't ship a dynamic version of ApolloTestSupport. I really don't like forking 3rd party packages. I tried changing my packages to explicitly load dynamically like this. That got me to the point that I could run on a simulator. But I was unable to get to the point that I could run all my unit tests without crashing on launch. And the code that runs on a simulator crashes on a device complaining about missing packages. products: [ .library( name: "AppGateway", + type: .dynamic, targets: ["AppGateway"]), ], Something is really different in Xcode 27 with the way it links packages and creates my app - a linker bug? I don't know if there is an ancient build setting that might be triggering this? Our app is really old. v1 was created in 2010. We just recently moved to a SceneUI delegate setup. I really don't know what would be a good next step for me to figure this one out. I am happy to use a DTS or create a Feedback if I thought it would help me get forward progress on this? Help?
0
3
165
1w
Url Cache
Hi all, I have implemented a feature in my iOS application which checks the latest version available on App Store and if there is new update available it shows Pop to update the app. I am using this url for checki https://itunes.apple.com/lookup?bundleId= Issue: For some users this url returns old cached data which is previous version although new version is already live and i have verified this url directly via PostMan or other IDE.
1
0
154
1w
Default Actor Isolation - MainActor conflicts with Sendable
In Xcode project > Build Settings > Swift Compiler - Concurrency. When we have those settings : Approachable Concurrency - Yes Default Actor Isolation - MainActor A sendable struct without @Actor annotation will be stuck to @MainActor. But if we have a sendable struct, by principle, it should be used across Actors. To remediate the situation, we had to prefix the struct with nonisolated keyword. The setting "Default Actor Isolation - MainActor" should not add @MainActor to Sendables. Problem describe in : FB23264607
2
0
339
1w
Emoji rotated variation
Emoji are very convenient to be used instead of image, directly as String. In some cases, a variation to show them rotated (but still as String, not converted as image) would be useful. Examples may be arrows or flags if you need to show them floating from the top and not from the side of the pole. And I would declare: flag = "🇺🇸" or So the question; is it possible to generate new emoji as rotated initial emojis ? Or better, do such extensions already exist.
2
1
194
1w
Subclassing UISegmentedControl in Xcode 26 strange behavior
UIKit application. I have a UISegmentedControl which displays flags, using the emoji for the text of the segment (SegmentedControl defined in stroryboard). Depending app is in Portrait or Landscape, the segmented control is displayed vertically or horizontally. When horizontal, nothing to do, direct display from stroryboard, works as expected. When vertical (Portrait), I have to rotate the UISegmentedControl π/2. And To get the flags properly oriented, I rotate each image -π/2. That works fine when compiling with Xcode 16.4. But when compiling with Xcode 26.3, rotation of segments do not work. Here is the illustration, compile on target simulators 26.2 in both cases (3rd image explained below):                             Xcode 16.4           -               Xcode 26.3 subviews rotated   -     removed subviews rotation Now the code. I subclassed UISegmentedControl to draw at will. class SegmentedControlRotable: UISegmentedControl { @IBInspectable var vertical : Bool = false // IBInspectable is now ignored override func draw(_ rect: CGRect) { if vertical { self.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2.0) for subview in self.subviews { subview.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2.0) // reverse rotate // 3rd picture: this line commented out. } } else { // does no change self.transform = CGAffineTransform(rotationAngle: 0.0) for subview in self.subviews { subview.transform = CGAffineTransform(rotationAngle: 0.0) } } } // More code with touchesEnded, works OK in both cases } In fact, with Xcode 26, segments are always drawn on an horizontal line. l I noticed that the structure of self.subviews is different. 19 subviews in Xcode 16, 12 in Xcode 26. I removed the rotation of subviews, and it's OK. Just flags are now vertical (as illustrated above). What do I miss ? How to rotate the subviews in Xcode 26 ?
0
0
96
1w
Sample Code with Swift 6
I find these sample projects quite valuable: https://developer.apple.com/documentation/widgetkit/emoji-rangers-supporting-live-activities-interactivity-and-animations https://developer.apple.com/documentation/coredata/sharing-core-data-objects-between-icloud-users . Both use Swift 5, and it is not trivial to adopt Swift 6 with them. Any plans to update them? What is best approach for adopting Swift 6 on such sample code?
5
0
859
1w
RegexBuilder infinite loop when nullable capture starts with NegativeLookahead
In Swift 6.4 or later, a RegexBuilder pattern can hang when an unbounded quantifier repeats a body that can match the empty string, where that body begins with NegativeLookahead. I've opened a corresponding issue and PR to resolve the issue in swift-experimental-string-processing. See below for a reproduction and a workaround. The regression affects apps running on OS 27 built with Xcode 27, which includes Swift 6.4. Running apps built with Xcode 27 on OS 26 or earlier demonstrates the expected behavior. Links: Issue: https://github.com/swiftlang/swift-experimental-string-processing/issues/865 PR: https://github.com/swiftlang/swift-experimental-string-processing/pull/866 FB23419149 and FB23179771 https://forums.swift.org/t/regexbuilder-infinite-loop-when-nullable-capture-starts-with-negativelookahead/87713 Reproduction In the reducer below, matching "A" repeatedly invokes the capture transform with an empty substring without advancing through the input. import RegexBuilder let regex = Regex { ZeroOrMore { Capture { NegativeLookahead { "a" } ZeroOrMore(.digit) } transform: { String($0) } // invoked repeatedly with "" } } _ = "A".matches(of: regex) // never returns Reduced string form: _ = try! Regex(#"(?:(?!a)\d*)*"#).firstMatch(in: "A") // never returns The issue is in the same forward-progress class as PR #851, which skips a nullable quantification's child subtree. Lookaround groups need the same treatment. The regression first appears in Swift 6.4-dev toolchains. I observed the issue in code running on iOS 27 beta 1 (24A5355q), then traced the regression to PR #849 in swift-experimental-string-processing. Workaround In the meantime, wrap the capture contents in Optionally { }: import RegexBuilder let digits = Regex { NegativeLookahead { "a" } ZeroOrMore(.digit) } let regex = Regex { ZeroOrMore { Capture { Optionally { digits } } transform: { String($0) } } } _ = "A".matches(of: regex)
1
1
252
1w
Customise UITabBar on iPadOS 26+
I'm building an app with a UISplitViewController as the base, with the main content being a UITabBarController. I'm targeting iOS 26+ and using UIKit. I've customised the tabbar on iOS to have a different font family and size, and used some custom images. Running the same app on iPad, the tabbar moves to the top of the screen, ignores ALL the appearance proxy settings and strips out the images. Its now just giant floating text. Also noticed in portrait mode when the side bar from the split view is open, it compresses the width of the tab bar down to only show 2 elements at a time, with this weird custom scroll thing to move to the rest of the tabs. If the text wasn't so massive, maybe it could fit more. I really hate every inch of this thing. Its looks ugly and functions bizarrely. Why does it ignore all the tabbar appearance settings, and how can I customise it to add icons back with smaller text? Ideally I don't want to use one of the hacks to force it to think its compact mode to bring back the old tabbar, as i'm relying on traits already to fix some SplitView annoyances and don't want those to break. But would love to have the old tab bar style. Are there any settings or toggles that I can use?
0
0
172
1w
UserDefaults.standard.integer(forKey: ) crashes the app with EXC_BAD_ACCESS (code=1, address=0x0)
With the 27 OSes using UserDefaults.standard.integer(forKey: ) can cause a crash with EXC_BAD_ACCESS (code=1, address=0x0) It has been seen on a Multiplatform app, up to now tested on iOS/iPadOS and visionOS 27 Beta 1. In our code we use UserDefaults.standard.integer(forKey: ) from a singleton called during the SwiftUI app init(), and we don't know yet if this is the only moment there is a crash as we can't go farther. The API should return 0 if it can't get a value. There is no reason the app should crash if the API conforms to its contract. Running the same code from Xcode on iOS 26 runs it without issue. FeedBack FB23310748
7
0
363
1w
Programming Languages Resources
This topic area is about the programming languages themselves, not about any specific API or tool. If you have an API question, go to the top level and look for a subtopic for that API. If you have a question about Apple developer tools, start in the Developer Tools & Services topic. For Swift questions: If your question is about the SwiftUI framework, start in UI Frameworks > SwiftUI. If your question is specific to the Swift Playground app, ask over in Developer Tools & Services > Swift Playground If you’re interested in the Swift open source effort — that includes the evolution of the language, the open source tools and libraries, and Swift on non-Apple platforms — check out Swift Forums If your question is about the Swift language, that’s on topic for Programming Languages > Swift, but you might have more luck asking it in Swift Forums > Using Swift. General: Forums topic: Programming Languages Swift: Forums subtopic: Programming Languages > Swift Forums tags: Swift Developer > Swift website Swift Programming Language website The Swift Programming Language documentation Swift Forums website, and specifically Swift Forums > Using Swift Swift Package Index website Concurrency Resources, which covers Swift concurrency How to think properly about binding memory Swift Forums thread Other: Forums subtopic: Programming Languages > Generic Forums tags: Objective-C Programming with Objective-C archived documentation Objective-C Runtime documentation Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com"
Replies
0
Boosts
0
Views
2.9k
Activity
Oct ’25
Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
Xcode tells me Previewing in executable targets now requires a new build layout for unoptimized builds. Either set ENABLE_DEBUG_DYLIB to YES for this target, or break out your preview code into a separate framework with its own scheme. How do enable that in Package.swift. swiftSettings don't work (.define and unsafeFlags with -D ...). Creating a library product that the executable then depends on doesn't help either. I have two targets, one is an executable target. The #Preview macro is in the non-executable target.
Replies
3
Boosts
2
Views
422
Activity
2h
SensorKit: didFetchResult not being called
Hello, I have an app for a research study that has been approved and authorized to use SensorKit. All my permissions, entitlements and authorizations are in order, but I still can't get any data. The didFetchResult is not being called even though didCompleteFetch is called. I have waited for over 24 hours, but it still returns no samples. Please, I would appreciate any help on this issue. Thank you func sensorReader( _ reader: SRSensorReader, fetchingRequest: SRFetchRequest, didFetchResult result: SRFetchResult<AnyObject> ) { receivedResultsInCurrentFetch = true print("✅ SensorKit fetch result received for: \(sensorKey)") AppLogger.shared.log("SensorKit fetch result received for \(sensorKey)") if let sample = result.sample as? T { print("✅ SensorKit sample matched expected type for \(sensorKey): \(T.self)") AppLogger.shared.log("SensorKit sample matched expected type for \(sensorKey): \(T.self)") processSample(sample) } else { print("❌ SensorKit sample did not match expected type for \(sensorKey): \(T.self)") AppLogger.shared.log("SensorKit sample did not match expected type for \(sensorKey): \(T.self)") } } func sensorReader(_ reader: SRSensorReader, didCompleteFetch request: SRFetchRequest) { if receivedResultsInCurrentFetch, let lastRequestedUpperBound { session.setSensorKitLastFetchTime(lastRequestedUpperBound, for: sensorKey) print("✅ SensorKit fetch completed with samples for \(sensorKey). Checkpoint updated.") } else { print("⚠️ SensorKit fetch completed for \(sensorKey) with no samples.") AppLogger.shared.log("SensorKit fetch completed for \(sensorKey) with no samples. Keeping previous checkpoint so delayed SensorKit data is not skipped.") } isFetchInFlight = false completePendingFetches(success: true) print("✅ SensorKit fetch completed for: \(sensorKey)") AppLogger.shared.log("Fetch request completed for sensor type: \(T.self)") }
Replies
1
Boosts
0
Views
134
Activity
3h
Xcode 27 beta 3 linker warning: points before section start and the target atom is ambiguous
I am testing an existing iOS app with Xcode 27 beta 3. The build succeeds, but I am seeing a new linker warning from Swift Package product targets. ld: warning: address=0xF496F points before section(28) start and the target atom is ambiguous Environment: Xcode 27.0 beta 3 Build version: 27A5218g Platform: iOS Simulator Configuration: Debug Project type: iOS app with Swift Package dependencies, also embedding a watchOS app Build command: DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer \ xcodebuild -project MyWeight/MyWeight.xcodeproj \ -scheme MyWeight \ -configuration Debug \ -destination "generic/platform=iOS Simulator" \ build The build succeeds: ** BUILD SUCCEEDED ** Warnings: MyWeight/MyWeightKit/Package.swift: MyWeightKit-watchOS-product: ld: warning: address=0xF493F points before section(28) start and the target atom is ambiguous MyWeight/MyWeightKit/Package.swift: MyWeightKit-iOS-product: ld: warning: address=0xF496F points before section(28) start and the target atom is ambiguous Both warnings appear during the link step for Swift Package product framework targets. Is this a known issue in Xcode 27 beta 3? Does it indicate a real issue in the produced simulator binary, or is it likely a linker/debug-info diagnostic?
Replies
0
Boosts
0
Views
17
Activity
16h
关于我使用Swift和Metal制作的神经网络引擎
我今年18岁。没有机器学习背景,没有上过大学,高中都没去上,没有导师。 几天前我盯着一张纸发呆。突然想:为什么计算机神经网络一定要是2D的?可以模拟生物吗?为什么一定要在平面上算?如果多个平面,岂不是翻倍?如果把六张纸想象成一个魔方,六个面各自承载神经元,八条体对角线变成新的通信通道会怎么样? 我真的很喜欢折腾这些,然后我立刻制定了详细计划,使用AI工具辅助写下了第一个 kernel。跑崩了。我又重新想了一下,和qq群友分享了我的目标,又写。又崩。连续几十次。没有 PyTorch,没有 TensorFlow,没有 CUDA。只有Swift和Metal。因为我的电脑显卡是AMD Vega 64,没装任何框架辅助,因为我想明白最底层的运行方式是什么原理。 这就是CubeNN。 ##以下为AI的详细解答,内容与架构改动太多,我在这里一次讲不清楚 它是什么 一个用魔方几何作为计算架构的神经网络引擎。 标准 Transformer: 把数据排成一行,O(n²) 地互相看 CubeNN: 把数据分布在 14 个面上,只在该看的地方看 6 个标准面 → 块稀疏注意力(粗看全局 + 细看局部) 8 个 X 面对角线 → 跨面信息桥(不做 Attention,只负责传递) 每轮:6 面算 → 投影到 8 X 面 → 上采样精炼 → 融合回 6 面 最关键的是 Cube Cascade——一个树+链级联推理: 树阶段: 1 个魔方 spawn 8 个 → 8 个 spawn 64 个 → 73 个并行探索 GPU 上同时跑,选最优路径 链阶段: 最优叶子无限深度精炼 3-5 步收敛,方差提升 ~7% 怎么实现的 纯 Swift + Metal。零依赖。零框架。 // 大致代码就是这些 import Metal import Foundation let device = MTLCreateSystemDefaultDevice()! let library = try! device.makeLibrary(filepath: "cube_nn.metallib") // ...12 个 GPU kernel,12,000 次 dispatch 关键技术决策: 单 Command Buffer:整个树阶段 73 个魔方的全部 kernel dispatch 打包进一个 CB,0 次 CPU-GPU 同步 Pipeline State 缓存:编码从 1022ms 降到 42ms Buffer 偏移:所有 73 个魔方的 14 个面存进一个连续 buffer,kernel 通过 buffer(15) 传偏移量 FP16:N≥64 时半精度提速 21% 性能 ##经过测试,但是因设备差异可能不准确,仅参考 AMD Radeon RX Vega 64 (2017 年显卡, 14nm, 295W): 规模 神经元 魔方数 耗时 N=32 6,144 73 (树) 435ms N=64 24,576 21 (树) 817ms N=128 98,304 1 116ms N=32 全连接 Attention 每层 201M FLOP → CubeNN 块稀疏 370K FLOP (544× 减少) N=128 全连接需要 32GB 显存(物理上不存在)→ CubeNN 用 192KB N=256 全连接需要 2.2T FLOP → CubeNN 52M FLOP (42,300× 减少) 代码体积:161KB。 对比 PyTorch 的 800MB。 我经历了什么 这个项目最困难的不是写 kernel,是在没有任何人告诉我"能不能做"的情况下,靠反复试错找到路。 第一次试图跑 73 个魔方,GPU 直接 hang 了。花了 3 天定位到是 Command Buffer 堆叠过多。 改了 single encoder 方案,又碰上 SIGILL——Metal 不允许 makeBuffer(length: 0),B=0 时创建了零长度 buffer。 想用 threadgroup memory 做 kernel fusion,结果跨 threadgroup 读不到数据,才明白 LDS 是 per-group 的。 N=64 的 FP16 要手动写 float↔half 转换函数,因为 macOS 11 上 Float16 类型被标为 unavailable。 每一次崩溃都教会我一个 Metal 的底层细节。没有人教我,但 Metal 的报错信息就是最好的老师。 为什么发在 Apple 开发者论坛 因为这是为苹果生态而生的项目。CubeNN 从头到尾只用了两个东西:Swift 和 Metal。它不需要移植就能跑在任何 Apple Silicon Mac 上(API兼容)。如果未来能把部分 kernel 映射到 Neural Engine,效率会再翻几倍。 我想问 Apple 的 Metal 工程师和 Core ML 团队: ** 有没有更好的 GPU 任务调度方式?**目前表现仍然欠佳(对于我这个完美主义者来说),可能改得有点乱了 有没有兴趣评估这个架构在 M4 上的表现? 我手里只有 Vega 64。M4 GPU + ANE方法 跑 CubeNN 会是什么效果? 源代码 ├── run.swift # 统一 CLI,参数化 N/B/depth ├── src/ │ ├── cube_nn.metal # FP16 kernel │ └── cube_nn_fp32.metal # FP32 kernel └── benchmarks/ # 实测数据 如果你读到了这里——谢谢你。一个门外汉靠痴狂的,纯粹到几乎是妄想的主意和Metal走到了这里。我懂的不是很多,如果这个架构有任何价值,我想让它变得更好。任何建议、批评、或者指教,都非常欢迎。
Replies
1
Boosts
0
Views
233
Activity
22h
Task alive duration when device is locked
Hello everybody. I have a Swift Task which calls 2(minimum) to 3 (maximum) REST calls sequentially upon specific cases. They are not long run processes like files. I am wondering what is the alive duration of a Task if the device is locked. I noticed that sometimes it is executed in the background properly, some others is paused and resumed when the device is unlocked again and sometime we got timeout (in more than 10 minutes). Is any official time limit documented where the iOS system suspends a Task?
Replies
1
Boosts
0
Views
105
Activity
1d
Issue with Auto-Blur Effect of NSScrollViews under NSToolbar, Ref: WWDC25
Hello, I'm building an app that is designed to largely mimick Apple's own audio auto-switch behavior when switching between different audio output devices like MacBook Pro speakers and AirPods. The purpose is to "lend a hand" to certain apps, like CrossOver (wine) ran x68-64 apps that don't seem to respond well to CoreAudio changing the audio output after the x68-64 program has already init its audio after startup. Thus, I don't actually need much of a GUI except for a few specific features, and perhaps later some ehancements I'd like to add that can make use of a proper GUI. I've decided to implement the MacOS Tahoe Apple Liquid Glass UI to keep the user experience as streamlined and intuitive as possible. I've largely been successful: The GitHub page goes into greater detail showing the greater context of the AppKit API's I'm using to achieve this UI design. There is just one issue I haven't been able to solve, how to get the sidebar tab(s) to blur when scrolled underneath the Window Controls (Traffic Light) buttons. These tabs are part of a NSScrollView underneath the NSToolbar aligned from the top-most left and right window edges, but split from the right-hand content side via NSSplitViewController > NSSplitViewItem (again exact topology is at the page "link" below). On the content side (right side), I used NSSplitViewItemAccessoryViewController to create the blur zone so that when its own NSScrollView content is scrolled upwards, past the toolbar NSToolbar, it would apply a progressive tint+blur effect, just as Apple has implemented in their own apps. This wasn't really automatic since I did have to elect to use it as part of a MacOS 26.1+ specific class (NSScrollEdgeEffectStyle), but it's working on the content side nonetheless: Now I am trying to get the same effect working on the sidebar side and am having issues with this. Please see the page below as it summarizes our test attempts with greater detail. I've only gotten this far by reading "obscure" comments in the SDK's so I'm really hoping this is just a ID10T error in that I've missed something. Note: even though I only have 3 tabs currently in the sidebar NSScrollView, I will eventually populate this further, especially with some user configurable stuff on my roadmap. That said, the sidebar is only "scrollable" right now because I've left the "vertical scroll elasticity" enabled, intentionally. (.verticalScrollElasticity [IS NOT] .none! Therefore, I can still "scroll" the enumerated tabs inside the sidebar's NSScrollView upward behind the Traffic Light buttons, to validate if the blur+tint effect is being rendered. I say all of that to ask if, perhaps, the reason that the blur+tint effect is not rendering in the Window could be because there's not enough content to render in the sidebar to produce a scrollbar, and simply leaving .verticalScrollElasticity "enabled" is not sufficient to produce this effect? I don't know that for sure, but it's the only thing I can think of at this point. Its not obvious to me though. This app is written entirely in Swift (v6.3.3) and will require a minimum of MacOS Tahoe 26.1.X due to the AppKit API's I'm using (namely NSScrollEdgeEffectStyle). GitHub Page documenting issue in greater detail (remove the spaces): HT TP S:// gitdev.brianbutts.me /sidebar-scroll-edge-blur. html
Replies
1
Boosts
0
Views
57
Activity
2d
Archived apps crash before main() after strip -S -T corrupts dyld chained fixups (FB23528109, Xcode 26.3-27.0b2)
We root-caused a launch crash that only affects ARCHIVED builds (Run/Debug works, simulator works) and filed it as FB23528109. Posting the details here because the crash signatures are hard to search for and other teams are likely to hit this as they adopt Swift 6.3 toolchains. SYMPTOM The archived app crashes before main() on device, on every launch. Depending on which orphaned pointer gets read first, the crash looks like one of these: EXC_BREAKPOINT, "pointer authentication trap DA", inside swift_conformsToProtocolMaybeInstantiateSuperclasses / _searchConformancesByMangledTypeName (often with a Firebase or other +load frame below it; that frame is just the first conformance scan at launch, not the cause) EXC_BAD_ACCESS KERN_INVALID_ADDRESS at a small, raw unslid address (e.g. 0xc118), inside dyld: resolveRebase <- objc_visitor::forEachClass <- dyld4::PrebuiltObjC::make Debug builds, simulator builds and Xcode Run builds are all fine, because the corruption happens in the Strip build phase, which only runs for Archive/install builds. ROOT CAUSE (two defects combine) strip -S -T (what Xcode runs on embedded frameworks during Archive when STRIP_SWIFT_SYMBOLS = YES) corrupts dyld chained fixups. When strip removes a Swift weak-definition symbol that has a GOT bind, it converts the bind into a rebase to the local definition (correct) but writes the converted entry with next = 0 (incorrect). That terminates the 16 KB page's fixup chain early, and every fixup after the converted slot in the same page is orphaned: dyld never processes it, so raw chain-encoding bytes get read as pointers at launch. The bug is present in every strip we tested: Xcode 26.3, 26.4, 26.4.1, 26.5, 26.6 and 27.0 beta 2. strip -S and strip -S -x (without -T) do not corrupt. Starting with Swift 6.3.0 (Xcode 26.4.0), the compiler emits the trigger pattern for ordinary code: cross-module references to a non-final class's stored-property accessors become weak-def-coalesce binds (Swift 6.2.4 emits none). So apps that embed a multi-module Swift dynamic framework (e.g. an SPM package built as one dynamic framework) started getting corrupted by their own default Archive pipeline when they moved past Xcode 26.3. HOW TO CHECK IF YOU ARE AFFECTED Compare the fixups of a framework binary inside your archive against a Run build of the same code: xcrun dyld_info -fixups YourApp.app/Frameworks/YourKit.framework/YourKit If fixups that exist in the Run build are missing after the archive's strip step (in particular __got slots and anything after them in the same 16 KB page), you are affected. Also: any GOT bind of a Swift ($s...) symbol in the pre-strip binary is a red flag. WORKAROUND Set STRIP_SWIFT_SYMBOLS = NO (optionally STRIP_STYLE = non-global, i.e. strip -S -x, which kept the size cost to about +4% for us). Important: if the affected framework is a Swift package product, these must be passed as xcodebuild command-line overrides (e.g. xcodebuild ... STRIP_SWIFT_SYMBOLS=NO STRIP_STYLE=non-global); xcconfig files do not apply to package targets. REPRO FB23528109 contains a complete minimal reproducer (4 small C files + 1 trivial Swift file, no proprietary code): a 30-second CLI script whose host binary segfaults through an orphaned pointer, and a default-settings Xcode project whose Run build works while its archived build crashes pre-main on device, identically for archives produced by Xcode 26.3.0, 26.4.0 and 26.6 (crash logs for each attached in the FB). Happy to share more details from the investigation if anyone is debugging the same signatures.
Replies
1
Boosts
0
Views
83
Activity
4d
UITabBarAppearance with iOS27 Beta
iOS Version: iOS 27 Beta Xcode: Xcode27 Beta 2 I have a custom UITabBar subclass. The tab bar items are visible and selectable, and the selected state works, but the title color in the normal state is always rendered as white, even though I set a different normal title color. Simplified code let normalColor = UIColor.gray let selectedColor = UIColor.orange let bgColor = UIColor.black let font = UIFont.systemFont(ofSize: 10, weight: .semibold) let appearance = UITabBarAppearance() appearance.configureWithOpaqueBackground() appearance.backgroundEffect = nil appearance.backgroundColor = bgColor appearance.shadowColor = .clear let itemAppearance = appearance.stackedLayoutAppearance itemAppearance.normal.titleTextAttributes = [ .font: font, .foregroundColor: normalColor ] itemAppearance.selected.titleTextAttributes = [ .font: font, .foregroundColor: selectedColor ] itemAppearance.normal.iconColor = normalColor itemAppearance.selected.iconColor = selectedColor appearance.stackedLayoutAppearance = itemAppearance appearance.inlineLayoutAppearance = itemAppearance appearance.compactInlineLayoutAppearance = itemAppearance tabBar.standardAppearance = appearance if #available(iOS 15.0, *) { tabBar.scrollEdgeAppearance = appearance } tabBar.backgroundColor = bgColor tabBar.isTranslucent = false The problem: The selected title/icon color works. The normal title color is ignored and stays white. This happens after moving to the newer tab bar appearance behavior / Liquid Glass environment. Question: Is there any additional configuration required for UITabBarAppearance so that the normal UITabBarItem title color is respected? Could unselectedItemTintColor, tintColor, scrollEdgeAppearance, or Liquid Glass behavior override normal.titleTextAttributes?
Replies
3
Boosts
0
Views
106
Activity
5d
How to change the color of the native back button
How do I change the color of the native back button that is added automatically with NavigationSplitView? I have tried a lot of different methods, but I can't find out how to change its color to a custom color instead of just black.
Replies
0
Boosts
0
Views
93
Activity
1w
HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall
Environment: iPhone 13 Pro, iOS 26.5. Affects a single user out of many; cannot reproduce on any of our test devices. We use HKStatisticsCollectionQuery to read step counts for a statistics screen. For one specific user, the query's initialResultsHandler appears to deliver results == nil (the success branch never runs), so our completion is never called and the screen shows an infinite spinner. private let store = HKHealthStore() func fetchHourlyStepCounts(for day: Date, completion: @escaping ([Int]) -> Void) { guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let calendar = Calendar.current let startOfDay = calendar.startOfDay(for: day) var hourly = DateComponents() hourly.hour = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: nil, options: .cumulativeSum, anchorDate: startOfDay, intervalComponents: hourly ) query.initialResultsHandler = { _, collection, error in guard let collection else { // For the affected user, execution seems to reach here (collection == nil). // Adding logging of the HKError + authorization status for the next occurrence. return } var counts: [Int] = [] let end = calendar.date(byAdding: .day, value: 1, to: startOfDay)! collection.enumerateStatistics(from: startOfDay, to: end) { stats, _ in let steps = stats.sumQuantity()?.doubleValue(for: .count()) ?? 0 counts.append(Int(steps)) } DispatchQueue.main.async { completion(counts) } } store.execute(query) } What we've confirmed / ruled out: Read authorization for stepCount is granted (the user toggled it ON in the HealthKit sheet on video). The Apple Health app shows step data for this user (so data exists). A coarser query (2-year interval) for the same user succeeds, while the hourly query appears to fail — same type / predicate / options / auth. Symptom persists across app reinstall and device reboot, and re-granting Health permission. Permission denial returns empty results (per Apple docs), not an error — so this isn't simple denial. Not errorDatabaseInaccessible as far as we can tell (foreground, device unlocked). Questions: What can cause HKStatisticsCollectionQuery.initialResultsHandler to return results == nil (with an error) persistently for one device/account, when read auth is granted and data exists? Can errorHealthDataRestricted occur without an MDM/supervised profile (i.e., on a normal consumer device)? What device/account states actually trigger it? Is it expected that a coarse-interval query succeeds while an hourly-interval query on the same type fails for the same user? We're adding logging of the actual HKError code + authorizationStatus for the next occurrence, but would appreciate any insight on what conditions produce this.
Replies
0
Boosts
0
Views
114
Activity
1w
Xcode 27: huge build size jump, spike in "Class X is implemented in both" warnings
The compiled size of my app (DerivedData/*/Build/Products/Debug-iphonesimulator/AppName.app) jumped 200 MB (926 MB-> 1.12 GB) just by compiling with Xcode 27 beta 2 (currently the latest). I can compile with Xcode 27, but when I run it on a simulator it crashes on launch. I get the same type of crash when running my unit tests. I'm getting a lot of warnings in the debug console about "Class X is implemented in both". I asked Claude to analyze the .app files to find the difference. Yes, I have a lot of internal and external packages/frameworks. Xcode26 ships 128 frameworks including 14 *_PackageProduct.framework dynamic frameworks (Logger_…, APICore_…, SplitManager_…, Apollo_…, PerModel_…, AppGateway_…, etc.). Xcode 27 ships 114 — all 14 of those dynamic package frameworks are gone. Xcode 27 changed the default and now links those SPM package products statically into every framework that consumes them. Counting framework binaries that carry their own copy of a package's Swift type metadata: ┌──────────────┬────────────┬─────────────┐ │ Package │ Xcode 26 │ Xcode 27 b2 │ ├──────────────┼────────────┼─────────────┤ │ Logger │ 12 │ 79 │ ├──────────────┼────────────┼─────────────┤ │ APICore │ 3 │ 45 │ ├──────────────┼────────────┼─────────────┤ │ SplitManager │ 1 │ 20 │ ├──────────────┼────────────┼─────────────┤ │ PerModel │ 1 │ 24 │ ├──────────────┼────────────┼─────────────┤ │ AppGateway │ 1 │ 20 │ └──────────────┴────────────┴─────────────┘ 79 copies of Logger's types instead of 1. That's the runtime problem: duplicate Swift type metadata / Objective-C class registration → "Class … is implemented in both …, one of the two will be used" and, when type identity or singletons matter, crashes. It hits unit tests hardest because the test bundle re-links the same static package that the host app's frameworks already contain. I worked on it a bit trying to switch my packages and frameworks to load dynamically. But that only gets so far as 3rd party packages like Apollo (for GraphQL) don't ship a dynamic version of ApolloTestSupport. I really don't like forking 3rd party packages. I tried changing my packages to explicitly load dynamically like this. That got me to the point that I could run on a simulator. But I was unable to get to the point that I could run all my unit tests without crashing on launch. And the code that runs on a simulator crashes on a device complaining about missing packages. products: [ .library( name: "AppGateway", + type: .dynamic, targets: ["AppGateway"]), ], Something is really different in Xcode 27 with the way it links packages and creates my app - a linker bug? I don't know if there is an ancient build setting that might be triggering this? Our app is really old. v1 was created in 2010. We just recently moved to a SceneUI delegate setup. I really don't know what would be a good next step for me to figure this one out. I am happy to use a DTS or create a Feedback if I thought it would help me get forward progress on this? Help?
Replies
0
Boosts
3
Views
165
Activity
1w
Url Cache
Hi all, I have implemented a feature in my iOS application which checks the latest version available on App Store and if there is new update available it shows Pop to update the app. I am using this url for checki https://itunes.apple.com/lookup?bundleId= Issue: For some users this url returns old cached data which is previous version although new version is already live and i have verified this url directly via PostMan or other IDE.
Replies
1
Boosts
0
Views
154
Activity
1w
Default Actor Isolation - MainActor conflicts with Sendable
In Xcode project > Build Settings > Swift Compiler - Concurrency. When we have those settings : Approachable Concurrency - Yes Default Actor Isolation - MainActor A sendable struct without @Actor annotation will be stuck to @MainActor. But if we have a sendable struct, by principle, it should be used across Actors. To remediate the situation, we had to prefix the struct with nonisolated keyword. The setting "Default Actor Isolation - MainActor" should not add @MainActor to Sendables. Problem describe in : FB23264607
Replies
2
Boosts
0
Views
339
Activity
1w
Mesh boolean subtraction operation with SceneKit/RealityKit
I ma trying to figure out if there is a Boolean subtraction functionality native in SceneKit or RealityKit. Simple operation like cutting a hole in a box from a sphere. If not, are there any libraries (free) that I can look into?
Replies
3
Boosts
0
Views
2k
Activity
1w
Emoji rotated variation
Emoji are very convenient to be used instead of image, directly as String. In some cases, a variation to show them rotated (but still as String, not converted as image) would be useful. Examples may be arrows or flags if you need to show them floating from the top and not from the side of the pole. And I would declare: flag = "🇺🇸" or So the question; is it possible to generate new emoji as rotated initial emojis ? Or better, do such extensions already exist.
Replies
2
Boosts
1
Views
194
Activity
1w
Subclassing UISegmentedControl in Xcode 26 strange behavior
UIKit application. I have a UISegmentedControl which displays flags, using the emoji for the text of the segment (SegmentedControl defined in stroryboard). Depending app is in Portrait or Landscape, the segmented control is displayed vertically or horizontally. When horizontal, nothing to do, direct display from stroryboard, works as expected. When vertical (Portrait), I have to rotate the UISegmentedControl π/2. And To get the flags properly oriented, I rotate each image -π/2. That works fine when compiling with Xcode 16.4. But when compiling with Xcode 26.3, rotation of segments do not work. Here is the illustration, compile on target simulators 26.2 in both cases (3rd image explained below):                             Xcode 16.4           -               Xcode 26.3 subviews rotated   -     removed subviews rotation Now the code. I subclassed UISegmentedControl to draw at will. class SegmentedControlRotable: UISegmentedControl { @IBInspectable var vertical : Bool = false // IBInspectable is now ignored override func draw(_ rect: CGRect) { if vertical { self.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2.0) for subview in self.subviews { subview.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2.0) // reverse rotate // 3rd picture: this line commented out. } } else { // does no change self.transform = CGAffineTransform(rotationAngle: 0.0) for subview in self.subviews { subview.transform = CGAffineTransform(rotationAngle: 0.0) } } } // More code with touchesEnded, works OK in both cases } In fact, with Xcode 26, segments are always drawn on an horizontal line. l I noticed that the structure of self.subviews is different. 19 subviews in Xcode 16, 12 in Xcode 26. I removed the rotation of subviews, and it's OK. Just flags are now vertical (as illustrated above). What do I miss ? How to rotate the subviews in Xcode 26 ?
Replies
0
Boosts
0
Views
96
Activity
1w
Sample Code with Swift 6
I find these sample projects quite valuable: https://developer.apple.com/documentation/widgetkit/emoji-rangers-supporting-live-activities-interactivity-and-animations https://developer.apple.com/documentation/coredata/sharing-core-data-objects-between-icloud-users . Both use Swift 5, and it is not trivial to adopt Swift 6 with them. Any plans to update them? What is best approach for adopting Swift 6 on such sample code?
Replies
5
Boosts
0
Views
859
Activity
1w
RegexBuilder infinite loop when nullable capture starts with NegativeLookahead
In Swift 6.4 or later, a RegexBuilder pattern can hang when an unbounded quantifier repeats a body that can match the empty string, where that body begins with NegativeLookahead. I've opened a corresponding issue and PR to resolve the issue in swift-experimental-string-processing. See below for a reproduction and a workaround. The regression affects apps running on OS 27 built with Xcode 27, which includes Swift 6.4. Running apps built with Xcode 27 on OS 26 or earlier demonstrates the expected behavior. Links: Issue: https://github.com/swiftlang/swift-experimental-string-processing/issues/865 PR: https://github.com/swiftlang/swift-experimental-string-processing/pull/866 FB23419149 and FB23179771 https://forums.swift.org/t/regexbuilder-infinite-loop-when-nullable-capture-starts-with-negativelookahead/87713 Reproduction In the reducer below, matching "A" repeatedly invokes the capture transform with an empty substring without advancing through the input. import RegexBuilder let regex = Regex { ZeroOrMore { Capture { NegativeLookahead { "a" } ZeroOrMore(.digit) } transform: { String($0) } // invoked repeatedly with "" } } _ = "A".matches(of: regex) // never returns Reduced string form: _ = try! Regex(#"(?:(?!a)\d*)*"#).firstMatch(in: "A") // never returns The issue is in the same forward-progress class as PR #851, which skips a nullable quantification's child subtree. Lookaround groups need the same treatment. The regression first appears in Swift 6.4-dev toolchains. I observed the issue in code running on iOS 27 beta 1 (24A5355q), then traced the regression to PR #849 in swift-experimental-string-processing. Workaround In the meantime, wrap the capture contents in Optionally { }: import RegexBuilder let digits = Regex { NegativeLookahead { "a" } ZeroOrMore(.digit) } let regex = Regex { ZeroOrMore { Capture { Optionally { digits } } transform: { String($0) } } } _ = "A".matches(of: regex)
Replies
1
Boosts
1
Views
252
Activity
1w
Customise UITabBar on iPadOS 26+
I'm building an app with a UISplitViewController as the base, with the main content being a UITabBarController. I'm targeting iOS 26+ and using UIKit. I've customised the tabbar on iOS to have a different font family and size, and used some custom images. Running the same app on iPad, the tabbar moves to the top of the screen, ignores ALL the appearance proxy settings and strips out the images. Its now just giant floating text. Also noticed in portrait mode when the side bar from the split view is open, it compresses the width of the tab bar down to only show 2 elements at a time, with this weird custom scroll thing to move to the rest of the tabs. If the text wasn't so massive, maybe it could fit more. I really hate every inch of this thing. Its looks ugly and functions bizarrely. Why does it ignore all the tabbar appearance settings, and how can I customise it to add icons back with smaller text? Ideally I don't want to use one of the hacks to force it to think its compact mode to bring back the old tabbar, as i'm relying on traits already to fix some SplitView annoyances and don't want those to break. But would love to have the old tab bar style. Are there any settings or toggles that I can use?
Replies
0
Boosts
0
Views
172
Activity
1w
UserDefaults.standard.integer(forKey: ) crashes the app with EXC_BAD_ACCESS (code=1, address=0x0)
With the 27 OSes using UserDefaults.standard.integer(forKey: ) can cause a crash with EXC_BAD_ACCESS (code=1, address=0x0) It has been seen on a Multiplatform app, up to now tested on iOS/iPadOS and visionOS 27 Beta 1. In our code we use UserDefaults.standard.integer(forKey: ) from a singleton called during the SwiftUI app init(), and we don't know yet if this is the only moment there is a crash as we can't go farther. The API should return 0 if it can't get a value. There is no reason the app should crash if the API conforms to its contract. Running the same code from Xcode on iOS 26 runs it without issue. FeedBack FB23310748
Replies
7
Boosts
0
Views
363
Activity
1w