thread #1, stop reason = signal SIGABRT
frame #0: 0x00000001a95985a8 dyld__abort_with_payload + 8 frame #1: 0x00000001a959f208 dyldabort_with_payload_wrapper_internal + 104
frame #2: 0x00000001a959f23c dyldabort_with_payload + 16 frame #3: 0x00000001a95364c8 dylddyld4::halt(char const*, dyld4::StructuredError const*) + 300
frame #4: 0x00000001a9541f60 dylddyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 4124 frame #5: 0x00000001a95667a8 dylddyld4::start(dyld4::KernelArgs*, void*, void*)::$_0::operator()() const + 544
frame #6: 0x00000001a955fb1c dyld`start + 2188
Dive into the world of programming languages used for app development.
Post
Replies
Boosts
Views
Activity
Hey all!
in my personal quest to make future proof apps moving to Swift 6, one of my app has a problem when setting an artwork image in MPNowPlayingInfoCenter
Here's what I'm using to set the metadata
func setMetadata(title: String? = nil, artist: String? = nil, artwork: String? = nil) async throws {
let defaultArtwork = UIImage(named: "logo")!
var nowPlayingInfo = [
MPMediaItemPropertyTitle: title ?? "***",
MPMediaItemPropertyArtist: artist ?? "***",
MPMediaItemPropertyArtwork: MPMediaItemArtwork(boundsSize: defaultArtwork.size) { _ in
defaultArtwork
}
] as [String: Any]
if let artwork = artwork {
guard let url = URL(string: artwork) else { return }
let (data, response) = try await URLSession.shared.data(from: url)
guard (response as? HTTPURLResponse)?.statusCode == 200 else { return }
guard let image = UIImage(data: data) else { return }
nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { _ in
image
}
}
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
}
the app crashes when hitting
MPMediaItemPropertyArtwork: MPMediaItemArtwork(boundsSize: defaultArtwork.size) { _ in
defaultArtwork
}
or
nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { _ in
image
}
commenting out these two make the app work again.
Again, no clue on why.
Thanks in advance
Hi,
After update to Xcode 16 a lot of errors happen, for example:
import Foundation
extension Collection {
func get(at i: Index) -> Element? {
return indices.contains(i) ? self[i] : nil
}
}
Errors:
Cannot find type 'Index' in scope
Cannot find 'indices' in scope
What is wrong?
Thanks.
Issues Integrating FaceTec SDK into a Custom iOS Framework
Hi Community,
I am working on a custom iOS framework that integrates FaceTec SDK for biometric authentication, but I am facing issues with properly running the SDK within my framework. Below is the context and specific issues I need help with:
Context: I have created a framework that includes a UIViewController called FinishViewController. This controller is responsible for managing the FaceTec SDK session. Below is a simplified snippet of the code used to initialize and handle FaceTec SDK:
import UIKit
import FaceTecSDK
import LocalAuthentication
class FinishViewController: UIViewController, URLSessionDelegate{
var utils: SampleAppUtilities!
var latestProcessor: Processor!
var latestExternalDatabaseRefID: String = ""
var latestSessionResult: FaceTecSessionResult!
var latestIDScanResult: FaceTecIDScanResult!
@IBOutlet weak var elTelon: UIView!
var isRealPerson = false
var isNotSuccessful = false
var isCancelled = false
override func viewDidLoad() {
super.viewDidLoad()
utils = SampleAppUtilities(vc: self)
// Initialize FaceTec SDK
Config.initializeFaceTecSDKFromAutogeneratedConfig(completion: { initializationSuccessful in
if(initializationSuccessful) {
self.onFaceTecSDKInitializationSuccess()
}
else {
self.onFaceTecSDKInitializationFailure()
}
})
DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [self] in
getSessionToken() { sessionToken in
_ = LivenessCheckProcessor(sessionToken: sessionToken, fromViewController: self)
.lvResponseDelegate = self
//self.latestProcessor = AuthenticateProcessor(sessionToken: sessionToken, fromViewController: self)
}
}
// Do any additional setup after loading the view.
}
func onFaceTecSDKInitializationFailure() {
// Displays the FaceTec SDK Status to text field if init failed
self.utils.displayStatus(statusString: "\(FaceTec.sdk.description(for: FaceTec.sdk.getStatus()))")
}
func onFaceTecSDKInitializationSuccess() {
// self.utils.enableButtons(shouldEnable: true)
// Set your FaceTec Device SDK Customizations.
ThemeHelpers.setAppTheme(theme: utils.currentTheme)
// Set the sound files that are to be used for Vocal Guidance.
// Set the strings to be used for group names, field names, and placeholder texts for the FaceTec ID Scan User OCR Confirmation Screen.
SampleAppUtilities.setOCRLocalization()
let currentTheme = Config.wasSDKConfiguredWithConfigWizard ? "Config Wizard Theme" : "FaceTec Theme"
utils.handleThemeSelection(theme: currentTheme)
self.utils.displayStatus(statusString: "Initialized Successfully.")
}
func onComplete() {
if !self.latestProcessor.isSuccess() {
// Reset the enrollment identifier.
self.latestExternalDatabaseRefID = "";
}
}
func getSessionToken(sessionTokenCallback: @escaping (String) -> ()) {
let endpoint = Config.BaseURL + "/session-token"
let request = NSMutableURLRequest(url: NSURL(string: endpoint)! as URL)
request.httpMethod = "GET"
// Required parameters to interact with the FaceTec Managed Testing API.
request.addValue(Config.DeviceKeyIdentifier, forHTTPHeaderField: "X-Device-Key")
request.addValue(FaceTec.sdk.createFaceTecAPIUserAgentString(""), forHTTPHeaderField: "User-Agent")
request.addValue(FaceTec.sdk.createFaceTecAPIUserAgentString(""), forHTTPHeaderField: "X-User-Agent")
let session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: OperationQueue.main)
let task = session.dataTask(with: request as URLRequest, completionHandler: { data, response, error in
// Ensure the data object is not nil otherwise callback with empty dictionary.
guard let data = data else {
print("Exception raised while attempting HTTPS call.")
return
}
if let responseJSONObj = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.allowFragments) as! [String: AnyObject] {
if((responseJSONObj["sessionToken"] as? String) != nil)
{
sessionTokenCallback(responseJSONObj["sessionToken"] as! String)
return
}
else {
print("Exception raised while attempting HTTPS call.")
}
}
})
task.resume()
}
func getLatestExternalDatabaseRefID() -> String {
return latestExternalDatabaseRefID;
}
func setLatestSessionResult(sessionResult: FaceTecSessionResult) {
latestSessionResult = sessionResult
print("The latestSessionResult is: ", latestSessionResult!)
}
@IBAction func finish(_ sender: Any) {
AppConfig.shared.intentosCaptura = 1
self.performSegue(withIdentifier: "unwindToRoot", sender: self)
}
}
When I try to run the SDK, no initial compilation or runtime errors occur, but the SDK does not start as expected and there are no clear indications or errors in the console to help me diagnose the problem. I have checked the wiring of all the IBOutlet and IBAction, and everything seems to be in order.
Are there any special considerations I should be aware of when integrating FaceTec SDK into a framework rather than an application directly?
Are there any best practices for managing SDK initialization or view lifecycles within an iOS framework?
Has anyone faced similar issues when integrating third-party SDKs into custom frameworks and how did they resolve them?
Hey all!
During the migration of a production app to swift 6, I've encountered a problem: when hitting the UNUserNotificationCenter.current().requestAuthorization the app crashes.
If I switch back to Language Version 5 the app works as expected.
The offending code is defined here
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
FirebaseConfiguration.shared.setLoggerLevel(.min)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { _, _ in }
application.registerForRemoteNotifications()
Messaging.messaging().delegate = self
return true
}
}
The error is depicted here:
I have no idea how to fix this.
Any help will be really appreciated
thanks in advance
Since I updated my project I'm getting this error
Stored property 'base' of 'Sendable'-conforming struct 'AnyShape' has non-sendable type '(CGRect) -> Path'; this is an error in the Swift 6 language mode
I get this error at that struct, more specifically on the base variable
public struct AnyShape: Shape {
private var base: (CGRect) -> Path
public init<S: Shape>(shape: S) {
base = shape.path(in:)
}
public func path(in rect: CGRect) -> Path {
base(rect)
}
}
I have no idea how to solve this issue, I've been looking on the internet for same issues and get nothing yet
We are seeing a swift concurrency related crash in iOS 18 and iOS 18.1 that has no direct link to any part of my code base in the stack trace. We are not able to reproduce locally but see it in the Organizer. The crash seems to come from withTaskCancellationHandler in Concurrency.swift
Incident Identifier: C5331198-3922-471F-8E39-57186BBB962B
Distributor ID: com.apple.AppStore
Hardware Model: iPhone16,2
Process: MyApp [866]
Path: /private/var/containers/Bundle/Application/B320C8CF-5711-4F14-92C4-0693420DDE07/MyApp.app/MyApp
Identifier: com.MyApp.release
Version: 10.0.1 (1)
AppStoreTools: 16A242b
AppVariant: 1:iPhone16,2:18
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.MyApp.release [989]
Date/Time: 2024-09-21 06:30:38.3210 -0500
Launch Time: 2024-09-21 06:18:03.0691 -0500
OS Version: iPhone OS 18.1 (22B5007p)
Release Type: Beta
Baseband Version: 2.15.01
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000004
Exception Codes: 0x0000000000000001, 0x0000000000000004
VM Region Info: 0x4 is not in any region. Bytes before following region: 4340908028
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 102bd0000-102be0000 [ 64K] r-x/r-x SM=COW /var/containers/Bundle/Application/B320C8CF-5711-4F14-92C4-0693420DDE07/MyApp.app/MyApp
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [866]
Triggered by Thread: 3
Thread 3 Crashed:
0 MyApp 0x0000000103b00b8c withTaskCancellationHandler<A>(operation:onCancel:isolation:) + 108 (/<compiler-generated>:0)
1 MyApp 0x0000000103b0284d closure #1 in DataRequest.dataTask<A>(automaticallyCancelling:forResponse:) + 1 (Concurrency.swift:352)
2 MyApp 0x0000000102f66011 partial apply for closure #1 in closure #1 in variable initialization expression of static FireAndForgetKey.liveValue + 1
3 MyApp 0x0000000102f80841 closure #1 in DataTask.response.getter + 1
4 MyApp 0x0000000102f66011 partial apply for closure #1 in closure #1 in variable initialization expression of static FireAndForgetKey.liveValue + 1
5 libswift_Concurrency.dylib 0x000000019164e689 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:471)
My project’s source code was building, running, and archiving successfully in Xcode 14.3. However, after upgrading to Xcode 15, I began encountering the error:
“Command SwiftCompile failed with a nonzero exit code.”
I couldn't resolve the issue, so I decided to continue using Xcode 14.3.
Recently, I upgraded to macOS Sequoia and also updated to Xcode 16. Unfortunately, the same error persists in the latest Xcode:
“Command SwiftCompile failed with a nonzero exit code.”
The unfortunate part is that Xcode 14.3 no longer works after the macOS upgrade. Whenever I try to run the code, I get the following popup.
I ran into a problem recently with my production app and an update for iOS 18. In this example I was using a new API added to the RC candidate of iOS 18.0, using this API as an example, I couldn't find a satisfactory way to avoid crashing on iOS 18.1 where the API was not available. I had plenty of users running the iOS 18.1 Beta and ultimately it's my fault if a version of my app did work, and then didn't after an update....
This code causes a crash on iOS 18.1 beta as the .appleSleepingBreathingDisturbances API doesn't seem to have made it's way into the beta:
if #available(iOS 18.0, *), #available(watchOS 11, *) {
healthKitTypesToRead.insert(HKQuantityType.quantityType(forIdentifier: .appleSleepingBreathingDisturbances)!)
}
I tried this but it still crashed on 18.1:
if #available(iOS 18.0, *), #available(watchOS 11, *) {
if let newQuantity = HKQuantityType.quantityType(forIdentifier: .appleSleepingBreathingDisturbances) {
healthKitTypesToRead.insert(newQuantity)
}
}
In the end the only way I could resolve this was the following:
if #available(iOS 18.1, *){
// Do nothing
}
else if #available(iOS 18.0, *), #available(watchOS 11, *) {
if let newQuantity = HKQuantityType.quantityType(forIdentifier: .appleSleepingBreathingDisturbances) {
healthKitTypesToRead.insert(newQuantity)
}
}
This seems like a poor solution and I'll have to ensure I release a new version of the app once iOS 18.1 has the available API added to enable support for the feature.
How could I have checked availability for this API correctly without causing the app to crash? I'm asking this question more as a Swift language feature rather than issue with the specific API as I'm sure that will get resolved soon anyway.
Thanks
I am not having any luck mutating a var in a structure, and yes, the method is defined as 'mutating'
here's the struct definition:
struct OnboardingSwipeableView: View{
static var shared = OnboardingSwipeableView()
@State var currentPage = 0
var lock = NSLock()
<snip>
here's the method:
mutating func goToNextPage(){
currentPage = self.currentPage+1
print("OBM->goToNestPage: currentPage=\(self.currentPage)")
}
however currentPage is not being updated. What gives?
Updating an app to use strict concurrency is not compiling in Swift 6 with strict concurrency enabled. I am getting the following error in Xcode Version 16.0 (16A242d).
private func queryHealthKit() async throws -> (
[HKSample]?, [HKDeletedObject]?, HKQueryAnchor?
) {
try await withCheckedThrowingContinuation { continuation in
// Create a predicate that returns only samples created within the last 24 hours.
let endDate = Date()
let startDate = endDate.addingTimeInterval(-24.0 * 60.0 * 60.0)
let datePredicate = HKQuery.predicateForSamples(
withStart: startDate, end: endDate, options: [.strictStartDate, .strictEndDate])
// Create the query.
let query = HKAnchoredObjectQuery(
type: caffeineType,
predicate: datePredicate,
anchor: anchor,
limit: HKObjectQueryNoLimit
) { (_, samples, deletedSamples, newAnchor, error) in
// When the query ends, check for errors.
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: (samples, deletedSamples, newAnchor))
}
}
store.execute(query)
}
}
The error is on
** continuation.resume(returning: (samples, deletedSamples, newAnchor))
**
and the error is
Task-isolated value of type '([HKSample]?, [HKDeletedObject]?, HKQueryAnchor?)' passed as a strongly transferred parameter; later accesses could race. How to solve this error?
after updating to macOS sequoia C++ compiler on vscode is not working is it just me or it is a common issue ?
Here is a code snippet about AVPlayer.
avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 60), queue: .main) { [weak self] _ in
// Call main actor-isolated instance methods
}
Xcode shows warnings that Call to main actor-isolated instance method '***' in a synchronous nonisolated context; this is an error in the Swift 6 language mode. How can I fix this?
avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 60), queue: .main) { [weak self] _ in
Task { @MainActor in
// Call main actor-isolated instance methods
}
}
Can I use this solution above? But it seems switching actors frequently can slow down performance.
I have a Class defined in C++, I want to pass the instance of class from C++ to Swift as a reference type. By default swift maps C++ classes as value types but we can change this behavior by using SWIFT_IMMORTAL_REFERENCE annotation mentioned here. The example mentioned here is of Singelton class but I have a usecase where i require more than one instance.
Cpp Class Skeleton.
class Cpp {
public:
void Print () noexcept;
void SetValue (int pValue) noexcept;
// Method which is Invoked by Swift.
static Cpp& ReturnObj () noexcept;
private:
int vValue;
} SWIFT_IMMORTAL_REFERENCE;
Definition of Return Obj
Cpp&
Cpp::ReturnObj () noexcept {
static Cpp obj;
return obj;
}
Swift Co
var obj : Cpp = Cpp.ReturnObj()
withUnsafeBytes(of: &obj) {(pointer : UnsafeRawBufferPointer) in
print (pointer)
print (pointer.baseAddress!)
}
Output
Address Printed by C++
0x100008000
Address Printed by Swift
0x00007ff7bfeff108
So from the above observation copy is passed.
How to do pass by reference then?
I’m facing an issue while compiling a project with a CustomSDK on Xcode 16.0 Beta 6. The following error is displayed during the build process:
Failed to build module 'CustomSDK'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)', while this compiler is 'Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)'). Please select a toolchain which matches the SDK.
Steps I have taken so far:
Set the BUILD_LIBRARY_FOR_DISTRIBUTION build setting to YES in the post_install script to ensure forward compatibility.
Cleaned the project and deleted Derived Data.
Verified that the latest SDK version was compiled using Swift 5 in Xcode 15.2, which should ensure compatibility with future versions.
Tried re-adding the SDK pod and rebuilt the project.
Despite these steps, the issue persists on Xcode 16 Beta 6. I suspect the problem could be related to a beta version of Xcode and compatibility issues, but I need guidance on how to ensure the SDK works with Xcode 16.
Is this a known issue with Swift versioning in the beta release? Are there any workarounds or specific changes I should apply to make the SDK work with Xcode 16 Beta 6?
Any help or suggestions would be appreciated!
I have a Usecase where I want to pass user-defined swift structure instance from Swift to C++ as argument to the C++ Function.
In the documentation it's mentioned that swift exposes these structures to c++.
Swift Structure.
public struct MyStruct {
public init (_ pValue : Int) {
uValue = pValue
}
public var uValue : Int
}
I am able to Create Instance in C++ .
Code
void
CppClass::CreateSwiftStruct ()
{
Interop::MyStruct my_struct = Interop::MyStruct::init (20);
}
But when I define a C++ Function which takes Interop::MyStruct as argument then that function doesn't get exposed to swift, so i am not able to call it.
Skeleton For CppClass
class CppClass {
static void PassStruct (Interop::MyStruct pStruct);
static void Test ();
}
Here PassStruct Method doesn't get exposed to C++ but Test does.
How can I pass Struct Instance in swift to C++ Function as In Param?
I have a struct defined in Swift, i want to pass it's instance pointer from swift to C++. When I am trying to directly return Typed Pointer from Swift Function to C++, the function doesn't get expose to C++.
Code which i have tried.
// Defined Structure
public struct MyStruct {
public init (_ pValue : Int) {
uValue = pValue
}
public var uValue : Int
}
var my_struct = MyStruct(20)
// Function which returns Struct Pointer to C++
// When I return typed pointer this function doesn't get exposed to C++
public func PassStructPointer () -> UnsafeMutablePointer<MyStruct> {
withUnsafeMutablePointer(to: &my_struct) { pointer in
return pointer
}
}
But when I pass UnsafeRawMutablePointer instead of type pointer then the function does get expose to C++
var my_struct = MyStruct(20)
// This get expose to C++.
public func PassStructPointer () -> UnsafeMutableRawPointer {
return withUnsafeMutableBytes(of: &my_struct) { pointer in
return pointer.baseAddress!
}
}
Can we not pass typed pointer of the types defined by us?
I have a use case where I want to return reference from Swift Function just like we can do in C++.
This is How we do it in C++:
int & ReturnIntRef () noexcept
{
static int a = 4;
return a;
}
Do we have equivalent of this in Swift ?
Hello,
I'm doing some test and I dowload the sample from here https://developer.apple.com/documentation/networkextension/local_push_connectivity/receiving_voice_and_text_communications_on_a_local_network
Everything works correctly and the phones are able to exchange messages without problems and the server sends pushes to the devices.
Now I would like to modify the server so that, when it sends the push to the mobile device, it can change the sound or add other information as is possible when using APN.
Now I would like to modify the server so that, when it sends the push to the mobile device, it can change the sound or add other information as is possible when using APN.
Is there any way to send a payload like for APN?
Thank's
Omar