Search results for

Swift 6

49,197 results found

Post

Replies

Boosts

Views

Activity

Reply to iOS folder bookmarks
I figured out some further details: when I get a file or folder URL from the picker I need to call startAccessingSecurityScopedResource on it first prior to converting it to bookmark. If I don't do that and try to convert that URL to bookmark I am seeing this error in the console: [ERROR] getattrlist(/7{34}3/D{7}s/2{8}2/N{2}1/0{8}7/1{6}3/2{69}0.png) = 1 however the call to make bookmark: url!.bookmarkData(options: [], includingResourceValuesForKeys: nil, relativeTo: nil) doesn't return an error. For a folder URL it's even less visible: no error from the call (same as for file URL) but also nothing in the console as a hint. Later on (perhaps on a different lunch) when I read a bookmark (file or folder) I don't need to call startAccessingSecurityScopedResource on it (not sure if that's intentional behaviour or not).
Topic: App & System Services SubTopic: Core OS Tags:
2w
Reply to Icon Composer: Any way to add icons to the app bundle for older macOS versions?
Amazing! Thanks @superpixel! Adding the secret undocumented --enable-icon-stack-fallback-generation=disabled to the ASSETCATALOG_OTHER_FLAGS build setting does work on Xcode 26 beta 6. What I do is enable this, disable Include all app icon assets and copy a separately compiled AppIcon.incs (with the legacy icons) to the Resources folder while making sure the CFBundleIconFile is in the Info.plist pointing to this file - this results in the correct icon showing up on older macOS versions, while Tahoe uses the Icon Composer variant. This should work on macOS (not sure if works for App Store, but my app is not an App Store app, so it does not matter). An other way is to have Include all app icon assets which generates the proper variants in Assets.car, but it bloats the bundle size somewhat (especially as I have some assets that depend on build configuration and this option makes all those into the bundle) - this might be the proper way though. Hope Apple fixes this properly though or add least adds a pr
2w
Invalid large app icon with Xcode 26 beta 6
I’m having a bit of trouble uploading my new icon to the App Store Connect. I created it entirely with Icon Composer, but it keeps throwing an error saying it’s an “Invalid large app icon.” The error message says that the large app icon in the asset catalog can’t be transparent or have an alpha channel. I only have one AppIcon in the asset catalog, and I’ve checked the “single size” option, which is set to 1024x1024 for any, dark, or tinted size. In the past, when I used the previous icon with the iOS 18 SDK, I didn’t have any issues uploading it. However, when I created the new icon with Icon Composer and compiled it with Xcode Beta, it broke. I’m a bit confused because the error message suggests that removing transparency is the solution, but the whole point of Icon Composer is to make the icon transparent for the new liquid glass design. I don’t want to remove the cool look that my new transparent icon has. Could you please help me out? I’d really appreciate it. Thanks a bunch!
2
0
122
2w
Unity GameKit plugin beta GameKit Activity UnsupportedOperationForOSVersion
I’m running into unexpected problems with the Unity GameKit plugin setup with the new Activities. I didn’t see anyone else mentioning these issues, so my guess is that it’s a problem with my setup. The authentication (GKLocalPlayer.Authenticate()) works as expected, but any call to the new GameActivity functionality (e.g. GKGameActivityDefinition.LoadGameActivityDefinitions() or GKGameActivity.WantsToPlay) gives me an exception with a 'UnsupportedOperationForOSVersion' reason despite it running on an iOS 18.6.1 device. I’m using a completely empty Unity 2022.3.62f1 project that only contains the official authentication example, followed by an event handler for activities from another example and the Unity core and gamekit plugins. The setup: macOS 15.6 Xcode 26 beta 6 (also tried with 5) Physical iPhone device running iOS 18.6.1 Unity 2022.3.62f1, which satisfies the requirements Unity plugin, Xcode setup, and build steps: I Followed the official beta branch build steps for Unity plugins with python3
2
0
411
2w
Reply to Managing the order of Transparent Proxies from MDM Profile
[quote='854958022, KrishnaveniNalka, /thread/796810?answerId=854958022#854958022, /profile/KrishnaveniNalka'] If I install the Transparent Proxy or VPN payload MDM profile first [/quote] OK, but why are you doing things in that order? If I were investigating this issue, I’d do the following: Create a trivial container app A with a dummy transparent proxy PA. Set the handle-new-flow method to log the flow details and return false. Clone the app to form container app B with dummy transparent proxy PB. Install both on the Mac. Activate both of their system extensions, but don’t install any network configurations. Push an MDM proxy with a configuration for PA and PB, and the Order property set on both. Do some networking. Remove that configuration. Repeat step 6 with the Order property reversed. Do some more networking. The log entries from steps 7 and 10 will tell you whether the Order property is doing its job. This will either work on not. If it doesn’t work then you’ve clearly isolated the problem an
2w
Reply to SwiftData Fatal error: Editors must register their identifiers before invoking operations on this store
@DTS Engineer thank you for these suggestions. I've added the full crash report from Crashlytics to this post. After enabling the launch argument you suggested, I managed to reproduce the crash in the debugger once, so that's some progress. After enabling Swift 6 and complete concurrency checking, I got some build errors in the class owning the ModelActor. Wherever I accessed the ModelActor, I got this error: Sending 'self.localStorage.some' risks causing data races. As mentioned in my original post, the ModelActor conforms to a protocol because I am using another type of storage in iOS 16 which doesn't support SwiftData. This protocol didn't require that conforming types were Actors, leading me to suspect that the class owning the ModelActor didn't treat it as an actor, because it only know about the protocol. Adding the Actor requirement to the protocol, removed the build errors in the owning class. Now, I have to ship this change to confirm that it actually fixes it, since I cannot reliably reprod
2w
The tag displayed in native webview does not work in iPadOS 26 Beta
I'm creating an iPad app using Xcode 26 Beta 6. I have the following simple code and web page, but when I tap the file selection button, nothing appears. Do I need to add any additional code? code struct SwiftUIWebView: View { @State private var webPage = WebPage() private let url = URL(string: https://www.xxxx.com/)! var body: some View { WebView(webPage) .onAppear { webPage.load(URLRequest(url: url)) } } } web page Test
Topic: Safari & Web SubTopic: General Tags:
0
0
302
2w
Reply to Function types as return types
If you make a mistake in your post you have a one-hour window in which you can edit it. If you're outside of that one hour, just reply to your original post. There's no need to create a duplicate thread for the same issue just because you didn't format something properly; that just clutters the forums. Anyway, correctly formatted: func stepForward(_ input: Int) -> Int { input + 1 } func stepBackward(_ input: Int) -> Int { input - 1 } func chooseStepFunction(backward: Bool) -> (Int) -> Int { backward ? stepBackward : stepForward } // Second version func chooseStepFunction(backward: Bool) -> (Int) -> Int { if backward { stepBackward } else { stepForward } } I don't get any errors, so this can't be the code that's causing it. The first version with the ternary operator works fine. As an aside, in Swift, if your function only does one thing then you don't need the return keyword.
Topic: Programming Languages SubTopic: Swift Tags:
2w
Reply to Function types as return types
It works in iOS playground, but not in MacOS playground, either Xcode 16.4 or 26.0ß6. So, that's definitely a bug you should report. You got the answer in your SO post: https://forums.swift.org/t/why-is-there-a-type-of-expression-is-ambiguous-without-a-type-annotation-error-when-using-a-ternary-operator-on-inferred-function-types-in-swift/77306/2 As said, this works: func chooseStepFunction(backward: Bool) -> (Int) -> Int { let res = oneStepBackward ? stepBackward : oneStepForward return res }
Topic: Programming Languages SubTopic: Swift Tags:
2w
Reply to Function types as return types
Thx for your reply . I am using Xcode version 16.4 and running in a playground. Just by typing these functions in the IDE (without any calls to the functions) I get the error message in the Code Review Pane. It is a blank macOS playground running on a Mac Studio M1. The code is from Apple's Swift Programming Language (5.7). Section Functions - Function types as return types.
Topic: Programming Languages SubTopic: Swift Tags:
2w
Xcode 26: Sendable checking + NSManagedObjectContext.perform in Swift 6
I have some code which handles doing some computation on a background thread before updating Core Data NSManagedObjects by using the NSManagedObjectContext.perform functions. This code is covered in Sendable warnings in Xcode 26 (beta 6) because my NSManagedObject subclasses (autogenerated) are non-Sendable and NSManagedObjectContext.perform function takes a Sendable closure. But I can't really figure out what I should be doing. I realize this pattern is non-ideal for Swift concurrency, but it's what Core Data demands AFAIK. How do I deal with this? let moc = object.managedObjectContext! try await moc.perform { object.completed = true // Capture of 'object' with non-Sendable type 'MySpecialObject' in a '@Sendable' closure try moc.save() } Thanks in advance for your help!
1
0
102
2w
Reply to SwiftData Fatal error: Editors must register their identifiers before invoking operations on this store
Do you have a full symbolicated crash report to share? You can include crash reports directly in your post using the forums attachment feature. For any random crash related to SwiftData / Core Data, I'd suggest that you add com.apple.CoreData.ConcurrencyDebug 1 as a launch argument of the app to check if there is any violation, as discussed here. Also, I guess ConsumptionSession is Sendable? Otherwise, Xcode will give you an error if you compile with Swift 6. If you haven't used Swift 6, I'd suggest that you give it a try to see if that unveils any race condition. Best, —— Ziqiao Chen  Worldwide Developer Relations.
2w
Reply to Should ModelActor be used to populate a view?
It's unclear what LabResultDto in the code snippet is. If it is a Sendable type that wraps the data in a SwiftData model, that's fine; if it is a SwiftData model type, because a SwiftData model object is not Sendable, you won't want to pass it across actors – Otherwise, Swift 6 compiler will give you an error. For more information about this topic, see the discussion here. When using SwiftData + SwiftUI, I typically use @Query to create a result set for a view. Under the hood (of @Query), the query controller should be able to detect the changes you made from within a model actor, and trigger a SwiftUI update. Fore more information about observing SwiftData changes, see this WWDC25 video. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
2w
Native Crash - Unknown Function (/usr/lib/system/libsystem_kernel.dylib) Unknown Function (/usr/lib/system/libsystem_kernel.dylib)
Hi, I encountered the following error while trying to launch a video game developed with Unity and running on an iPhone 12 and iPhone 16 Pro. Native StackTrace: Thread 2 (crashed) 0 libsystem_kernel.dylib 0x00000001d40102ec 1 libsystem_c.dylib 0x000000019330fba0 2 UnityFramework 0x000000010e7bc744 3 UnityFramework 0x000000010dc1c22c 4 UnityFramework 0x000000010cc26da4 5 CoreFoundation 0x000000018b4af984 6 libobjc.A.dylib 0x0000000183277140 7 libc++abi.dylib 0x00000001e7d20068 8 libc++abi.dylib 0x00000001e7d2000c 9 libdispatch.dylib 0x0000000193256de8 10 libdispatch.dylib 0x000000019325e400 11 libdispatch.dylib 0x000000019325ef30 12 libdispatch.dylib 0x0000000193269cb4 13 libdispatch.dylib 0x0000000193269528 14 libsystem_pthread.dylib 0x00000001e7e00934 15 libsystem_pthread.dylib 0x00000001e7dfd0cc
5
0
90
2w