Search results for

Swift 6

49,208 results found

Post

Replies

Boosts

Views

Activity

Reply to Struggling with async/await: Fetching an image off the main thread
Folks, This conversation will go more smoothly if you reply as a reply, rather than in the comments. See Quinn’s Top Ten DevForums Tips for this and other tips. eoonline wrote: for the sake of future readers, that alone is insufficient. Agreed. As that’s a critical point of my previous post, I’ve edited that post to clarify it. Thanks for pointing this out. Praveenraj4256 wrote: Using Task.detached is better approach? No. In general, you should try to avoid creating new tasks wherever possible. [quote='817895022, Praveenraj4256, /thread/770655?answerId=817895022#817895022, /profile/Praveenraj4256'] I want to achieve the same functionality using structured concurrency [/quote] I think it’s a mistake to look for ‘drop in’ replacements for old techniques. The key thing to remember about Swift concurrency is that the isolation context of your code is determined statically [1]. That’s a benefit for you — you can look at the code and understand its isolation context — but it’s of critical importance to the
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
UserDefaults not Sendable
Hey, I am just about to prepare my app for Swift 6, and facing the issue that UserDefaults is not Sendable. The documentation states that its thread safe, so I am wondering, why is it not marked as Sendable? Was it just forgotten? Is it safe to mark it as nonisolated(unsafe) or @unchecked Sendable?
6
0
3.7k
Jun ’24
Xcode 16 Doesn't Display "Swift Compiler" Build Settings Sections
I am editing my iOS project in Xcode 16 and want to use the Swift Compiler - Upcoming Features section of the build settings to selectively enable the new Swift 6 language features. I have read the instructions for doing this and have dowloaded an Apple sample project and can see that section under the project and target-level Build Settings in the sample project However, when I open my Xcode project in XCode 16 that section does not appear. Is there any way for me to influence how Xcode 16 displays the build settings? In fact, no Swift Compiler sections appear at all under my project Build Settings (All | Combined). There is a User-Defined section that has the Swift Version, Compilation Mode and Optimization level. The project itself is several years old and was on a very old project version. I have upgraded my project document format to Xcode 16 but it made no difference. I have compared my project and the sample project in a text editor and both seem to have similar stru
3
0
949
Oct ’24
Possible typo in concurrency diagram (WWDC25: Elevate an app with Swift concurrency)
Hello, While watching WWDC25: Code-along: Elevate an app with Swift concurrency at timestamp 25:48, I noticed something in the slide/diagram that might be incorrect. The diagram shows ExtractSticker twice, but based on the code context and spoken explanation, I think it was meant to be ExtractSticker and ExtractColor. Reasoning: The surrounding code and narration describe the use of async let and a Sendable Data object. From the flow, one task extracts a sticker while the other extracts a color, so it seems like the diagram is inconsistent. I do understand that with @concurrent, having two ExtractSticker operations on the same Data is technically possible (with two concurrent process executing their respective ExtractSticker) — but that would be a different meaning than what the talk was describing. Since concurrency is already a subtle and error-prone topic, I thought it was worth pointing this out. If I’m mistaken, I’d love clarification. Otherwise, this could be a small correction to keep things a
2
0
1.6k
2w
Reply to C++ calling swift function
I am using Swift 2.0 on Xcode 6Are you using Swift 1.2 on Xcode 6? (Xcode 6.x does not support Swift 2.) Then no way. You cannot convert Swift function to C-function pointer. Add an Objective-C(++) file to bridge between Swift and C++.If you are using Swift 2 on Xcode7, global functions can be automatically converted to C-function pointers, just write it as:RegisterCallBack(DataCallback)
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’15
Toolbar Bug on Iphone 6 and 6 Plus
Hello, everybody! I found a problem on my project, and i think its a Bug on XCODE itself.I'm developing a WebView on Swift Lenguage. Every code its in the right place, I run the project in 4s, 5, 5S Devices and works just fine, but when i run on the Iphone 6 and 6 plus devices, the toolbar becomes bigger and i don't know hot to fix it. Could you Guys give me any help or hint? Sorry for my bad english. 🙂 Im from Brazil lol
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
310
Aug ’15
Xcode 7 Playgrounds can't use latest iOS/OS X frameworks?
Trying to test out some iOS 9 / OSX 10.11 stuff in a playground, but an seeing errors that seem to indicate that I can't try out new stuff in a playground. Specifically, trying to test out some things from the latest nshipster.com article:import UIKit let formatter = NSNumberFormatter() formatter.numberStyle = NSNumberFormatterStyle.OrdinalStyleThis gives me an error in the console:Playground execution failed: /var/folders/tf/3k7qp8615ml80kjsshq70hnr0000gp/T/./lldb/3312/playground8.swift:6:48: error: 'OrdinalStyle' is only available on iOS 9.0 or newer formatter.numberStyle = NSNumberFormatterStyle.OrdinalStyle ^ /var/folders/tf/3k7qp8615ml80kjsshq70hnr0000gp/T/./lldb/3312/playground8.swift:6:48: note: guard with version check formatter.numberStyle = NSNumberFormatterStyle.OrdinalStyleSo basically XCode 7 is useless to try out the latest code? Seems like a big problem...
4
0
1.7k
Jun ’15
Autocomplete broken for large mixed projects ObjC/Swift. (xc7 beta 6)?
I'm guessing it's not just me.I have a number of large ObjC projects which I have started adding Swift code to. Exciting!Sadly, this is made extremely difficult because autocomplete only works for Swift types (e.g Array) and not for any ObjC types (from Frameworks or my own code).If I make a new ObjC project and then add some Swift code autocomplete works fine. It's only my large legacy projects (i.e the ones I care about) that don't work.Anybody know any tricks to make it work again? Anybody already have a radar #? Thanks.
0
0
287
Sep ’15
"Abort trap: 6" error in Swift 2 with Xcode 7 beta-1
Hello, I have gotten this error that prevents my project from compiling, and others have reported it as well in various places. My project is Swift with SceneKit, migrated from 6.3.X to 7, but I have also been able to reproduce it with a fresh project created in Xcode 7 beta-1. If you are having this problem, please see this discussion for details:https://forums.developer.apple.com/message/10714I am starting a thread here in the Swift forum because it seems the issue is Swift-specific (and possibly SceneKit-specific as well) and this is a more active forum. If we can some more discussion and testing, we can start submitting bug reports on this, but I would like to gather more information from other users before I do that to narrow down the problem.
7
0
3.7k
Jun ’15
Crash in Preview (but not in Simulator) when using fileprivate on a protocol in Swift
Consider this stripped-down example of a view with a view model: import Observation import SwiftUI struct MainView: View { @State private var viewModel = ViewModel() private let items = [0, 1, 2] var body: some View { List { GroupedItemsView( viewModel : viewModel.groupState, groupedItems : [(0, items)] ) } } } fileprivate struct GroupedItemsView: View { let viewModel : ViewModel let groupedItems : [(ViewModel.GroupTag, [Int])] var body: some View { ForEach(groupedItems, id: .0) { groupTag, items in Text(nothing) } } } fileprivate protocol GroupsExpandable: AnyObject { // HERE associatedtype GroupTag: Hashable } fileprivate final class GroupState: GroupsExpandable {} @Observable fileprivate final class ViewModel { var groupState = GroupState() } #Preview { MainView() } This compiles and runs fine in the Simulator, but it crashes in the Preview. However, when I remove the fileprivate modifier before GroupsExpandable (see HERE), it also runs in the Preview. What is the reason for this? Bug in Preview? Error on
1
0
86
Apr ’25