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?
Dive into the world of programming languages used for app development.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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 <locale.h>
#include <string.h>
#include <xlocale.h>
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 && ./a.out
Assertion failed: (p->val == key), function lookup_substsearch, file collate.c, line 596.
Abort trap: 6
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
I've been teaching myself Objective-C and I wanted to start creating projects that don't use ARC to become better at memory management and learn how it all works. I've been attempting to build and run applications, but I'm not really sure where to start as modern iOS development is used with Swift and memory management is handled.
Is there any way to create modern applications that use Objective-C, UIKit, and not use ARC?
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
I have a Swift Package that contains an Objective-C target. The target contains Objective-C literals but unfortunately the compiler says "Initializer element is not a compile-time constant", what am I doing wrong?
Based on the error triggering in the upper half, I take it that objc_array_literals is on.
My target definition looks like:
.target(
name: "MyTarget",
path: "Sources/MySourcesObjC",
publicHeadersPath: "include",
cxxSettings: [
.unsafeFlags("-fobjc-constant-literals")
]
),
I believe Objective-C literals are enabled since a long time but I still tried passing in the -fobjc-constant-literals flag and no luck.
To be clear I'm not interested in a run-time initialization, I really want it to be compile time. Does anyone know what I can do?
I am currently encountering two deprecated errors in my code. Could someone please identify the issues with the code?
Errors:
'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:annotationItems:annotationContent:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead.
'MapAnnotation' was deprecated in iOS 17.0: Use Annotation along with Map initializers that take a MapContentBuilder instead.
Code:
// MARK: - Stores Map (Dynamic)
struct StoresMapView: View {
@State private var storeLocations: [StoreLocation] = []
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: -31.95, longitude: 115.86),
span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)
)
var body: some View {
Map(coordinateRegion: $region, interactionModes: .all, annotationItems: storeLocations) { store in
MapAnnotation(coordinate: CLLocationCoordinate2D(latitude: store.latitude, longitude: store.longitude)) {
VStack(spacing: 4) {
Image(systemName: "leaf.circle.fill")
.font(.title)
.foregroundColor(.green)
Text(store.name)
.font(.caption)
.fixedSize()
}
}
}
.onAppear(perform: loadStoreData)
.navigationTitle("Store Locator")
}
private func loadStoreData() {
guard let url = URL(string: "https://example.com/cop092/StoreLocations.json") else { return }
URLSession.shared.dataTask(with: url) { data, _, _ in
if let data = data, let decoded = try? JSONDecoder().decode([StoreLocation].self, from: data) {
DispatchQueue.main.async {
self.storeLocations = decoded
if let first = decoded.first {
self.region.center = CLLocationCoordinate2D(latitude: first.latitude, longitude: first.longitude)
}
}
}
}.resume()
}
}