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.
Dive into the world of programming languages used for app development.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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;
}
Hello,
I am developing a private internal Flutter app for our customer, which will not be published on the Apple Store. One of the key features of this app is to collect RF strength metrics to share user experience with the network.
For Android, we successfully implemented the required functionality and are able to collect the following metrics:
Signal strength level (0-4)
Signal strength in dBm
RSSI
RSRQ
Cell ID
Location Area Code
Carrier name
Mobile country code
Mobile network code
Radio access technology
Connection status
Duplex mode
However, for iOS, we are facing challenges with CoreTelephony, which is not returning the necessary data. We are aware that CoreTelephony is deprecated and are looking for alternatives.
We noticed that a lot of the information we need is available via FTMInternal-4. Is there a way to access this data for a private app? Are there any other recommended approaches or frameworks that can be used to gather cellular network information on iOS for an app that won't be distributed via the Apple Store?
my swift code
import Foundation
import CoreTelephony
class RfSignalStrengthImpl: RfSignalStrengthApi {
func getCellularSignalStrength(completion: @escaping (Result<CellularSignalStrength, Error>) -> Void) {
let networkInfo = CTTelephonyNetworkInfo()
guard let carrier = networkInfo.serviceSubscriberCellularProviders?.values.first else {
completion(.failure(NSError(domain: "com.xxxx.yyyy", code: 0, userInfo: [NSLocalizedDescriptionKey: "Carrier not found"])))
return
}
let carrierName = carrier.carrierName ?? "Unknown"
let mobileCountryCode = carrier.mobileCountryCode ?? "Unknown"
let mobileNetworkCode = carrier.mobileNetworkCode ?? "Unknown"
let radioAccessTechnology = networkInfo.serviceCurrentRadioAccessTechnology?.values.first ?? "Unknown"
var connectionStatus = "Unknown"
...
...
}
Thank you for your assistance.
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?
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 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?()
}
}
}
I have an @objC used for notification.
kTag is an Int constant, fieldBeingEdited is an Int variable.
The following code fails at compilation with error: Command CompileSwift failed with a nonzero exit code if I capture self (I edited code, to have minimal case)
@objc func keyboardDone(_ sender : UIButton) {
DispatchQueue.main.async { [self] () -> Void in
switch fieldBeingEdited {
case kTag : break
default : break
}
}
}
If I explicitly use self, it compiles, even with self captured:
@objc func keyboardDone(_ sender : UIButton) {
DispatchQueue.main.async { [self] () -> Void in
switch fieldBeingEdited { // <<-- no need for self here
case self.kTag : break // <<-- self here
default : break
}
}
}
This compiles as well:
@objc func keyboardDone(_ sender : UIButton) {
DispatchQueue.main.async { () -> Void in
switch self.fieldBeingEdited { // <<-- no need for self here
case self.kTag : break // <<-- self here
default : break
}
}
}
Is it a compiler bug or am I missing something ?
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
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?
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
Why doesn’t deinit support async? At the end of a test, I want to wipe data from HealthKit, and it’s delete function is asynchronous.
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.
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
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
Crashed: com.apple.root.user-initiated-qos.cooperative
0 libswift_Concurrency.dylib 0x67f40 swift_task_create_commonImpl(unsigned long, swift::TaskOptionRecord*, swift::TargetMetadataswift::InProcess const*, void (swift::AsyncContext* swift_async_context) swiftasynccall*, void*, unsigned long) + 528
1 libswift_Concurrency.dylib 0x64d78 swift_asyncLet_begin + 40
2 AAAA 0x47aef28 (1) suspend resume partial function for ActivityContextModule.fetchRecord(startDate:endDate:) + 50786796
3 libswift_Concurrency.dylib 0x60f5c swift::runJobInEstablishedExecutorContext(swift::Job*) + 252
4 libswift_Concurrency.dylib 0x62514 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 144
5 libdispatch.dylib 0x15ec0 _dispatch_root_queue_drain + 392
6 libdispatch.dylib 0x166c4 _dispatch_worker_thread2 + 156
7 libsystem_pthread.dylib 0x3644 _pthread_wqthread + 228
8 libsystem_pthread.dylib 0x1474 start_wqthread + 8
"the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions" ...... it killing me !!!!