I've been testing my open source libraries with Swift 6.2 and the new Default Actor Isolation concurrency build setting set to MainActor (with Complete strict concurrency turned on). My library Destinations uses protocols extensively, often applying conformance to foundational Swift protocols like Hashable and Identifiable. Many of these basic protocols are not flagged as running on the @MainActor in Beta 1, leading to situations like this:
Given this example code:
public protocol Contentable: Identifiable {
var id: UUID { get }
}
final class ContentModel: Contentable {
let id: UUID = UUID()
}
I get the warning:
Multiline
Conformance of 'ContentModel' to protocol 'Contentable' crosses into main actor-isolated code and can cause data races; this is an error in the Swift 6 language mode
The fix it suggests is to put a @MainActor before the Contentable protocol declaration in ContentModel, which seems to be a new attribute configuration in Swift 6.2. This solves the warning, but would create a lot of extra noise across the codebase.
Was it an oversight or a temporary omission that protocols like Hashable and Identifiable do not run on @MainActor by default, or is there some other reason they are excluded? Considering how often protocols in our code may conform to foundational protocols like this, it seems at odds to the MainActor mode of the Default Actor Isolation setting given that it was created to make concurrency easier and less boilerplate to implement.
How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here
Dive into the world of programming languages used for app development.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
我的应用是在mac intel时发生这个问题,从dump看程序一直卡在mmap_locked,不知要怎么修改
程序dump如下
amaran.txt
Topic:
Programming Languages
SubTopic:
General
Hey everyone,
I have a problem with an app im creating. The code doesn't have any errors but the console has this that pops up:
Snapshot request 0x1054191d0 complete with error: <NSError: 0x10541a970; domain: FBSSceneSnapshotErrorDomain; code: 4; "an unrelated condition or state was not satisfied"> {
NSLocalizedDescription = an error occurred during a scene snapshotting operation;
}
With Swift being brought to new places, is anyone working on interoperability with PHP? I'd love to replace much of my PHP and Javascript web code with Swift (and ideally SwiftUI for UI design). Are there any projects/people working in this space?
Hi,
I’m trying to use the new InlineArray type, but noticed that it is unfortunately only available on macOS 26 and not on macOS 15 and others. As this is quite an essential type, I was wondering if this is intended or will this change in later beta’s? Not having it available on older Darwin platforms would severily limit it’s usage in the coming years.
Thanks!
Last night my iPhone game crashed while running in debug mode on my iPhone. I just plugged it into my Mac, and was able to find the ips file. The stack trace shows the function in my app where it crashed, and then a couple of frames in libswiftCore.dylib before an assertion failure.
My question is - I've got absolutely no idea what the assertion failure actually was, all I have is...
0 libswiftCore.dylib 0x1921412a0 closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 228
1 libswiftCore.dylib 0x192141178 closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 327
2 libswiftCore.dylib 0x192140b4c _assertionFailure(_:_:file:line:flags:) + 183
3 MyGame.debug.dylib 0x104e52818 SentryBrain.takeTurn(actor:) + 1240
...
How do I figure out what the assertion failure was that triggered the crash? How do I figure out what line of code in takeTurn(...) triggered the failing assertion failure?
I'm encountering an issue where certain images are not displaying on some iOS devices, while the same code works perfectly on others. There’s no error or crash — just some images fail to load or display. I've confirmed the image URLs and formats are correct.
Has anyone faced a similar issue or could suggest what might be causing this inconsistent behavior?
Thanks in advance!
Topic:
Programming Languages
SubTopic:
Swift
We have an iOS App built in .NET MAUI (Multi-platform App UI).
This is a web view App.
We wish to integrate APP Clips into this App.
But we are unable to do it, due to less available resources online on such implementation.
We do not wish to share code between .NET MAUI App and App clips
We understand it is not possible to add APP Clips without a parent swift/Xcode app.
As an alternative solution we were thinking to Create a new APP in APP Store Connect using XCode/swift and integrate app clips to it.
This parent app when downloaded by users will only redirect users to our MAIN .NET MAUI app to app store connect.
We need to know if such apps will be approved by APPSTORE Connect? Please guide us on this
Also please do let us know if you have any other solution to integrate App clips to a .NET MAUI App
hi,
Is it possible to compare two vectors and get a boolean answer?
example :
uint642_t a;
uint642_t b;
.../...
if(a == b)
.../...
how to do it ?
thank
I’m creating an app using SwiftUI, and I would like to incorporate a small Java codebase that I created for the Android version of the app. Is there a way to package the Java code to work on iOS and macOS
Topic:
Programming Languages
SubTopic:
General
Is there any way that I can import a Java module for use from Swift?
Topic:
Programming Languages
SubTopic:
Swift
I have a s hared library in C++ that was built with GNU Libtool, and I want to bundle it with my Swift app and call it from the app. How can I bundle it and call it?
i am trying to build my code and have ran into this error.
"Trailing closure passed to parameter of type 'DispatchWorkItem' that does not accept a closure"
i have been trying to figure it out for so long, and even ai cant figure it out. is this a bug, or am i missing some obvious way to fix this ?
func loadUser(uid: String, completion: (() -> Void)? = nil) {
db.collection("users").document(uid).getDocument { [weak self] snapshot, error in
guard let data = snapshot?.data(), error == nil else { completion?(); return }
DispatchQueue.main.async {
self?.currentUser = User(
username: data["username"] as? String ?? "Learner",
email: data["email"] as? String ?? "",
profileImageName: "person.circle.fill",
totalXP: data["totalXP"] as? Int ?? 0,
currentStreak: data["currentStreak"] as? Int ?? 0,
longestStreak: data["longestStreak"] as? Int ?? 0,
level: data["level"] as? Int ?? 1,
levelProgress: data["levelProgress"] as? Double ?? 0.0,
xpToNextLevel: data["xpToNextLevel"] as? Int ?? 100,
completedLessons: data["completedLessons"] as? [String] ?? []
)
self?.saveUser()
completion?()
}
}
}
We are migrating to swift 6 from swift 5 using Xcode 16.2. we are getting below errors in almost each of our source code files :
Call to main actor-isolated initializer 'init(storyboard:bundle:)' in a synchronous non isolated context
Main actor-isolated property 'delegate' can not be mutated from a nonisolated context
Call to main actor-isolated instance method 'register(cell:)' in a synchronous nonisolated context
Call to main actor-isolated instance method 'setup()' in a synchronous nonisolated context
Few questions related to these compile errors.
Some of our functions arguments have default value set but swift 6 does not allow to set any default values. This requires a lot of code changes throughout the project. This would be lot of source code re-write.
Using annotations like @uncheck sendable , @Sendable on the class (Main actor) name, lot of functions within those classes , having inside some code which coming from other classes which also showing main thread issue even we using @uncheck sendable.
There are so many compile errors, we are still seeing other than what we have listed here. Fixing these compile errors throughout our project, would be like a re-write of our whole application, which would take lot of time. In order for us to migrate efficiently, we have few questions where we need your help with. Below are the questions.
Are there any ways we can bypass these errors using any keywords or any other way possible?
Can Swift 5 and Swift 6 co-exist? so, we can slowly migrate over a period of time.
We have FrameworkA which needs to use another FrameworkB internally to fetch a token.
Now when I try to use this FrameworkA, we are seeing an issue with internal framework i.e. No such module 'FrameworkB'.
But when I use @_implementationOnly import for the internal FrameworkB, I didn't see any issues.
So just wanted to check If I can go ahead and use this @_implementationOnly import flag in Production?
At least with macOS Sequoia 15.5 and Xcode 16.3:
$ cat test.cc
#include &lt;locale.h&gt;
#include &lt;string.h&gt;
#include &lt;xlocale.h&gt;
int main(void) {
locale_t l = newlocale(LC_ALL_MASK, "el_GR.UTF-8", 0);
strxfrm_l(NULL, "ό", 0, l);
return 0;
}
$ c99 test.c &amp;&amp; ./a.out
Assertion failed: (p-&gt;val == key), function lookup_substsearch, file collate.c, line 596.
Abort trap: 6
Hello, I'm not a developer. I have an app in the App Store and an Apple Developer account. I have two questions: 1. I'm trying to find out exactly where the source code of my app is located - I can't. It should be in Xcode. There is only Xcode cloud in my account, which is inactive. 2. I want to find out what programming language my app is written in. How do I do this?
Topic:
Programming Languages
SubTopic:
General
Just read about the new @concurrent option coming to Swift 6.2 and lover it, but...
It just me, but I which these options would pick a case and stick with it...
@Sendable
@unchecked
@MainActor
@concurrent
@Observable
@ObservationIgnored
I have a Settings class that conform to the TestProtocol. From the function of the protocol I need to call the setString function and this function needs to be on the MainActor. Is there a way of make this work in Swift6, without making the protocol functions running on @MainActor
The calls are as follows:
class Settings: TestProtocol{
var value:String = ""
@MainActor func setString( _ string:String ){
value = string
}
func passString(string: String) {
Task{
await setString(string)
}
}
}
protocol TestProtocol{
func passString( string:String )
}
Hi all,
In Swift, I often see static helper functions grouped in an enum without any cases, like this:
enum StringUtils {
static func camelCaseToSnakeCase(_ input: String) -> String {
// implementation
}
}
Since this enum has no cases, it cannot be instantiated – which is exactly the point.
It’s meant to group related functionality without any stored state, and without the need for instantiation.
This pattern avoids writing a struct with a private init() and makes the intent clearer:
"This is just a static utility, not an object."
You’ll often see this used for things like:
AnalyticsEvents.track(_:)
My question:
Is this use of a case-less enum considered good practice in Swift when building static-only helpers?
Or is there a better alternative for expressing intent and preventing instantiation?
I’d appreciate any insight – especially if there’s official guidance or references from the Swift core team.
Thanks!
Topic:
Programming Languages
SubTopic:
Swift