Swift Packages

RSS for tag

Create reusable code, organize it in a lightweight way, and share it across Xcode projects and with other developers using Swift Packages.

Posts under Swift Packages tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

joblinkapp's registerview problem
我正在使用 Core Data 开发一个 SwiftUI 项目。我的数据模型中有一个名为 AppleUser 的实体,具有以下属性:id (UUID)、name (String)、email (String)、password (String) 和 createdAt (Date)。所有属性都是非可选的。 我使用 Xcode 的自动生成创建了相应的 Core Data 类文件(AppleUser+CoreDataClass.swift 和 AppleUser+CoreDataProperties.swift)。我还有一个 PersistenceController,它使用模型名称 JobLinkModel 初始化 NSPersistentContainer。 当我尝试使用以下方法保存新的 AppleUser 对象时: 让用户 = AppleUser(上下文:viewContext) user.id = UUID() user.name = “用户 1” user.email = “...” user.password = “密码 1” user.createdAt = Date()【电子邮件格式正确,但已替换为“...”出于隐私原因】 尝试?viewContext.save() 我在控制台中收到以下错误:核心数据保存失败:Foundation._GenericObjCError.nilError, [:] 用户快照: [“id”: ..., “name”: “User1”, “email”: “...”, “password”: “...”, “createdAt”: ...] 所有字段都有有效值,核心数据模型似乎正确。我还尝试过: • 检查 NSPersistentContainer(name:) 中的模型名称是否与 .xcdatamodeld 文件 (JobLinkModel) 匹配 • 确保正确设置 AppleUser 实体类、模块和 Codegen(类定义、当前产品模块) • 删除重复或旧的 AppleUser 类文件 • 清理 Xcode 构建文件夹并从模拟器中删除应用程序 • 对上下文使用 @Environment(.managedObjectContext) 尽管如此,在保存新的 AppleUser 对象时,我仍然会收到 _GenericObjCError.nilError。 我想了解: 为什么即使所有字段都不是零且正确分配,核心数据也无法保存? 这可能是由于一些残留的旧类文件引起的,还是我缺少设置中的其他内容? 我应该采取哪些步骤来确保 Core Data 正确识别 AppleUser 实体并允许保存? 任何帮助或指导将不胜感激。
0
0
18
7h
joblinkapp's registerview mistake
I am working on a SwiftUI project using Core Data. I have an entity called AppleUser in my data model, with the following attributes: id (UUID), name (String), email (String), password (String), and createdAt (Date). All attributes are non-optional. I created the corresponding Core Data class files (AppleUser+CoreDataClass.swift and AppleUser+CoreDataProperties.swift) using Xcode’s automatic generation. I also have a PersistenceController that initializes the NSPersistentContainer with the model name JobLinkModel. When I try to save a new AppleUser object using: let user = AppleUser(context: viewContext) user.id = UUID() user.name = "User1" user.email = "..." user.password = "password1" user.createdAt = Date()【The email is correctly formatted, but it has been replaced with “…” for privacy reasons】 try? viewContext.save() I get the following error in the console:Core Data save failed: Foundation._GenericObjCError.nilError, [:] User snapshot: ["id": ..., "name": "User1", "email": "...", "password": "...", "createdAt": ...] All fields have valid values, and the Core Data model seems correct. I have also tried: • Checking that the model name in NSPersistentContainer(name:) matches the .xcdatamodeld file (JobLinkModel) • Ensuring the AppleUser entity Class, Module, and Codegen are correctly set (Class Definition, Current Product Module) • Deleting duplicate or old AppleUser class files • Cleaning Xcode build folder and deleting the app from the simulator • Using @Environment(.managedObjectContext) for the context Despite all this, I still get _GenericObjCError.nilError when saving a new AppleUser object. I want to understand: 1. Why is Core Data failing to save even though all fields are non-nil and correctly assigned? 2. Could this be caused by some residual old class files, or is there something else in the setup that I am missing? 3. What steps should I take to ensure that Core Data properly recognizes the AppleUser entity and allows saving? Any help or guidance would be greatly appreciated.
0
0
2
7h
[UIKit, SwiftUI] Document-based app hangs when document initialization throws exception
Steps to reproduce: Create a default document-based app for iOS using SwiftUI or UIKit with UIDocumentViewController. In the document loading method, simulate an error by throwing an exception, for example: throw CocoaError(.coderValueNotFound) Open the app on device/simulator running iOS 18 and attempt to open or create a new document. Expected behavior: An appropriate error message should be displayed to the user. Actual behavior: No error message is shown to the user The "Create Document" button becomes permanently disabled The app appears to hang or become unresponsive Environment: iOS 18, 26 beta 9 Both UIKit and SwiftUI implementations affected Has anyone encountered this issue or found a workaround? This seems like a regression in iOS 18's document handling. FB20189617, FB20189669
0
0
78
5d
Swift Package Manager – Support for Multiple Targets with Distinct Localization Files
I am an SDK provider working with Swift Package Manager (SPM) to deliver libraries for iOS developers. My SDK currently uses SPM targets to modularize functionality. However, SPM enforces strict resource bundling, which prevents me from efficiently offering multiple targets—each with a different set of localization files—in a single package. Current Limitation: When multiple SPM targets share the same source and resource directory but require distinct sets of .lproj localization folders (for app size or client requirements), SPM raises “overlapping sources” errors. The only workaround is to manually split resource directories or have clients prune localizations post-build, which is inefficient and error-prone. Feature Request: Please consider adding native support in Swift Package Manager for: Defining multiple targets within a single package that can process overlapping source/resource directories, Each target specifying a distinct subset of localization resource files via the exclude or a new designated parameter, Enabling efficient modular delivery of SDKs to clients needing different localization payloads, without redundant resource duplication or error-prone manual pruning. Support for this feature would greatly ease SDK distribution, lower app sizes, and improve package maintainability for iOS and all Swift platforms.
0
0
854
6d
Creating Swift Package with binaryTarget that has dependencies
How can you distribute an XCFramework via Swift Package Manager when it has dependencies on other Swift packages? We accomplished this with CocoaPods in order to distribute our closed source SDK that has dependencies, but need to migrate to SPM. Note none of the types from the dependencies are used as part of our module’s public interface - usage is purely internal. I’ve made a lot of progress following these steps for a simple example: Create Framework Project Create a new iOS Framework project in Xcode and name it WallpaperKit In the project settings select the target and verify in Build Settings that Build Libraries for Distribution is Yes then set Skip Install to No Create a new UIViewController subclass, name it WallpaperPreviewViewController, make it public, and add some functionality to it to show a UIImageView Add a new Package Dependency in the project settings, for this example we’ll use https://github.com/onevcat/Kingfisher, and specify exact version 8.5.0 Add internal import Kingfisher and use it in WallpaperPreviewViewController to download and show an image from the web Close the WallpaperKit project Create Hosting App Project (this makes it easier to develop the framework functionality and test it in an app with Xcode building both in the same workspace) Create a new iOS app project and name it WallpaperApp Create a new workspace named WallpaperApp Close the WallpaperApp project Drag and drop WallpaperApp.xcodeproj into the workspace’s sidebar Drag and drop WallpaperKit.xcodeproj into the workspace’s sidebar Switch the scheme to WallpaperKit and build Select WallpaperApp project, then with WallpaperApp target selected, in the General tab under Frameworks, Libraries, and Embedded Content, click + and add WallpaperKit.framework In ViewController.swift, import WallpaperKit and add functionality to present an instance of WallpaperPreviewViewController Run the app and verify it works Create XCFramework In Terminal, cd into WallpaperKit and run xcodebuild archive -scheme WallpaperKit -configuration Release -destination 'generic/platform=iOS' -archivePath './build/WallpaperKit.framework-iphoneos.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES DEFINES_MODULE=YES Run xcodebuild archive -scheme WallpaperKit -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath './build/WallpaperKit.framework-iphonesimulator.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES DEFINES_MODULE=YES Run xcodebuild -create-xcframework -framework './build/WallpaperKit.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/WallpaperKit.framework' -framework './build/WallpaperKit.framework-iphoneos.xcarchive/Products/Library/Frameworks/WallpaperKit.framework' -output './build/WallpaperKit.xcframework' Open the build folder and retrieve the XCFramework Create Swift Package Create a new package in Xcode, select Library, and name it WallpaperKitDist Drag and drop WallpaperKit.xcframework into Sources Create a new directory in Sources called WallpaperKitDependencies Create a new Swift file in WallpaperKitDependencies called WallpaperKitDependencies (SPM requires a Swift file to recognize WallpaperKitDependencies as a valid target and fetch dependencies) Open Package.swift and change it to import PackageDescription let package = Package( name: "WallpaperKit", platforms: [ .iOS(.v18) ], products: [ .library( name: "WallpaperKit", targets: ["WallpaperKit", "WallpaperKitDependencies"] ), ], dependencies: [ .package( url: "https://github.com/onevcat/Kingfisher.git", exact: "8.5.0" ) ], targets: [ .binaryTarget( name: "WallpaperKit", path: "./Sources/WallpaperKit.xcframework" ), .target( name: "WallpaperKitDependencies", dependencies: [ "Kingfisher" ], path: "./Sources/WallpaperKitDependencies" ) ] ) Create Test App (to simulate a third-party app using the package) Create a new iOS app project and name it TestApp Add a new Local package selecting the WallpaperKitDist directory that contains Package.swift Import WallpaperKit and use it to present a WallpaperPreviewViewController This works! Though the console logs objc[39953]: Class _TtC10KingfisherP33_6AA794C9C370CDB07604B4D8B99AEAA312BundleFinder is implemented in both /Users/Name/Library/Developer/Xcode/DerivedData/TestApp-capvhjiqxrdgdnbevpkajicnjpcs/Build/Products/Debug-iphonesimulator/WallpaperKit.framework/WallpaperKit (0x100e8bbf8) and /Users/Name/Library/Developer/CoreSimulator/Devices/E0AF13C2-874C-47B9-B864-72AF3E4D5D4B/data/Containers/Bundle/Application/AF32011A-92E7-4E26-9A97-9F0C25C07863/TestApp.app/TestApp.debug.dylib (0x101a543b0). This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed. I thought using internal import Kingfisher (or @_implementationOnly import Kingfisher) would have resolved this, but seems to make no difference compared to just import Kingfisher. I suspect it might not be an issue as long as the Kingfisher version number specified in the distribution Package.swift matches the version used in the framework project (and the app does not add a different version as a dependency), but not positive. Can these warnings be resolved, or is it not a concern in this setup? Is this the best solution to distribute an XCFramework via Swift Package Manager that has dependencies on other Swift packages for now or is there a better approach? Thanks!
0
0
98
1w
Xcode and runtime mismatch error
I keep getting "iOS 18.5 must be installed": dialoge box and when i try downloding 18.5 it fail Download failed. Domain: DVTDownloadableErrorDomain Code: 41 User Info: { DVTErrorCreationDateKey = "2025-08-24 20:40:42 +0000"; } Download failed. Domain: DVTDownloadableErrorDomain Code: 41 Failed fetching catalog for assetType (com.apple.MobileAsset.iOSSimulatorRuntime), serverParameters ({ RequestedBuild = 22G86; }) Domain: DVTDownloadsUtilitiesErrorDomain Code: -1 Download failed due to a bad URL. (Catalog download for com.apple.MobileAsset.iOSSimulatorRuntime) Domain: com.apple.MobileAssetError.Download Code: 49 User Info: { checkConfiguration = 1; } System Information macOS Version 15.5 (Build 24F74) Xcode 16.4 (23792) (Build 16F6) Timestamp: 2025-08-24T21:40:42+01:00
2
1
154
2w
Swift Package Fails iOS Validation
My app (called "MuVis - Music Visualizer") passes the macOS App Store verification, but is failing the iOS verification. The errors indicate a problem with the Swift package github.com/Treata11/CBass.  I have been in touch with the CBass package developer (Treata11) as well as the original BASS developers (un4seen.com).  We think the problem is related to CBass swift-package config (which apparently works fine for mac, but doesn’t for iOS). The source code for the package is at the site package.  All of us think that the package is configured correctly in accordance with the latest Apple package development documentation.  Please tell us what is wrong with this package, and how to make it pass the iOS App Store verification. The Xcode error messages from validation testing include several items similar to: Upload Symbols Failed: inline-code The archive did not include a dSYM for the bass.framework with the UUIDs [18D5DBE2-3250-3EDE-B75C-D81B4E9F05AC, A88554A0-9087-3776-AC05-424B2D52F973, DEB682F5-ABBE-39D5-A0F8-8C01C14E178A]. Ensure that the archive's dSYM folder includes a DWARF file for bass.framework with the expected UUIDs. Since the MuVis app is long and complex, I have written a minimal reproducible example app (called "SwiftCBassDemo") for which source code is available at DemoApp. I am using macOS 15.6.1, Xcode 16.4, and iOS 18.6.2.
1
0
102
2w
Manipulation stops working when changing rooms
This post documents an issue I reported in feedback FB19610114 and see if anyone knows of a workaround. Here is a copy of the feedback. Short version Manipulation (SwiftUI OR RealityKit) fails to translate entities after changing rooms. By changing rooms, I mean a human wearing an Apple Vision Pro leaving one room and entering another room. Once this issue occurs, it impacts all apps that use these features. A device restart is the only solution I have to fix it. Feedback FB19610114 This is an odd one. I'm using the new Manipulation Component in visionOS 26. Most of the time this works well. Sometime it stops working and when it does the only way to get it working again is to reboot the headset. When this happens, I can continue to rotate and scale items, but translation no longer works. It is as if the item is stuck to a fixed point in the parent scene (window, volume, etc). When this bug occurs, it affects every app across the entire operating system that is using manipulation, including the RealityKit component AND the SwiftUI version. This is not limited to one app and is not limited to apps that I am working on. Once this error occurs, it affects literally any application across the operating system that is using this API, including apps from Apple. I won't speculate on the cause of this, but I do know of one way where I can always get it to happen. Here is how to reproduce it: Make an Xcode project with a single entity that uses the Manipulation Component. There is no need to customize the configuration of this component. The default implementation will work. Build and run this app on device. You can keep running from device or quit and launch the app like normal on device. Open the app and manipulate the entity - it should work as expected. Physically walk into another room. It is vital that you leave the current room that you are in and enter a different room entirely. Use the digital crown to recenter your view and bring your window or volume to you. Test the manipulation on the entity again - it should still be working as expected at this point. Physically, move yourself and your headset into the original room where you started. Use the digital crown to recenter your view and bring your window or volume to you. Test the manipulation on the entity again - you should now see the issue. When I follow the steps above, then 100% of the time manipulation translation stops working at this point. It will impact any application using this API. The only way to fix it is to restart my headset. A few points to keep in mind It does not matter if an app is actively being run from Xcode. When this occurs, it impacts every single app, not just one. When this occurs, rotation and scaling continue to work, but the entity/view cannot be translated. This impacts BOTH the SwiftUI version and the RealityKit version. When this occurs, the only way to "fix" it is to reboot the device.
1
3
132
1w
Xcode 26 beta 5 xcodebuild crash
Good day! When your project have total 887 or more SPM local targets and then you try to build it, xcodebuild will be crash. Crash log: SWBBuildService-2025-08-11-151103.ips Thread 2 Crashed:: Dispatch queue: com.apple.root.default-qos.cooperative 0 libxpc.dylib 0x197c4826c _availability_version_check + 8 1 libswiftCore.dylib 0x1a9b44428 __isPlatformVersionAtLeast + 92 2 libswiftCore.dylib 0x1a9a6e054 _swift_allocObject_ + 1100 3 SWBMacro 0x104a9c408 specialized _ArrayBuffer._consumeAndCreateNew(bufferIsUnique:minimumCapacity:growForAppend:) + 116 4 SWBMacro 0x104a97b58 specialized Array.append<A>(contentsOf:) + 116 5 SWBMacro 0x104a954e8 MacroEvaluationProgram.executeInContext(_:withResultBuilder:alwaysEvalAsString:) + 160 6 SWBMacro 0x104a96548 MacroEvaluationProgram.executeInContext(_:withResultBuilder:alwaysEvalAsString:) + 4352 7 SWBMacro 0x104a96548 MacroEvaluationProgram.executeInContext(_:withResultBuilder:alwaysEvalAsString:) + 4352 8 SWBMacro 0x104a96548 MacroEvaluationProgram.executeInContext(_:withResultBuilder:alwaysEvalAsString:) + 4352 9 SWBMacro 0x104a96548 MacroEvaluationProgram.executeInContext(_:withResultBuilder:alwaysEvalAsString:) + 4352 10 SWBMacro 0x104a96548 MacroEvaluationProgram.executeInContext(_:withResultBuilder:alwaysEvalAsString:) + 4352 But if you try to build Package.swift via swift build command, it works. Here you can open sample project: Just Package.swift with SPM 900 targets Open Package.swift via Xcode 26 any beta and try to build Xcode workspace with SPM 900 targets Open MyApp.xcworkspace and try to build You can also make by self the Package.swift (also make required directories for SPM): // swift-tools-version: 5.9 import PackageDescription // let count = 800 // no crash let count = 900 // crash let targetsNames = (1...count).map { "Pkg1Target\($0)" } let targets = targetsNames.map { Target.target(name: $0) } let package = Package( name: "Pkg1TargetLibrary", platforms: [.iOS(.v16)], products: [ .library(name: "Pkg1TargetLibrary", targets: targets.map(\.name)), ], targets: targets )
4
0
169
3w
NavigationSplitView content column renders list in plain style – even on iPhone
Hi everyone, I’m building an iOS app that originally targeted iPhone using NavigationStack. Now I’m adapting it for iPad and switched to using NavigationSplitView to support a three-column layout. The structure looks like this: NavigationSplitView { A // Sidebar } content: { B // Middle column – this shows a list } detail: { C // Detail view } The issue is with the list shown in view B (the content column). It appears completely unstyled, as if it’s using .listStyle(.plain) — with no background material, and a very flat look. I can understand that this might be intentional on iPad to visually distinguish the three columns. However, the problem is that this same unstyled list also appears on iPhone, even though iPhone only shows a single column view at a time! I tried explicitly setting .listStyle(.insetGrouped) or .listStyle(.grouped) on the list in view B, but it makes no difference. When I go back to NavigationStack, the list in B is styled properly, just as expected — but then I lose the enhanced iPad layout. What I’m looking for: I’d like to keep using NavigationSplitView, but I want the list in the content column (view B) to use the default iOS list styling, at least on iPhone. Is there any way to achieve this? Thanks!
0
0
47
Aug ’25
linking error file cannot be open()ed, errno=2
I have been learning from the Apple Developer tutorials and I got stuck on the ScoreKeeper chapter with Testing. Since my Macbook Pro 2017 can only use Xcode 15.2 as the highest level, I am having issues with it. I saw a forum post that a certain level of Swift and the tool chain would fix this. I attempted to install Swift 5.10.1 to then realize I only had Xcode 15.2 not 15.3, so I had to attempt to install Swift 5.9. Since neither option worked, I uninstalled Xcode and removed any extra files along with swift packages, minus my projects, to redownload and reinstall Xcode 15.2. Now I am having issues with building the scheme, and I get link error,s and they pertain to Swift 5.10.1, which I had not installed any Swift packages after the Xcode reinstallation. I have tried another previous project even a new one same error. This was 7/30/25, as of today 7/31 I tried to install Swift 5.9 thinking it would overwrite or "downgrade" the package, no such luck. The file path in the error stops at the /.../...RELEASE.pkg file and does not continue, which seems to be the issue of the error. How to I fix this issue, I had a working product 3 dyas ago
2
0
89
Aug ’25
Autofill Extension can't find bundle while the main app can
I have a Swift Package, it's added to both the main app and the autofill extension. The main app is an iOS app that run directly on my mac from Xcode. I use this extension to access the bundle import Foundation import OSLog class CurrentBundleFinder {} extension Foundation.Bundle { static let myModule: Bundle = { /* The name of your local package, prepended by "LocalPackages_" */ let bundleName = "DesignSystem_DesignSystem" let logger = Logger(subsystem: "DesignSystem", category: "Bundle") logger.error("Searching for bundle: \(bundleName)") let candidates = [ /* Bundle should be present here when the package is linked into an App. */ Bundle.main.resourceURL, /* Bundle should be present here when the package is linked into a framework. */ Bundle(for: CurrentBundleFinder.self).resourceURL, /* For command-line tools. */ Bundle.main.bundleURL, /* Bundle should be present here when running previews from a different package (this is the path to "…/Debug-iphonesimulator/"). */ Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent(), /* For app extensions - look in parent app bundle */ Bundle.main.bundleURL.deletingLastPathComponent().deletingLastPathComponent(), ] logger.error("all bundle: \(candidates, privacy: .public)") for (index, candidate) in candidates.enumerated() { logger.error("Checking candidate \(index): \(candidate?.absoluteString ?? "nil", privacy: .public)") let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle") logger.error("Bundle path: \(bundlePath?.absoluteString ?? "nil", privacy: .public)") if let bundle = bundlePath.flatMap(Bundle.init(url:)) { logger.error("Successfully found bundle at: \(bundlePath?.absoluteString ?? "unknown", privacy: .public)") return bundle } } logger.error("Unable to find bundle named \(bundleName)") fatalError("unable to find bundle named \(bundleName)") }() } Bellow is the log from the main app and the autofill extension log.txt I have check that /private/var/folders/cb/fctmx0_x3_dbxy_9wnm7g0s40000gn/X/1CC84EBB-DAC0-5120-9346-5EFBC8691CF1/d/Wrapper/Proton Pass.app/PlugIns/AutoFill.appex/DesignSystem_DesignSystem.bundle exist in the file system, but the autofill extension is unable to create a bundle from that
1
0
76
Jul ’25
swift package with arm64e
I use spm manage swift package, now i want my macos app support arm64e,so i add arm64e in Build Srtting -> Architectures. but i got error Could not find module 'SwiftyJSON' for target 'arm64e-apple-macos'; found: arm64-apple-macos, x86_64-apple-macos Apparently, if no limit in Package.swift, SPM will only compile versions for x86 and ARM64 architectures by default. now, how should I configure SPM to compile the arm64e version? thanks
4
0
212
2w
Module compiled with Swift 6.0.3 cannot be imported by the Swift 6.1 compiler
Module compiled with Swift 6.0.3 cannot be imported by the Swift 6.1 compiler: /private/var/tmp/_bazel_xx/8b7c61ad484d9da1bf94a11f12ae6ffd/rules_xcodeproj.noindex/build_output_base/execroot/main/CustomModules/BIYThred/CocoaLumberjack/framework/CocoaLumberjack.framework/Modules/CocoaLumberjack.swiftmodule/arm64-apple-ios.swiftmodule
1
0
678
Jul ’25
Entities moved with Manipulation Component in visionOS Beta 4 are clipped by volume bounds
In Beta 1,2, and 3, we could pick up and inspect entities, bringing them closer while moving them outside of the bounds of a volume. As of Beta 4, these entities are now clipped by the bounds of the volume. I'm not sure if this is a bug or an intended change, but I files a Feedback report (FB19005083). The release notes don't mention a change in behavior–at least not that I can find. Is this an intentional change or a bug? Here is a video that shows the issue. https://youtu.be/ajBAaSxLL2Y In the previous versions of visionOS 26, I could move these entities out of the volume and inspect them close up. Releasing would return them to the volume. Now they are clipped as soon as they reach the end of the volume. I haven't had a chance to test with windows or with the SwiftUI modifier version of manipulation.
1
4
350
Jul ’25
Windows-specific timeout issue with URLSession in Swift (Error Code -1001)
Hello everyone, 👋🏼🤠 I've been struggling with a persistent issue for several weeks and would greatly appreciate any insights or suggestions from the community. ❗️Problem Summary We are sending JSON requests (~100 KB in size) via URLSession from a Swift app running on Windows. These requests consistently time out after a while. Specifically, we receive the following error: Error Domain=NSURLErrorDomain Code=-1001 "(null)" This only occurs on Windows – under macOS and Linux, the same requests work perfectly. 🔍 Details The server responds in under 5 seconds, and we have verified that the backend (a Vapor app in Kubernetes) is definitely not the bottleneck. The request always hits the timeout interval, no matter how high we configure it: 60, 120, 300, 600 seconds – the error remains the same. (timeoutForRequest) The request flow: Swift App (Windows) ---> HTTPS ---> Load Balancer (NGINX) ---> HTTP ---> Ingress Controller ---> Vapor App (Kubernetes) On the load balancer we see this error: client prematurely closed connection, so upstream connection is closed too (104: Connection reset by peer) The Ingress Controller never receives the complete body in these error cases. The content length set by the Swift app exceeds the data actually received. We disabled request buffering in the Ingress Controller, but the issue persists. We even tested a setup where we inserted a Caddy server in between to strip away TLS. The Swift app sent unencrypted HTTP requests to Caddy, which then forwarded them. This slightly improved stability but did not solve the issue. 🧪 Additional Notes The URLSession is configured in an actor, with a nonisolated URLSession instance: actor DataConnectActor { nonisolated let session : URLSession = URLSession(configuration: { let urlSessionConfiguration : URLSessionConfiguration = URLSessionConfiguration.default urlSessionConfiguration.httpMaximumConnectionsPerHost = ProcessInfo.processInfo.environment["DATACONNECT_MAX_CONNECTIONS"]?.asInt() ?? 16 urlSessionConfiguration.timeoutIntervalForRequest = TimeInterval(ProcessInfo.processInfo.environment["DATACONNECT_REQUEST_TIMEOUT"]?.asInt() ?? 120) urlSessionConfiguration.timeoutIntervalForResource = TimeInterval(ProcessInfo.processInfo.environment["DATACONNECT_RESSOURCE_TIMEOUT"]?.asInt() ?? 300) urlSessionConfiguration.httpAdditionalHeaders = ["User-Agent": "DataConnect Agent (\(Environment.version))"] return urlSessionConfiguration }()) public internal(set) var accessToken: UUID? = nil ... } Requests are sent via a TaskGroup, limited to 5 concurrent tasks. The more concurrent tasks we allow, the faster the timeout occurs. We already increased the number of ephemeral ports in Windows. This made things slightly better, but the problem remains. Using URLSessionDebugLibcurl=1 doesn't reveal any obvious issue related to libcurl. We have also implemented a retry mechanism, but all retries also time out. 🔧 Request Flow (Code Snippet Summary) let data = try JSONEncoder().encode(entries) var request = URLRequest(url: url) request.httpMethod = "POST" request.httpBody = data request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") request.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type") // additional headers... let (responseData, response) = try await urlSession.data(for: request) ✅ What We’ve Tried Tested with and without TLS Increased timeout and connection settings Disabled buffering on Ingress Increased ephemeral ports on Windows Limited concurrent requests Used URLSessionDebugLibcurl=1 We don't know how we can look any further here. Thank you in advance for any guidance!
2
0
186
Jul ’25
TabView + NavigationStack + ScrollView navigationTitle bug
Hello there! I've been struggline with this thing for a two days now, and seems like it's a bug in SwiftUI. Navigation title is jumping on top of the ScrollView's content when switching tabs in TabView. Steps to reproduce: Scroll one tab to the bottom so that the large title is hidden and the floating toolbar appears. Go to another tab in the tab bar. Go back to the initial tab (it is still scrolled), and press the current tab button again to scroll to the top. The navigation title will glitch and be on top of the content. The animation fixes if you scroll again manually. Video: https://share.cleanshot.com/PFCSKMlH Code (simplified): import SwiftData import SwiftUI @main struct MyApp: App { var body: some Scene { WindowGroup { TabsContentView() } } } // ... struct TabsContentView: View { enum Tab { case library, profile } @State private var selectedTab: Tab = .library var body: some View { TabView(selection: $selectedTab) { NavigationStack { YourLibraryList() .navigationTitle("Your Library") } .tabItem { Label("Library", systemImage: "tray.fill") } .tag(Tab.library) NavigationStack { VStack { Spacer() Text("Profile") .font(.largeTitle) .foregroundColor(Color.theme.text) Text("Manage your account and preferences here") .font(.body) .foregroundColor(Color.theme.mutedForeground) .multilineTextAlignment(.center) .padding(.horizontal) Spacer() } .navigationTitle("Explore") } .tabItem { Label("Profile", systemImage: "person.fill") } .tag(Tab.profile) } .toolbarBackground(.ultraThinMaterial, for: .tabBar) .toolbarBackground(.visible, for: .tabBar) } } // ... struct YourLibraryList: View { var body: some View { ScrollView { VStack(spacing: 12) { ForEach(1 ... 20, id: \.self) { number in RoundedRectangle(cornerRadius: 12) .fill(Color.blue.opacity(0.1)) .stroke(Color.blue, lineWidth: 1) .frame(height: 60) .overlay( Text("\(number)") .font(.title2) .fontWeight(.semibold) .foregroundColor(.blue) ) } } .padding(.horizontal) } } }
2
0
203
Jul ’25