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

All subtopics

Post

Replies

Boosts

Views

Activity

SwiftData fetch request publisher returns only one value
I am using repository pattern in my app so the repository has such a function: func getAll() throws -> some Publisher<[CryptoPrice], Never> { let descriptor = FetchDescriptor<CryptoPriceDbEntity>() let testPublisher = try context.fetch(descriptor) .publisher .print() .map { dbEntity in CryptoPriceMapper.mapFromDbEntity(dbEntity) } .collect() .print() .eraseToAnyPublisher() //FIXME: this publisher send one value and then close. Is it normal behaviour of swift Data return testPublisher } and the view model subscribe to this. I was expecting the view model to receive the new query result whenever it the database changes as a constant stream. But I was surprised to see the publisher send some data once and then it close immediately. Is it normal behaviour of SwiftData or is there a big in this code ?
1
0
927
Aug ’23
[Needs Urgent Help!] Command SwiftCompile failed with a nonzero exit code
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace. Stack dump: 0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Common/Toast/Toast.swift /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Shop/CheckOutViewController.swift /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Common/UITextField/NLPaddedTextFieldView.swift ... ... /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/SettingsVC.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DGElasticPullToRefreshConstants.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DGElasticPullToRefreshView.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/CountDownRouterVC.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DatePickerTableViewCell.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/CircularProgress.o 1. Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100) 2. Compiling with the current language version 3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for IPPT) 4. While running pass #670343 SILModuleTransform "DeadFunctionAndGlobalElimination". Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 swift-frontend 0x0000000109b7f300 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) + 56 1 swift-frontend 0x0000000109b7e2e4 llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x0000000109b7f910 SignalHandler(int) + 344 3 libsystem_platform.dylib 0x000000019418aa24 _sigtramp + 56 4 swift-frontend 0x00000001052bb65c (anonymous namespace)::DeadFunctionAndGlobalEliminationPass::run() + 424 5 swift-frontend 0x00000001052bb65c (anonymous namespace)::DeadFunctionAndGlobalEliminationPass::run() + 424 6 swift-frontend 0x00000001054214a0 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&amp;) + 15312 7 swift-frontend 0x0000000105442a04 swift::SimpleRequest&lt;swift::ExecuteSILPipelineRequest, std::__1::tuple&lt;&gt; (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1&gt;::evaluateRequest(swift::ExecuteSILPipelineRequest const&amp;, swift::Evaluator&amp;) + 56 8 swift-frontend 0x0000000105428dd4 llvm::Expected&lt;swift::ExecuteSILPipelineRequest::OutputType&gt; swift::Evaluator::getResultUncached&lt;swift::ExecuteSILPipelineRequest&gt;(swift::ExecuteSILPipelineRequest const&amp;) + 484 9 swift-frontend 0x000000010542b714 swift::runSILOptimizationPasses(swift::SILModule&amp;) + 400 10 swift-frontend 0x0000000104c09c10 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 524 11 swift-frontend 0x0000000104a6d51c performCompileStepsPostSILGen(swift::CompilerInstance&amp;, std::__1::unique_ptr&lt;swift::SILModule, std::__1::default_delete&lt;swift::SILModule&gt; &gt;, llvm::PointerUnion&lt;swift::ModuleDecl*, swift::SourceFile*&gt;, swift::PrimarySpecificPaths const&amp;, int&amp;, swift::FrontendObserver*) + 1040 12 swift-frontend 0x0000000104a70ab8 performCompile(swift::CompilerInstance&amp;, int&amp;, swift::FrontendObserver*) + 3288 13 swift-frontend 0x0000000104a6e944 swift::performFrontend(llvm::ArrayRef&lt;char const*&gt;, char const*, void*, swift::FrontendObserver*) + 4308 14 swift-frontend 0x0000000104a3368c swift::mainEntry(int, char const**) + 4116 15 dyld 0x0000000193e03f28 start + 2236 Command SwiftCompile failed with a nonzero exit code I need help understanding the root cause to resolve. Overwhelmed by the log :(
4
0
1.6k
Aug ’23
Xcode 15 beta 6: Undefined symbols, Linker command failed with exit code 1
Switched from Xcode 14.3.1 to Xcode 15 beta 6. My project does not build now. I fix one error - I get another. Works fine on 14.3.1 of course. Macbook Pro M1. Here are errors I got: DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS. I changed all DT_TOOLCHAIN_DIR to TOOLCHAIN_DIR. Then i got 'Stored properties cannot be marked unavailable with @available' in one pod, I removed these lines to silence this exception. Then some pods (SwiftSoup, Starscream, PromiseKit) gave me different errors, that I avoided with changing their min iOS version to 14.0. And finally I stuck with two errors: 'Undefined symbols' and 'Linker command failed with exit code 1'. None of them give me any info or show me the exact place of error. I tried updating, reinstalling cocoapods, reinstalling all pods, cleaning derived data, cleaning build folder, adding -v to 'other linker flags'. Nothing gave me any clue.
4
2
3.8k
Aug ’23
iOS 16.4 and above - lower photo resolution AVCamera
Hi all, I am experiencing a problem with front camera when app is running on device with iOS with 16.4 or later. My app is using the front camera and it captured photo with maximum resolution which I am setting by using AVCaptureSession.Preset.photo. When I am capturing photos on device with iOS 16.3 and below, maximum resolution of captured photo is 3384x4512. But when the same code is run on device with iOS 16.4 and above - maximum resolution is way more below the 3384x4512 and it varies depending of the specific device (iPhone 12, iPhone 13 Pro, iPhone 14). Below is the code used for configuring the session: guard let device = AVCaptureDevice.default(AVCaptureDevice.DeviceType.builtInWideAngleCamera, for: .video, position: .front) else { print("No front facing camera found") return } session.beginConfiguration() var frontInput: AVCaptureInput? do { frontInput = try AVCaptureDeviceInput(device: device) } catch let error { print("ERROR WITH FRONT CAMERA: \(error)") } if let inputFr = frontInput, session.canAddInput(inputFr) { session.addInput(inputFr) } let output = AVCaptureVideoDataOutput() output.alwaysDiscardsLateVideoFrames = true let queue = DispatchQueue(label: "cameraQueue") output.setSampleBufferDelegate(self, queue: queue) output.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_32BGRA)] session.addOutput(output) session.sessionPreset = AVCaptureSession.Preset.photo session.commitConfiguration() Does anybody else experiencing problem with lower resolution on devices with iOS 16.4 and above?
3
0
600
Aug ’23
Instruments - Swift Concurrency not working
Hello, I am trying to debug Swift Concurrency codes by using Swift Concurrency Instruments. But in our project which has been maintained for a long time, Swift Concurrency Instruments seems not working. Task { print("async code") await someAsyncFunction() } When I run Swift Concurrency Instruments with the above codes in our project, I could check that the print works well by checking stdout/stderr Instruments, but there are no records on Swift Concurrency Instruments. But in the small simple sample project, I checked that Swift Concurrency Instruments works well. Are there any settings that I need to do for the legacy project to debug Swift Concurrency?
10
0
1.5k
Sep ’23
Unable to Verify App: An internet connection is required to verify the trust of the developer' ... This app will not be available until verified.
Recently after updating iPad devices on 16.6, our devices is giving following error on all of our enterprise applications. Unable to verify app. An internet connection is required to verify the trust of the developer iOS version of iPad devices -> 16.6 Xcode version -> 14.2(14C18) Certificates and provisioning profiles are valid, we have cross checked that and it is causing only on few of our devices. Below are the screen shots attached for info:
7
2
3.6k
Sep ’23
WidgetKit - Should I access my SwiftData cloud kit synced DB from TimelineProvider or the Widget's view?
Hi there, When using WidgetKit, should I should fetch my SwiftData main app's database in the TimelineProvider or directly on the widget's view? Also, my understanding is that the widget view's code is run during the archiving process and not when the view first appears on the user's device. So, is it true that accessing in the TimelineProvider vs. accessing in the view will both run at approximately the same time, and thus will return the same DB results? Best, Taylor
1
2
691
Sep ’23
AVAudioSession allowBluetoothA2DP not working on external device iOS17 playAndRecord session
I saw a similar post to this where the issue was fixed in the final iOS17 release, but I am still having a problem since my situation is slightly different. I am wondering if its a bug based on current behavior, but was hoping maybe someone knows if the issue is with my setup? I am trying to monitor an external USB camera's audio input using the new iOS17 external call for iPad, over bluetooth. func setupAudioSession() { let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetoothA2DP, .defaultToSpeaker] ) try audioSession.setActive(true) } catch { print("Failed to set up audio session: \(error)") } } When my execution order is: setupAudioSession() // code above // discover and connect the session AV inputs to the external USB // start an audio engine // connect audio engine output to a buffer queue and play // start the session My app does not allow routing to the headphones and directly switches to speaker. However if I change the order to this: setupAudioSession() // code above // discover and connect the session AV inputs to the external USB // start an audio engine // start the session --- !starting before connecting output! // connect audio engine output to a buffer queue and play The session stays connected to Bluetooth and plays over the headphones. However if I suspend the app and relaunch, I get switched back to speaker. I understand maybe the system is trying to prevent an audio feedback loop? But don't understand why launching the session early would get the desired behavior. Any help would be greatly appreciated.
1
1
894
Sep ’23
[iOS17] AVPlayer+AudioTapProcessor fails on Apple Clock's alarm notification
Hello all, I've been developing a video player app using AVPlayer with AudioTapProcessor. Where AudioTapProcessor is used to render audio data with the custom filters. Recently, I've updated my iPhone to the newest iOS 17 and noticed an unusual behavior on system alarm triggered by the Apple Clock app. Is there a change in iOS 17 that could perhaps cause this issue? If not, does anyone have any idea where I should look into? Steps to Reproduce: Turn off Slient/Vibration Mode on the device Play AVPlayer (w/ AudioTapProcessor) Set Alarm/Timer on the Apple Clock app (set Sound other than "None") Result (Unusual Behavior): Alarm triggered without any sound AVPlayer sound stops Output log: rt_receiver::receive_loop failed: 89 AVPlayerItem.failedToPlayToEndTimeNotification gets triggered from NotificationCenter More Info: Only way to bypass (for now) is to re-initiate AVPlayer instance after AVPlayerItem.failedToPlayToEndTimeNotification Issue doesn't happen: on iOS 16.3.1 device when alarm happens before loading AVPlayer when AudioTapProcessor is detached from AVPlayer when alarm triggers from apps other than the Apple Clock Manually pause()/play() on AVAudioSession.interruptionNotification handler doesn't help Running AddressSanitizer results in "Deallocation of non-allocated memory" in libclang_rt.dylib
2
1
1.2k
Sep ’23
SwiftData randomly throwing EXC_BAD_ACCESS on Model entity creation and update
There is something that I'm spending hours trying to solve but start to be blocked. On one of my app projects, I'm experiencing random fatal errors during the access and update of SwiftData Models, which does not occur when using CoreData. This mainly happens when setting value for newly created entities: SwiftData randomly crashes the application with the following error: EXC_BAD_ACCESS (code=1, address=0x11). I made sure to update the code to move operations in the background and to use a ModelActor. It works properly, but 1 out of 3 times, it crashes with the error quoted. I also tried to look at previous posts and made sure to persist the context when creating new entities, before updating them. The last information in my console before “(lldb)” is: CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2996): &amp;lt;NSCloudKitMirroringDelegate: 0x2806342a0&amp;gt;: Observed context save: &amp;lt;NSPersistentStoreCoordinator: 0x281434c40&amp;gt; - &amp;lt;NSManagedObjectContext: 0x280450820&amp;gt; CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate remoteStoreDidChange:](3039): &amp;lt;NSCloudKitMirroringDelegate: 0x2806342a0&amp;gt;: Observed remote store notification: &amp;lt;NSPersistentStoreCoordinator: 0x281434c40&amp;gt; - FF2D0015-7121-4C30-9EE3-2A51A76C303B - &amp;lt;NSPersistentHistoryToken - { "FF2D0015-7121-4C30-9EE3-2A51A76C303B" = 1316; }&amp;gt; - file:///private/var/mobile/Containers/Shared/AppGroup/ED0B229A-F5BC-47B7-B7BC-88EEFB6E6CA8/Library/Application%20Support/default.store CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate managedObjectContextSaved:](2996): &amp;lt;NSCloudKitMirroringDelegate: 0x2806342a0&amp;gt;: Observed context save: &amp;lt;NSPersistentStoreCoordinator: 0x281434c40&amp;gt; - &amp;lt;NSManagedObjectContext: 0x280450820&amp;gt;. In the rare occasion where it provides more details, Xcode shows issue in the @Model macro, as shown in the screenshot attached. I was able to reproduce this issue on 4 different physical devices and in the simulator. It also happens, less frequently, when trying to fetch a Model entity from the SwiftData context. Not for specific models tho, it can happen for all of them, randomly. I was able to experience this random problem both on iOS 17.0 Developer Beta, RC &amp;amp; the official iOS 17.0 release. At the time in the beta Xcode 15, and now the latest stable Xcode. Am I the only one having this kind of issues? Or is it a known issue with Swift? Anybody has idea how I could solve that?
5
2
2.5k
Sep ’23
SwiftData: Accessing a context outside of a view not possible.
Getting a warning from the Xcode compiler about accessing a context outside of a view. It popped up in white text on a purple background, not the usual white on yellow warning color. The actual warning text is: Accessing Environment's value outside of being installed on a View. This will always read the default value and will not update. This seems to mean that any datastore access must be done within a view, and isn't possible from the model or some sort of DataManager class. Am I reading this correctly? I'm trying to keep the business logic out of the views. I can do it with everything except the datastore code because of this context issue. Doesn't seem to make sense. Suggestions greatly appreciated.
4
2
2.8k
Sep ’23
App Store listing does not show all localised Languages
The Problem: The App Store listing of my app does not show all languages the app is localised in: The Question: How to fix this? A potential reason I could imagine might be, that the App Store looks for the files localised, and Xcode shows 0 localised files in English for my app, because English is my development language and all Strings are in English like that: Text("Reload", comment: "Menu action to reload feed") I really don't want to translate every English word, to English like "Reload" = "Reload". What am I getting wrong here? How can I have the App Store show both supported languages? The current implementation: My app supports two languages and I am using the new String catalog for localising. Both languages work while testing on device and are available from the App Settings in the System settings app to switch between:
3
0
1.6k
Sep ’23
How to save FamilyActivitySelection in FirebaseFirestore
Hi, I'm developing an app like Opal which uses Screen Time API. So the user should be able to create modes to activate it later, like an alarm. There's a list of durations and mode names and there should be selected apps, so whenever the user turns the switch on, app restricting should be started. How can I save the selected apps in FirebaseFirestore, and then get that data to restrict the apps whenever the user turns the switch on? I've tried to save it as Strings, but I can't convert it later to ApplicationToken to insert it to Set.
2
2
746
Sep ’23
'main' attribute cannot be used in a module that contains top-level code
Hi! I'm having this issue that wasn't present before in this project. In my app's entry file, which is named 'controlShiftApp.swift' and NOT 'main.swift' (which has been documented to cause the same error), the @main attribute gives the following error: 'main' attribute cannot be used in a module that contains top-level code I have no other files named main.swift in this target. I only have main.swift in the targets for system extensions. I also haven't used @main anywhere else in this project. Here is a screenshot to show you what I mean. I'd really appreciate inputs on this matter. I need to get this fixed so that I can continue my development ASAP. Also, I'm new to Swift so many things are not as trivial to me, and I would like it if you could give me clear steps on how to resolve this. Thanks!
2
0
1.5k
Sep ’23
os_log Unified Logging not anymore tide to stderr in iOS 17?
Currently I have a setup which duplicates the stderr STDERR_FILENO pipe into a separate one. Then by setting up a readabilityHandler (on the new Pipe) I can capture the logged data and either store it inside a File, adjust/modify the data etc. Since iOS 17 this is not possible anymore (previous versions worked iOS 16)? I cannot find any documentation on why or what changed on the os_log side. private func setupPipes() { inputPipe.fileHandleForReading.readabilityHandler = { [weak self] handler in guard let strongSelf = self else { return } let data = handler.availableData strongSelf.queue.async(flags: .barrier) { guard let fileHandle = try? FileHandle(forWritingTo: strongSelf.filePath) else { return } fileHandle.seekToEndOfFile() fileHandle.write(data) try? fileHandle.close() } strongSelf.outputPipe.fileHandleForWriting.write(data) } dup2(STDERR_FILENO, outputPipe.fileHandleForWriting.fileDescriptor) dup2(inputPipe.fileHandleForWriting.fileDescriptor, STDERR_FILENO) }
8
0
1.5k
Oct ’23
Finding device heading with ARKit and ARGeoTrackingConfiguration
I am working on an app where I need to orient a custom view depending on the device heading. I am using ARKit and ARSCNView with the ARGeoTrackingConfiguration in order to overlay my custom view in real world geographic coordinates. I've got a lot of it working, but the heading of my custom view is off. Once the ARSession gets a ARGeoTrackingStatus.State of .localized, I need to be able to get the devices heading (0-360) so that I can orient my view. I'm having trouble figuring out how to do this missing piece. Any help is appreciated.
3
1
1.2k
Oct ’23