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

Posts under Swift tag

201 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
3.1k
Oct ’25
iOS 27 Beta 4: Native Liquid Glass UITabBar renders with opaque milky/frosted background while identical code renders correctly on iOS 26.5
iOS 27 Beta 4: Native Liquid Glass UITabBar renders with opaque milky/frosted background while identical code renders correctly on iOS 26.5 Environment Xcode 27 Beta 4 iOS 27 Beta 4 UIKit UITabBarController Storyboard based application Native UITabBar (no custom tab bar implementation) Device: iPhone 17 Pro Simulator (also reproducible on other iPhone simulators) Problem After upgrading to iOS 27 Beta 4, the native Liquid Glass tab bar appears significantly more opaque (milky/frosted gray) than on iOS 26.5. The exact same application binary and configuration render correctly on iOS 26.5. No custom blur or visual effect is being applied. Current Configuration let appearance = UITabBarAppearance() appearance.configureWithDefaultBackground() appearance.backgroundColor = nil appearance.backgroundEffect = nil appearance.shadowColor = .clear tabBar.standardAppearance = appearance tabBar.scrollEdgeAppearance = appearance tabBar.isTranslucent = true tabBar.backgroundColor = nil tabBar.barTintColor = nil tabBar.backgroundImage = nil tabBar.shadowImage = nil Runtime Verification Verified at runtime: tabBar.backgroundColor == nil tabBar.barTintColor == nil tabBar.isTranslucent == true standardAppearance.backgroundColor == nil standardAppearance.backgroundEffect == nil scrollEdgeAppearance.backgroundColor == nil scrollEdgeAppearance.backgroundEffect == nil View Hierarchy The runtime hierarchy contains Apple's native Liquid Glass implementation: UITabBar _UIBarItemPlatterView _UILiquidLensView BackdropView ClearGlassView _UIPortalView _UITabSelectionView Therefore UIKit is using the Liquid Glass implementation rather than falling back to a legacy blur. Investigation Performed The following were tested without changing behavior: Removed all custom blur views Removed custom overlays Removed refresh/recomposition code Removed layout invalidation Removed transform hacks Removed PageMenu Replaced entire first tab with a plain UITableViewController Replaced DiscoverVC completely Replaced nested collection views Rebuilt a minimal demo project using identical UITabBarAppearance code The minimal demo renders correctly. The production application renders with a much more opaque gray background. Question Has anything changed in the Liquid Glass compositor or backdrop sampling behavior in iOS 27 Beta 4? Is there any new API or recommended configuration required to achieve the same transparency level as iOS 26.5? If this is expected behavior, is there any supported way to control the opacity of the system Liquid Glass material? Screenshots Attach: iOS 26.5 screenshot iOS 27 Beta 4 screenshot
1
0
161
9h
visionOS 26: is there any way yet to distinguish a user-initiated window close from system out-of-FoV backgrounding
This was confirmed as a framework gap in an accepted answer from an Apple Vision Pro engineer in June 2024 (https://developer.apple.com/forums/thread/758014?answerId=792769022#792769022): .background fires identically whether the user taps a window's close button or the system backgrounds a window that's been out of the field of view for ~61 seconds, and there's no app-visible signal that distinguishes the two. The recommendation at the time was to use a gesture/affordance to reopen the window, and to file an enhancement request. Two years on, with the window-management APIs that have shipped since, I want to confirm whether the situation has changed as of visionOS 26. My case: VisionBlazer, a native spatial 3D creation tool (TestFlight beta, August 2026 launch). Users routinely work with several SwiftUI WindowGroup tool windows open at once — drawing tools, materials, timeline, properties, lighting — parked spatially around an ImmersiveSpace. Parking a window behind or beside you is core to the workflow. The app should terminate when the user closes the primary window, but must not terminate when a secondary window (or the primary) is simply parked out of view. What I've verified on-device (visionOS 26.5): scenePhase == .background fires identically for a user close tap and for the ~61s out-of-FoV backgrounding (SurfBoard: "…is out of FOV after 60.99 seconds. Backgrounding"). The phase sequence (active → inactive → background) and timing (~0.2–0.4s gap) are indistinguishable between the two cases. scenePhase on visionOS reflects visibility, not focus — a parked window stays .active while the user edits elsewhere, until the out-of-FoV timer fires. The session identifier reachable from the window's view hierarchy (view.window!.windowScene.session.persistentIdentifier) never matches the identifier reported by application(_:didDiscardSceneSessions:) or UIScene.didDisconnectNotification for that same close. The view-visible session stays in UIApplication.shared.openSessions indefinitely after the close. Those disconnect/discard callbacks arrive ~10–15s late and only ever carry foreign session identifiers, so they can't be attributed to a specific window. Stale-session discards from prior launches pollute the signal further. onDisappear does not fire on user close. Five strategies tried, all failed: (1) scene-object identity captured at didMoveToWindow; (2) session.persistentIdentifier matching against openSessions; (3) live re-capture of scene/session from the view hierarchy on every lifecycle change; (4) temporal correlation of didEnterBackground/didDisconnect; (5) a focus-recency heuristic on scenePhase transitions. All fail on the identifier mismatch and the visibility-not-focus semantics above. Questions: As of visionOS 26, is there now any supported way to detect that the user intentionally closed a specific window, distinct from system backgrounding? Is there a SwiftUI or scene-delegate callback tied to a window's own scene that fires only on user close? Is there a dismissalReason (or equivalent) anywhere on the close path? If none of the above exists, is an explicit in-app Quit button still the intended pattern for "quit when the main window is closed"? I have a focused test project reproducing all of this and can link it. Thanks.
6
0
850
13h
Limits to Apple Messaging
I’m developing an app (well, Claude Code is doing the Swift work) that has a need to send SMS messages on a regular basis. It’s an app that sends location information to a third party, via SMS, in case the user goes missing. Claude is telling me that the user has to hit send for every message. Claude also says there’s no way for the app to know if a message was successfully sent. It only knows that it was queued in Messenger but not that it was actually successful in sending. In the Android port we don’t have those restriction, apparently. The Android app can send messages without the users involvement (after granting permission ahead of time). The Android app can also query as to whether the send was successful, and optionally retry the send when it wasn’t. The advantage of not having the user needing to hit send ’Send’ and being able to determine if the queued send was successfully sent is an increase in reliable location information being received by the recipient. My questions are whether Claude Code is correct in what iOS allows, and if there’s an alternate approach. I understand the security concern with sending messages the user didn’t explicitly approve for each message but I’m wondering if Apple is considering an implementation mechanism that approaches Android (ie: approve message sending without per-message authorization) and the ability to check if a queued message was successfully sent. Thanks.
0
0
225
1d
Why does an edited 4K 60 FPS video become significantly smaller than the original when exported from the Photos library?
I'm observing an interesting behavior on iOS when uploading edited videos from the Photos library. Scenario Device: iPhone Video: 4K, 60 FPS Original video size (Photos app): 660 MB Uploaded original asset: 660 MB After applying a simple edit (e.g., a filter) in the Photos app: Photos app still shows the edited video. When my app uploads the current/edited asset, the uploaded file size becomes 167 MB. So the edited version is approximately 75% smaller than the original (660 MB → 167 MB), even though the duration appears unchanged. Questions Is this expected behavior for edited videos in the Photos library? Does iOS automatically re-encode edited videos using a lower bitrate or a different codec (e.g., HEVC) when generating the current rendition? Does the Photos app continue to display the size of the original asset rather than the size of the edited rendition? I'm aware that PhotoKit allows retrieving both the original and the current (edited) versions of a PHAsset. In this case, I'm intentionally retrieving the current version, and this behavior is observed only for the edited asset.
1
0
255
1w
Images in segmentedControl segments do not draw properly
This is UIKit app, in Xcode 26.3 (but same issue in 16.4). I create (in IB) a segmentedControl, with 2 segments. I set the images that are stored in assets. They show properly in Xcode. But when running (26.1 simulator), they just show a black image. In Xcode                                                                           On simulator at runtime I've tried to set background to clear as well as tint, to no avail. What am I missing ?
0
0
151
1w
SwiftUI, macOS, PDFView, The "Remove Highlight" context menu does not work
I'm using PDFKitView: NSViewRepresentable to present the pdf page in SwiftUI. Seems we already have some useful built-in functions in the context menu. However, the highlight manipulation functions are not functional - I can neither delete the highlight annotation nor change the color/type of the current pointed highlight annotation. The "Add Note" and other page display changing functions work well.
2
1
1.1k
2w
Best practices
Hi everyone, I'm Alexsander. My friends call me Lexie. I have been working as software developer since 6 years ago, I have a lot of experience with Java and I started working with Angular since the last year. I am new in the Apple ecosystem and I have a question about best practices in full native Swift apps. There is any source (blogs, youtube channels, books, et al.) where I can understand the best practices? Like, I've heard about MVVM to scalable apps but I don't know exactly how to apply it. I think it's because usually I do not have my front-end components in the same project of my backend. I've been watching some videos from Apple Developer youtube channel and they are absolutely amazing, but they only keep teaching people to use the "raw" resources, not matching with the best practices. For example, I saw using swift data we do not need to write any SQL Query, unlike Java Ecossystem where even we use a ORM we usually write our queries natively, whether creating a table or fetching data.
0
0
232
2w
ES event thread playing nicely with Swift Concurrency
We're working on an Endpoint Security extension and using Swift 6 with Concurrency. I've heard there are some subtleties to getting the threading right across those two domains and am hoping that someone can help shed light on it. In particular, ES events can be delivered on a high priority thread and I'd like to be sure that any work done in the Concurrency domain retains that priority to minimize latency between event delivery and response.
2
0
401
2w
Add a value to the Photos Caption field
In the iOS Photos app there is a caption field the user can write to. How can you write to this value from Swift when creating a photo? I see apps that do this, but there doesn't seem to be any official way to do this using the Photo library through PHAssetCreationRequest or PHAssetResourceCreationOptions or setting EXIF values, I tried settings a bunch of values there including IPTC values but nothing appears in the caption field in the iOS photos app. There must be some way to do it since I see other apps setting that value somehow after capturing a photo.
2
1
449
2w
HomeKit support on MacOS
I am currently developing an app for MacOS that needs to control HomeKit devices like lights. However, it seems like MacOS is supported on the official documentation, but not when I try to create an app ID on developer.apple.com. On the link https://developer.apple.com/apple-home/, MacOS is clearly showed as supported for MacOS. But when I try to create an app ID, it shows that it is only compatible for iOS, VisionOS and WatchOS. Could this be clarified? Best regards, orangeidle25
6
0
1.2k
2w
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?
1
5
531
3w
Xcode 27: spike in "Class X is implemented in both" warnings
Anyone else seeing a lot more "Class X is implemented in both ..." warnings on Xcode 27 than on Xcode 26? Same source, same flags, the count goes from a handful to a couple thousand, and some now correlate with real crashes (cast failures, missing protocol conformances) instead of the usual harmless first-wins behavior. Is this a known change in Swift 6.4 / Xcode 27? Is there a new flag I should be passing? Any suggestions welcome.
5
0
603
3w
preferredLanguages incorrectly read in iOS 26.1 simulators ?
I have to use the user preferred language (the first, here French). In didFinishLaunchingWithOptions, I select the first in the array of languages. print(#function, Locale.preferredLanguages) let prefLanguage = Locale.preferredLanguages.count > 0 ? Locale.preferredLanguages[0] : "en" So I expect to get Français. That works OK in iOS 16 (both on device and simulator) as well as on iPad iOS 26, but not on iOS 26.1 simulator. log for iOS 16 simulator or on devices: application(_:didFinishLaunchingWithOptions:) ["fr-FR", "en-FR", "es-FR", "it-FR", "de-FR", "el-FR"] log for iOS 26 (Xcode 26.3) application(_:didFinishLaunchingWithOptions:) ["en-FR", "fr-FR", "es-FR", "de-FR", "it-FR", "el-FR"] Order is changed. Is this a known bug or am I missing something ?
1
0
462
3w
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?
2
0
279
3w
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.
4
2
655
4w
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
376
4w
关于我使用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
455
4w
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
1
683
4w
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
3.1k
Activity
Oct ’25
iOS 27 Beta 4: Native Liquid Glass UITabBar renders with opaque milky/frosted background while identical code renders correctly on iOS 26.5
iOS 27 Beta 4: Native Liquid Glass UITabBar renders with opaque milky/frosted background while identical code renders correctly on iOS 26.5 Environment Xcode 27 Beta 4 iOS 27 Beta 4 UIKit UITabBarController Storyboard based application Native UITabBar (no custom tab bar implementation) Device: iPhone 17 Pro Simulator (also reproducible on other iPhone simulators) Problem After upgrading to iOS 27 Beta 4, the native Liquid Glass tab bar appears significantly more opaque (milky/frosted gray) than on iOS 26.5. The exact same application binary and configuration render correctly on iOS 26.5. No custom blur or visual effect is being applied. Current Configuration let appearance = UITabBarAppearance() appearance.configureWithDefaultBackground() appearance.backgroundColor = nil appearance.backgroundEffect = nil appearance.shadowColor = .clear tabBar.standardAppearance = appearance tabBar.scrollEdgeAppearance = appearance tabBar.isTranslucent = true tabBar.backgroundColor = nil tabBar.barTintColor = nil tabBar.backgroundImage = nil tabBar.shadowImage = nil Runtime Verification Verified at runtime: tabBar.backgroundColor == nil tabBar.barTintColor == nil tabBar.isTranslucent == true standardAppearance.backgroundColor == nil standardAppearance.backgroundEffect == nil scrollEdgeAppearance.backgroundColor == nil scrollEdgeAppearance.backgroundEffect == nil View Hierarchy The runtime hierarchy contains Apple's native Liquid Glass implementation: UITabBar _UIBarItemPlatterView _UILiquidLensView BackdropView ClearGlassView _UIPortalView _UITabSelectionView Therefore UIKit is using the Liquid Glass implementation rather than falling back to a legacy blur. Investigation Performed The following were tested without changing behavior: Removed all custom blur views Removed custom overlays Removed refresh/recomposition code Removed layout invalidation Removed transform hacks Removed PageMenu Replaced entire first tab with a plain UITableViewController Replaced DiscoverVC completely Replaced nested collection views Rebuilt a minimal demo project using identical UITabBarAppearance code The minimal demo renders correctly. The production application renders with a much more opaque gray background. Question Has anything changed in the Liquid Glass compositor or backdrop sampling behavior in iOS 27 Beta 4? Is there any new API or recommended configuration required to achieve the same transparency level as iOS 26.5? If this is expected behavior, is there any supported way to control the opacity of the system Liquid Glass material? Screenshots Attach: iOS 26.5 screenshot iOS 27 Beta 4 screenshot
Replies
1
Boosts
0
Views
161
Activity
9h
visionOS 26: is there any way yet to distinguish a user-initiated window close from system out-of-FoV backgrounding
This was confirmed as a framework gap in an accepted answer from an Apple Vision Pro engineer in June 2024 (https://developer.apple.com/forums/thread/758014?answerId=792769022#792769022): .background fires identically whether the user taps a window's close button or the system backgrounds a window that's been out of the field of view for ~61 seconds, and there's no app-visible signal that distinguishes the two. The recommendation at the time was to use a gesture/affordance to reopen the window, and to file an enhancement request. Two years on, with the window-management APIs that have shipped since, I want to confirm whether the situation has changed as of visionOS 26. My case: VisionBlazer, a native spatial 3D creation tool (TestFlight beta, August 2026 launch). Users routinely work with several SwiftUI WindowGroup tool windows open at once — drawing tools, materials, timeline, properties, lighting — parked spatially around an ImmersiveSpace. Parking a window behind or beside you is core to the workflow. The app should terminate when the user closes the primary window, but must not terminate when a secondary window (or the primary) is simply parked out of view. What I've verified on-device (visionOS 26.5): scenePhase == .background fires identically for a user close tap and for the ~61s out-of-FoV backgrounding (SurfBoard: "…is out of FOV after 60.99 seconds. Backgrounding"). The phase sequence (active → inactive → background) and timing (~0.2–0.4s gap) are indistinguishable between the two cases. scenePhase on visionOS reflects visibility, not focus — a parked window stays .active while the user edits elsewhere, until the out-of-FoV timer fires. The session identifier reachable from the window's view hierarchy (view.window!.windowScene.session.persistentIdentifier) never matches the identifier reported by application(_:didDiscardSceneSessions:) or UIScene.didDisconnectNotification for that same close. The view-visible session stays in UIApplication.shared.openSessions indefinitely after the close. Those disconnect/discard callbacks arrive ~10–15s late and only ever carry foreign session identifiers, so they can't be attributed to a specific window. Stale-session discards from prior launches pollute the signal further. onDisappear does not fire on user close. Five strategies tried, all failed: (1) scene-object identity captured at didMoveToWindow; (2) session.persistentIdentifier matching against openSessions; (3) live re-capture of scene/session from the view hierarchy on every lifecycle change; (4) temporal correlation of didEnterBackground/didDisconnect; (5) a focus-recency heuristic on scenePhase transitions. All fail on the identifier mismatch and the visibility-not-focus semantics above. Questions: As of visionOS 26, is there now any supported way to detect that the user intentionally closed a specific window, distinct from system backgrounding? Is there a SwiftUI or scene-delegate callback tied to a window's own scene that fires only on user close? Is there a dismissalReason (or equivalent) anywhere on the close path? If none of the above exists, is an explicit in-app Quit button still the intended pattern for "quit when the main window is closed"? I have a focused test project reproducing all of this and can link it. Thanks.
Replies
6
Boosts
0
Views
850
Activity
13h
Limits to Apple Messaging
I’m developing an app (well, Claude Code is doing the Swift work) that has a need to send SMS messages on a regular basis. It’s an app that sends location information to a third party, via SMS, in case the user goes missing. Claude is telling me that the user has to hit send for every message. Claude also says there’s no way for the app to know if a message was successfully sent. It only knows that it was queued in Messenger but not that it was actually successful in sending. In the Android port we don’t have those restriction, apparently. The Android app can send messages without the users involvement (after granting permission ahead of time). The Android app can also query as to whether the send was successful, and optionally retry the send when it wasn’t. The advantage of not having the user needing to hit send ’Send’ and being able to determine if the queued send was successfully sent is an increase in reliable location information being received by the recipient. My questions are whether Claude Code is correct in what iOS allows, and if there’s an alternate approach. I understand the security concern with sending messages the user didn’t explicitly approve for each message but I’m wondering if Apple is considering an implementation mechanism that approaches Android (ie: approve message sending without per-message authorization) and the ability to check if a queued message was successfully sent. Thanks.
Replies
0
Boosts
0
Views
225
Activity
1d
Turn my iPhone to silent mode via Code (Swift)
Hi All,I am working on a project to turn my iPhone to silent mode via Code (Swift), Can someone ,plz, help to put on the right direction as I am very new to Xcode and Swift.Regards
Replies
2
Boosts
0
Views
2.8k
Activity
5d
Why does an edited 4K 60 FPS video become significantly smaller than the original when exported from the Photos library?
I'm observing an interesting behavior on iOS when uploading edited videos from the Photos library. Scenario Device: iPhone Video: 4K, 60 FPS Original video size (Photos app): 660 MB Uploaded original asset: 660 MB After applying a simple edit (e.g., a filter) in the Photos app: Photos app still shows the edited video. When my app uploads the current/edited asset, the uploaded file size becomes 167 MB. So the edited version is approximately 75% smaller than the original (660 MB → 167 MB), even though the duration appears unchanged. Questions Is this expected behavior for edited videos in the Photos library? Does iOS automatically re-encode edited videos using a lower bitrate or a different codec (e.g., HEVC) when generating the current rendition? Does the Photos app continue to display the size of the original asset rather than the size of the edited rendition? I'm aware that PhotoKit allows retrieving both the original and the current (edited) versions of a PHAsset. In this case, I'm intentionally retrieving the current version, and this behavior is observed only for the edited asset.
Replies
1
Boosts
0
Views
255
Activity
1w
Images in segmentedControl segments do not draw properly
This is UIKit app, in Xcode 26.3 (but same issue in 16.4). I create (in IB) a segmentedControl, with 2 segments. I set the images that are stored in assets. They show properly in Xcode. But when running (26.1 simulator), they just show a black image. In Xcode                                                                           On simulator at runtime I've tried to set background to clear as well as tint, to no avail. What am I missing ?
Replies
0
Boosts
0
Views
151
Activity
1w
SwiftUI, macOS, PDFView, The "Remove Highlight" context menu does not work
I'm using PDFKitView: NSViewRepresentable to present the pdf page in SwiftUI. Seems we already have some useful built-in functions in the context menu. However, the highlight manipulation functions are not functional - I can neither delete the highlight annotation nor change the color/type of the current pointed highlight annotation. The "Add Note" and other page display changing functions work well.
Replies
2
Boosts
1
Views
1.1k
Activity
2w
Best practices
Hi everyone, I'm Alexsander. My friends call me Lexie. I have been working as software developer since 6 years ago, I have a lot of experience with Java and I started working with Angular since the last year. I am new in the Apple ecosystem and I have a question about best practices in full native Swift apps. There is any source (blogs, youtube channels, books, et al.) where I can understand the best practices? Like, I've heard about MVVM to scalable apps but I don't know exactly how to apply it. I think it's because usually I do not have my front-end components in the same project of my backend. I've been watching some videos from Apple Developer youtube channel and they are absolutely amazing, but they only keep teaching people to use the "raw" resources, not matching with the best practices. For example, I saw using swift data we do not need to write any SQL Query, unlike Java Ecossystem where even we use a ORM we usually write our queries natively, whether creating a table or fetching data.
Replies
0
Boosts
0
Views
232
Activity
2w
ES event thread playing nicely with Swift Concurrency
We're working on an Endpoint Security extension and using Swift 6 with Concurrency. I've heard there are some subtleties to getting the threading right across those two domains and am hoping that someone can help shed light on it. In particular, ES events can be delivered on a high priority thread and I'd like to be sure that any work done in the Concurrency domain retains that priority to minimize latency between event delivery and response.
Replies
2
Boosts
0
Views
401
Activity
2w
Add a value to the Photos Caption field
In the iOS Photos app there is a caption field the user can write to. How can you write to this value from Swift when creating a photo? I see apps that do this, but there doesn't seem to be any official way to do this using the Photo library through PHAssetCreationRequest or PHAssetResourceCreationOptions or setting EXIF values, I tried settings a bunch of values there including IPTC values but nothing appears in the caption field in the iOS photos app. There must be some way to do it since I see other apps setting that value somehow after capturing a photo.
Replies
2
Boosts
1
Views
449
Activity
2w
HomeKit support on MacOS
I am currently developing an app for MacOS that needs to control HomeKit devices like lights. However, it seems like MacOS is supported on the official documentation, but not when I try to create an app ID on developer.apple.com. On the link https://developer.apple.com/apple-home/, MacOS is clearly showed as supported for MacOS. But when I try to create an app ID, it shows that it is only compatible for iOS, VisionOS and WatchOS. Could this be clarified? Best regards, orangeidle25
Replies
6
Boosts
0
Views
1.2k
Activity
2w
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
1
Boosts
5
Views
531
Activity
3w
Xcode 27: spike in "Class X is implemented in both" warnings
Anyone else seeing a lot more "Class X is implemented in both ..." warnings on Xcode 27 than on Xcode 26? Same source, same flags, the count goes from a handful to a couple thousand, and some now correlate with real crashes (cast failures, missing protocol conformances) instead of the usual harmless first-wins behavior. Is this a known change in Swift 6.4 / Xcode 27? Is there a new flag I should be passing? Any suggestions welcome.
Replies
5
Boosts
0
Views
603
Activity
3w
preferredLanguages incorrectly read in iOS 26.1 simulators ?
I have to use the user preferred language (the first, here French). In didFinishLaunchingWithOptions, I select the first in the array of languages. print(#function, Locale.preferredLanguages) let prefLanguage = Locale.preferredLanguages.count > 0 ? Locale.preferredLanguages[0] : "en" So I expect to get Français. That works OK in iOS 16 (both on device and simulator) as well as on iPad iOS 26, but not on iOS 26.1 simulator. log for iOS 16 simulator or on devices: application(_:didFinishLaunchingWithOptions:) ["fr-FR", "en-FR", "es-FR", "it-FR", "de-FR", "el-FR"] log for iOS 26 (Xcode 26.3) application(_:didFinishLaunchingWithOptions:) ["en-FR", "fr-FR", "es-FR", "de-FR", "it-FR", "el-FR"] Order is changed. Is this a known bug or am I missing something ?
Replies
1
Boosts
0
Views
462
Activity
3w
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
2
Boosts
0
Views
279
Activity
3w
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
4
Boosts
2
Views
655
Activity
4w
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
376
Activity
4w
关于我使用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
455
Activity
4w
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
1
Views
683
Activity
4w