Dive into the world of programming languages used for app development.

All subtopics

Post

Replies

Boosts

Views

Activity

Is it possible to Add Reply of Push Notification from Airpod using Voice ?
We want to do below addition to iOS Mobile App. Airpod announces Push notification = which is workking now we want to use voice command that "Reply to this" and sending Reply to that notification but it is saying it is not supported in your app. So basically we need to use feature - Listen and respond to messages with AirPods Do we need to add any integration inside app for this or it will directly worked with Siri settings ? Is it possible to do in non messaging App? Is it possible to do without syncing contacts ?
0
0
359
Dec ’24
Model instance invalidated, backing data could no longer be found in the store
I have been recently getting the following error seemingly randomly, when an event handler of a SwiftUI view accesses a relationship of a SwiftData model the view holds a reference to. I haven't yet found a reliable way of reproducing it: SwiftData/BackingData.swift:866: Fatal error: This model instance was invalidated because its backing data could no longer be found the store. PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: COREDATA_ID_URL), implementation: SwiftData.PersistentIdentifierImplementation) What could cause this error? Could you suggest me a workaround?
2
0
584
Dec ’24
SwiftData Query filter().first crashed in iOS18.2
Hi There, I have a iOS App which has been published and purely managing data by SwiftData. I use following simple codes everywhere in Views: ... @Query var items: [Item] .... if let firstItem = items.first( where: {...}) { ... Then I encountered crash at Query that _items.wrapperdValue has some errors. Then I tried to split first(where...) into ordinary way: let filteredItems = items.filter(...) if let firstItem = filteredItems.first { ... It runs OK. Is it a bug in SwiftData in 18.2 or I missed some steps to facilitate SwiftData macros?
1
0
289
Dec ’24
Problem with deleting SDP service (macOS, IOBluetooth)
Hello everyone. macOS, IOBluetooth framework. My goal is to create a temporary SDP service. According to the documentation, by default a temporary service is created (aka Persistent = NO), which is deleted after the application is closed. The documentation also mentions the IOBluetoothRemoveServiceWithRecordHandle function for forced removal of the service. This function is deprecated and is currently unavailable. I guesse that it has been replaced by the IOBluetoothSDPServiceRecord.removeServiceRecord method. The essence of the problem is that the server is not deleted either using removeServiceRecord or even after app closing. That is, if you create several services and try to delete them, they will remain alive. Only turning Bluetooth off and on in the OS helps. I tested all versions of macOS starting with Monteray. The same behavior. for (int i = 0; i < 10; i++) { service = [IOBluetoothSDPServiceRecord publishedServiceRecordWithDictionary:dictionary]; if (!service) { NSLog(@"Failed to create service"); } else { [service getRFCOMMChannelID:&channelID]; [service getServiceRecordHandle:&serverHandle]; NSLog(@"A new service has been created handle=%u, channelID=%hhu", serverHandle, channelID); if (service.removeServiceRecord != kIOReturnSuccess) { NSLog(@"Failed to delete service"); } //service.release; service = nil; } } Can someone confirm this behavior? And is there a solution? A minimal test example is available at the link
1
1
524
Dec ’24
Strange crash when using .values from @Published publisher
Given the below code with Swift 6 language mode, Xcode 16.2 If running with iOS 18+: the app crashes due to _dispatch_assert_queue_fail If running with iOS 17 and below: there is a warning: warning: data race detected: @MainActor function at Swift6Playground/PublishedValuesView.swift:12 was not called on the main thread Could anyone please help explain what's wrong here? import SwiftUI import Combine @MainActor class PublishedValuesViewModel: ObservableObject { @Published var count = 0 @Published var content: String = "NA" private var cancellables: Set<AnyCancellable> = [] func start() async { let publisher = $count .map { String(describing: $0) } .removeDuplicates() for await value in publisher.values { content = value } } } struct PublishedValuesView: View { @ObservedObject var viewModel: PublishedValuesViewModel var body: some View { Text("Published Values: \(viewModel.content)") .task { await viewModel.start() } } }
2
0
408
Dec ’24
Inquiry about WebRTC camera access when using Chrome browser and WKWebView API on iPadOS
We are Java application developers and we have a question regarding camera access via WebRTC on iPadOS. Specifically, on iPadOS 17.1, we are encountering an issue when trying to access the camera via the WKWebView API in the Chrome browser, where an error occurs and the camera capture fails. Our investigation suggests that device access through the navigator.mediaDevices property via the WKWebView API may not work in Chrome. However, it works as expected in the Safari browser, leading us to wonder if this is a Chrome-specific limitation, or if it's due to an iPadOS setting or specification. At this point, we are unsure if this issue is related to the WKWebView and WebRTC specifications on iPadOS 17.1, or if there are specific limitations in Chrome. We would appreciate any insights or solutions regarding camera access in iPadOS 17.1 with WKWebView and WebRTC, especially in relation to Chrome.
1
0
387
Dec ’24
Instance methods don't work on iOS18.2.
I am using CHCSVParser in objective-c to use the CSVString extension of the Array instance method. When I installed a new app on iOS18.1.1, the correct value (@"Application,"abc,def"") was returned for both the first and second turns, but when I installed a new app on iOS18.2, the correct value was returned for the first turn, but @"" was returned for the second turn. Even when I debug with step into, I can enter the CSVString for the first turn, but I cannot enter it for the second turn and after. It's as if the instance method is not being generated. There are in-app purchases between the first and second turns, but the view controllers that are called are also the same. Is there any change between iOS18.1.1 and iOS18.2? [Code] NSArray *application = [NSArray arrayWithObjects:KEY_APPLICATION, @"abc,def", nil]; NSString *applistring = [application CSVString]; NSString *appliStr = [application CSVString]; [Debug window 18.1.1 First] application __NSArrayI * @"2 elements" 0x0000000302118c00 [0] __NSCFConstantString * @"Application" 0x00000001005deab8 [1] __NSCFConstantString * @"abc,def" 0x00000001005deb78 applistring __NSCFString * @"Application,"abc,def"" 0x0000000302f7d050 appliStr __NSCFString * @"Application,"abc,def"" 0x0000000302f706f0 [18.1.1 Second] application __NSArrayI * @"2 elements" 0x00000003021b5200 [0] __NSCFConstantString * @"Application" 0x00000001005deab8 [1] __NSCFConstantString * @"abc,def" 0x00000001005deb78 applistring __NSCFString * @"Application,"abc,def"" 0x0000000302ff6dc0 appliStr __NSCFString * @"Application,"abc,def"" 0x0000000302fa4d20 [18.2 First] sapplication __NSArrayI * @"2 elements" 0x00000003019d7e80 [0] __NSCFConstantString * @"Application" 0x00000001041c6ab8 [1] __NSCFConstantString * @"abc,def" 0x00000001041c6b78 applistring __NSCFString * @"Application,"abc,def"" 0x000000030179e430 appliStr __NSCFString * @"Application,"abc,def"" 0x000000030179e5e0 [18.2 Second] application __NSArrayI * @"2 elements" 0x00000003019679a0 [0] __NSCFConstantString * @"Application" 0x00000001041c6ab8 [1] __NSCFConstantString * @"abc,def" 0x00000001041c6b78 applistring __NSCFConstantString * @"" 0x00000001efa04768 appliStr __NSCFConstantString * @"" 0x00000001efa04768
0
0
363
Dec ’24
traitCollectionDidChange iOS18
iOS18.2 / iPhone 16pro / Xcode 16.2 'traitCollectionDidChange' This function has been deprecated since ios17. However, in ios18, when I changed the app to the background state or changed it to the foreground state again, it was confirmed that the function worked. It hasn't been confirmed in ios17, but why is it only confirmed in ios18?
0
0
423
Dec ’24
Can't use Link in .systemLarge widget
I just added a .systemLarge widget to my app, but I can't get Links to work. I want the user to be able to tap one of the four rows in my widget - like the EmojiRangers example - but I can't get it to work. I watched a Developer video from WWDC20: https://developer.apple.com/videos/play/wwdc2020/10036?time=223 The guy, Izzy, 'simply' embeds an HStack in a Link, and hey presto! It all works. But that doesn't happen for me. There's clearly some code in the background that runs. I already have .widgetURL working for .systemSmall and .systemMedium widgets, and I don't need to use Links on those two types. Those work by sending a URL to .onOpenURL { incomingURL in ... All good there, no issues. I've wrapped each row in the large widget in a Link with the URL of something like myappurlscheme://widgetTapped/widgetId (it's the same url as that used in the small and medium widgets). I build & run. I tap a row. It doesn't act as though a row is tappable (it doesn't go slightly transparent), and just opens the app without hitting .onOpenURL or anything else. Nothing in my scene delegate is triggered. Is there a specific delegate method that gets called? Do I need to set up some awful intents? I'm not using any sort of NavigationStack here; that model doesn't fit my app. Any ideas? Thanks.
1
0
403
Dec ’24
AppleScriptLauncher Menu App
I'm primarily an AppleScript writer and only a novice programmer, using ChatGPT to help me with the legwork. It has helped me to write a functioning app that builds a menu structure based on the scripts I have in the Scripts directory used in the script menu and then runs the applescripts. When I distribute the app to my desktop and run it, the scripts that access other apps, like InDesign will cause it to launch, but not actually do anything. I included the ids for each app in the entitlements dictionary and have given the app full disk access in system settings, but it's not functioning as I'd expect. I know there are apps like Alfred that allow you to run scripts from a keystroke, but I'm building this for others I work with so they can also access info about each script, what it does, and how to use it from the menu, as well as key commands to run them. Not sure what else to say, but if this sounds like a simple fix to anyone, please let me know.
0
0
352
Dec ’24
Database Download Record Fetch Fails in MacOS 15.2
A program I wrote in Swift that uploads and downloads to a private database in iCloud is failing for downloads since the the 15.2 update. It still works for uploads. I.e., I can download uploads made from the program under 15.2 on another computer running the same program under 15.1 The Fetch operation does not return an error, but the returnRecord is empty! I do get the error below after the fact of the failure, don't know if it's related. "ViewBridge to RemoteViewService Terminated: Error Domain=com.apple.ViewBridge Code=18 "(null)" UserInfo={com.apple.ViewBridge.error.hint=this process disconnected remote view controller -- benign unless unexpected, com.apple.ViewBridge.error.description=NSViewBridgeErrorCanceled}" To be clear, I assume I do have access to the database since it works for upload under 15.2, as well as upload and download under 15.1, and from a very similar program on my iPhone (which I haven't updated yet!) Questions? Comments? Thanks!
0
1
326
Dec ’24
Passing compatible primitive types as reference in cpp-swift interop
I have an xcode project which has both cpp and swift code. In one of my usecase I am passing primitive type variables from swift to cpp by reference( primitives types list here as per the new cpp-swift interop documentation) swift code: // primitive check code:Bool var x : Bool = true // When we are passing a variable as a Reference, we need to use explicitly use'&' student.PassBoolAsReferenceType (&x) // interop call to cpp code print (x) Cpp code: void Student::PassBoolAsReferenceType(bool &pValue) noexcept { std::cout << pValue << std::endl; pValue = false; } The above code fails during compilation with no clear error message "Command SwiftCompile failed with a nonzero exit code" However, all the other primitive types that I tested worked for the above code like Int, Float, Double etc. Only the Bool interop fails. Can someone explain why is it not possible for bool? I m using the new interop introduced in swift 5.9.
1
0
303
Dec ’24
String functions problems on iOS18
On iOS 18 some string functions return incorrect values in some cases. Found problems on replacingOccurrences() and split() functions, but there may be others. In the results of these functions in some cases a character is left in the result string when it shouldn't. This did not happen on iOS17 and older versions. I created a very simple Test Project to reproduce the problem. If I run these tests on iOS17 or older the tests succeed. If I run these tests on iOS18 the tests fail. test_TestStr1() function shows a problem in replacingOccurrences() directly using strings. test_TestStr2() function shows a problem in split() that seems to happen only when bridging from NSString to String. import XCTest final class TestStrings18Tests: XCTestCase { override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. } func test_TestStr1() { let str1 = "_%\u{7}1\u{7}_"; let str2 = "%\u{7}1\u{7}"; let str3 = "X"; let str4 = str1.replacingOccurrences(of: str2, with: str3); //This should be true XCTAssertTrue(str4 == "_X_"); } func test_TestStr2() { let s1 = "TVAR(6)\u{11}201\"Ã\"\u{11}201\"A\""; let s2 = s1.components(separatedBy: "\u{11}201"); let t1 = NSString("TVAR(6)\u{11}201\"Ã\"\u{11}201\"A\"") as String; let t2 = t1.components(separatedBy: "\u{11}201"); XCTAssertTrue(s2.count == t2.count); let c = s2.count //This should be True XCTAssertTrue(s2[0] == t2[0]); } }
5
0
409
Dec ’24
How to dismiss an ImmersiveSpace when the main window closes?
I noticed that when I enter the fully immersive view and then click the X button below the window, the immersive space remains active, and the only way to dismiss it is to click the digital crown. On other apps (Disney+ for example), closing out of the main window while in immersive mode also closes out the immersive space. I tried applying an onDisappear modifier to the the Modules view with a dismissImmersiveSpace, but that doesn't appear to do anything. Any help would be appreciated.
1
0
368
Dec ’24
Best way to convert HTML to PDF in a C# app on macOS?
I'm working on a cross-platform C# application that converts HTML content to PDF. The goal is to render dynamic HTML pages (including CSS and JavaScript) as high-quality, printable PDF files. Additionally, I need to support features like adding headers/footers, securing PDFs with passwords, and controlling user permissions. While everything works well on Windows, I need some help rendering consistency and handling permissions on MacOS.
6
0
663
Dec ’24
The UWB performance of iOS18 is different from that of iOS17
Hello, dear engineer: The UWB Accessory used by my APP has inconsistent code callbacks on iOS17 and iOS18. I have connected multiple UWB Accessory by Accessory Single Configuration Data (UUID: 95e8d9d5-d8ef-4721-9a4e-807375f53328) in the APP. In iOS17.5.1, the unconnected Accessory calls the func session in the NiSessionDelegate (_ session: NISession, didRemove nearbyObjects: [NINearbyObject], "reason: NINearbyObject RemovalReason)," reason is the timeout. iOS18.0.1 does not call didRemove and fails to connect automatically after 10 minutes on the disconnected Accessory. iOS18.2 does not call didRemove. After 10 minutes, when the Accessory is not connected, it automatically connects and starts ranging. Therefore, I would like to ask what is updated in iOS18 UWB? Is there a document for reference, or can you provide the callback performance of each iOS version for UWB? The code is as follows: niConfiguration = try NINearbyAccessoryConfiguration(data: Data(AccessoryUwbConfigData)) uwbSession.run(niConfiguration)
0
0
367
Dec ’24
Best way to measure days between dates
Hey team I'm facing an issue where startDate is 1 January 2025 and endDate is 31 March 2025 between this 2 dates is 90 days, but on my code is being taken as 89 days I've seen the math of the code excludes the first partial day (from midnight to 06:00) on 2025-01-01, which results in 89 full days instead of 90 days. startDate: 2025-01-01 06:00:00 +0000 endDate: 2025-03-31 06:00:00 +0000 this is my function func daysBetweenDates() -> Int? { guard let selectedStartDate = selectedStartDate?.date else { return nil } guard let selectedEndDate = selectedEndDate?.date else { return 0 } let calendar = Calendar.current let dateComponents = calendar.dateComponents([.day], from: selectedStartDate, to: selectedEndDate) return dateComponents.day } what I've tried is reset the hours to 0 so it can take the full day and return 90 days like this func daysBetweenDates() -> Int? { guard let selectedStartDate = selectedStartDate?.date else { return nil } guard let selectedEndDate = selectedEndDate?.date else { return 0 } var calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone(secondsFromGMT: 0) ?? .current let cleanMidNightStartDate = calendar.startOfDay(for: selectedStartDate) let cleanMidNightEndDate = calendar.startOfDay(for: selectedEndDate.addingTimeInterval(24 * 60 * 60)) let dateComponents = calendar.dateComponents([.day], from: cleanMidNightStartDate, to: cleanMidNightEndDate) let daysCount = dateComponents.day ?? 0 return daysCount } this worked for that date specifically but when I tried to change the date for example startDate: 18 December 2024. endDate: 18 March 2025. between those dates we have 90 days but this function now reads 91. what I'm looking is a cleaver solution for this problem so I can have the best posible quality code, thanks in advance!
1
0
368
Dec ’24
UIViewRepresentable is not working
I have been trying to integrate a UIKit view into SwiftUI, specifically a WKWebView. However, I keep encountering a does not conform to protocol error. Here's my code: import SwiftUI import WebKit struct SimpleWebView: View { var body: some View { WebViewContainerRepresentable() .edgesIgnoringSafeArea(.all) } } struct WebViewContainerRepresentable: UIViewRepresentable { typealias UIViewType = WKWebView func makeUIView(context: Context) -> WKWebView { let webView = WKWebView() if let url = Bundle.main.url(forResource: "index", withExtension: "html") { webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent()) } return webView } func updateUIView(_ uiView: WKWebView, context: Context) { // Updates not required for this use case } } I tried this with other views as well, and it turns out this is not WKWebView-specific. The minimum deployment version is iOS 15. Any help would be much appreciated. Let me know if I need to add any more information.
1
0
402
Dec ’24