Swift is a powerful and intuitive programming language for Apple platforms and beyond.

Posts under Swift tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Behavior of Drawings in Portrait/Landscape Mode
The app provides a simple drawing functionality on a canvas without using a storyboard. After creating drawings in portrait mode, rotating the simulator or the iPad-Device to landscape mode does not update or rescale the existing drawings to fit the newly expanded canvas area. The app can also be launched directly in landscape mode, allowing drawings to be created before rotating the device back to portrait mode. However, the issue persists, with the drawings not adjusting to the new canvas dimensions. The goal is to achieve the same behavior as in the Apple Notes app: when the iPad is rotated, the drawings should adjust to the newly expanded or reduced canvas area. I would appreciate any suggestions or solutions. Sample Projekt [https://github.com/GG88IOS/Test_Drawing_App)
4
0
91
May ’25
Random crash on app language change from app
I've developed an app in swift and UIKit. Its multi linguistic app supports English and Arabic. When I change the language from English to Arabic or Arabic to English. After changing language, when I navigate through different screens crash is happening randomly on different screens most of the time when I tap to navigate to a screen. And cash log is: This time crashed with this error Exception NSException * "Not possible to remove variable:\t945: <unknown var (bug!) with engine as delegate:0x2824edf00>{id: 34210} colIndex:261 from engine <NSISEngine: 0x15c5dd5f0>{ delegate:0x15c594b50\nEngineVars:\n\t 0: objective{id: 31542} rowIndex:0\n\t 1: UIButton:0x15c6255b0.Width{id: 31545} rowIndex:1\n\t 2: 0x281c41450.marker{id: 31548} colIndex:1\n\t 3: UIButton:0x15c6255b0.Height{id: 31547} rowIndex:1073741824\n\t 4: 0x281c412c0.marker{id: 31546} colIndex:1073741825\n\t 5: UIButton:0x15c625a50.Width{id: 31549} rowIndex:11\n\t 6: 0x281c41270.marker{id: 31544} colIndex:2\n\t 7: UIButton:0x15c625a50.Height{id: 31551} rowIndex:1073741825\n\t 8: 0x281c414a0.marker{id: 31550} colIndex:1073741826\n\t 9: UILabel:0x15c625d10.Height{id: 31553} rowIndex:1073741826\n\t 10: 0x281c41590.marker{id: 31552} colIndex:1073741827\n\t 11: UIImageView:0x15c625870.Width{id: 31555} rowIndex:3\n\t 12: 0x281c41360.marker{id: 31554} colIndex:3\n\t 13: UIImageView:0x15c625870.Height{id: 31557} rowIndex:1073741827\n\t 14: 0x281c413b0.marker{id: 31556} colIndex:1073741828"... 0x0000000282fb11a0 For switching language I'm using this code snippet: private func restartApp() { guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let delegate = windowScene.delegate as? SceneDelegate, let window = delegate.window else { return } // Create a new root view controller let vc : AppLoadingVC = AppRouter.instantiateViewController(storyboard: .Splash) let nc = UINavigationController(rootViewController: vc) ApplicationManager.sharedInstance.isUserLoggedIn = false DispatchQueue.main.async { if UserDefaults.isRTL { UIView.appearance().semanticContentAttribute = .forceRightToLeft SideMenuController.preferences.basic.forceRightToLeft = true Localize.setCurrentLanguage("ar") } else { UIView.appearance().semanticContentAttribute = .forceLeftToRight SideMenuController.preferences.basic.forceRightToLeft = false Localize.setCurrentLanguage("en") } window.rootViewController = nc window.makeKeyAndVisible() } } Please anybody help me I've been stuck here since lot of days. I tried multiple things but all in vain.
1
0
52
Apr ’25
App Crashes on Paper Selection After Background Printer Connection
Description: 1. When initiating the print flow via UIPrintInteractionController, and no printer is initially connected, iOS displays all possible paper sizes in the paper selection UI. However, if a printer connects in the background after this view is shown, the list of paper sizes does not automatically refresh to reflect only the options supported by the connected printer. 2. If the user selects an incompatible paper size (one not supported by the printer that has just connected), the app crashes due to an invalid configuration. Steps to Reproduce: Launch the app and navigate to the print functionality. Tap the Print button to invoke UIPrintInteractionController. At this point, no printer is yet connected. iOS displays all available paper sizes. While the paper selection UI is visible, the AirPrint-compatible printer connects in the background. Without dismissing the controller, the user selects a paper size (e.g., one that is not supported by the printer). The app crashes. Expected Result: App should not crash Once the printer becomes available (connected in the background), the paper size options should refresh automatically. The list should be filtered to only include sizes that are compatible with the connected printer. This prevents the user from selecting an invalid option, avoiding crashes. Actual Result: App crashes The paper size list remains unfiltered. The user can still select unsupported paper sizes. Selecting an incompatible option causes the app to crash, due to a mismatch between UI selection and printer capability. Demo App Crash : https://drive.google.com/file/d/19PV02wzOJhc2DYI6kAe-uxHuR1Qg15Bu/view?usp=sharing Apple Files App Crash: https://drive.google.com/file/d/1flHKuU_xaxHSzRun1dYlh8w7nBPJZeRb/view?usp=sharing
1
0
64
1w
Scrollview and a background image set to scaledToFill....
I've been beating my head against the wall over a scrollview issue where the top and bottom are cut off in landscape mode. Portrait mode - everything runs swimmingly. The moment I flip the iPad on its side, though, I lose about a quarter of the view on the top and bottom. I thought this was something to do with framing or such; I ran through a myriad of frame, padding, spacer, geometry...I set it static, I set it to dynamically grow, I even created algorithms to try to figure out how to set things to the individual device. Eventually, I separated the tablet and phone views as was suggested here and on the Apple dev forums. That's when I started playing around with the background image. Right now I have.... ZStack { Image("background") .resizable() .scaledToFill() .ignoresSafeArea() ScrollView { VStack(spacing: 24) {.... The problem is the "scaledToFill". In essence, whenever THAT is in the code, the vertical scrollview goes wonky in landscape mode. It, in essence, thinks that it has much more room at the top and the bottom because the background image has been extended at top and bottom to fill the wider screen of the iPad in landscape orientation. Is there any way to get around this issue? The desired behavior is pretty straightforward - the background image fills the entire background, no white bars or such, and the view scrolls against it.
3
0
116
Apr ’25
Cannot use instance member 'input_parameter' within property initializer; property initializers run before 'self' is available
I am passing UUID Key from View1 to View2. In View2, I need to Fetch entries using TabKey. userId is global variable working fine. Giving error TabKey. Please help. how to get rid of this error. If I keep this logic inside init method, Getting new error saying that "Cannot convert value of type 'FetchedResults' to expected argument type 'Binding' Here is the Code. @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \Table2.date, ascending: false)], predicate: { guard let currentUserId = AppSession.shared.currentUserId else { return NSPredicate(value: false) // Or handle the nil case as needed } return NSPredicate(format: "userId == %@ AND itemKey == %@", currentUserId as CVarArg, TabKey as CVarArg ) }(), animation: .default ) private var itab: FetchedResults
0
0
33
Apr ’25
How to obtain video streams from the digital space included in VisionPro after applying for the "Enterprise API"?
After implementing the method of obtaining video streams discussed at WWDC in the program, I found that the obtained video stream does not include digital models in the digital space or related videos such as the program UI. I would like to ask how to obtain a video stream or frame that contains only the physical world? let formats = CameraVideoFormat.supportedVideoFormats(for: .main, cameraPositions:[.left]) let cameraFrameProvider = CameraFrameProvider() var arKitSession = ARKitSession() var pixelBuffer: CVPixelBuffer? var cameraAccessStatus = ARKitSession.AuthorizationStatus.notDetermined let worldTracking = WorldTrackingProvider() func requestWorldSensingCameraAccess() async { let authorizationResult = await arKitSession.requestAuthorization(for: [.cameraAccess]) cameraAccessStatus = authorizationResult[.cameraAccess]! } func queryAuthorizationCameraAccess() async{ let authorizationResult = await arKitSession.queryAuthorization(for: [.cameraAccess]) cameraAccessStatus = authorizationResult[.cameraAccess]! } func monitorSessionEvents() async { for await event in arKitSession.events { switch event { case .dataProviderStateChanged(_, let newState, let error): switch newState { case .initialized: break case .running: break case .paused: break case .stopped: if let error { print("An error occurred: \(error)") } @unknown default: break } case .authorizationChanged(let type, let status): print("Authorization type \(type) changed to \(status)") default: print("An unknown event occured \(event)") } } } @MainActor func processWorldAnchorUpdates() async { for await anchorUpdate in worldTracking.anchorUpdates { switch anchorUpdate.event { case .added: //检查是否有持久化对象附加到此添加的锚点- //它可能是该应用程序之前运行的一个世界锚。 //ARKit显示与此应用程序相关的所有世界锚点 //当世界跟踪提供程序启动时。 fallthrough case .updated: //使放置的对象的位置与其对应的对象保持同步 //世界锚点,如果未跟踪锚点,则隐藏对象。 break case .removed: //如果删除了相应的世界定位点,则删除已放置的对象。 break } } } func arkitRun() async{ do { try await arKitSession.run([cameraFrameProvider,worldTracking]) } catch { return } } @MainActor func processDeviceAnchorUpdates() async { await run(function: self.cameraFrameUpdatesBuffer, withFrequency: 90) } @MainActor func cameraFrameUpdatesBuffer() async{ guard let cameraFrameUpdates = cameraFrameProvider.cameraFrameUpdates(for: formats[0]),let cameraFrameUpdates1 = cameraFrameProvider.cameraFrameUpdates(for: formats[1]) else { return } for await cameraFrame in cameraFrameUpdates { guard let mainCameraSample = cameraFrame.sample(for: .left) else { continue } self.pixelBuffer = mainCameraSample.pixelBuffer } for await cameraFrame in cameraFrameUpdates1 { guard let mainCameraSample = cameraFrame.sample(for: .left) else { continue } if self.pixelBuffer != nil { self.pixelBuffer = mergeTwoFrames(frame1: self.pixelBuffer!, frame2: mainCameraSample.pixelBuffer, outputSize: CGSize(width: 1920, height: 1080)) } } }
0
0
77
Apr ’25
BUG IN CLIENT OF LIBMALLOC: memory corruption of free block
We've noticed a pretty common crash that's occurring in our app that appears to only be affecting iOS 18 users. The code in question is below: func getThing() async throws -&gt; ThingData { guard shouldRefresh, let data = self.thingData else { let remoteThingData = try await store.getThingData() self.thingData = remoteThingData return remoteThingData // Crash happens here } return data } The crash happens on a background thread and the actual crash is: Crashed: com.apple.root.user-initiated-qos.cooperative EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000004a67149c0 We haven't been able to reproduce the error ourselves but in the past 90 days all of the crashes (several thousand) have been only on iOS 18. We also found this thread that appears similar from 2 years ago but unsure if it's related because in our case the guard can only be calculated at runtime so there shouldn't be any optimizations happening.
1
1
661
Apr ’25
AVCapturePhotoOutput crashes at delegate callback on MacOS 13.7.5
A functioning Multiplatform app, which includes use of Continuity Camera on an M1MacMini running Sequoia 15.5, works correctly capturing photos with AVCapturePhoto. However, that app (and a test app just for Continuity Camera) crashes at delegate callback when run on a 2017 MacBookPro under MacOS 13.7.5. The app was created with Xcode 16 (various releases) and using Swift 6 (but tried with 5). Compiling and running the test app with Xcode 15.2 on the 13.7.5 machine also crashes at delegate callback. The iPhone 15 Continuity Camera gets detected and set up correctly, and preview video works correctly. It's when the CapturePhoto code is run that the crash occurs. The relevant capture code is: func capturePhoto() { let captureSettings = AVCapturePhotoSettings() captureSettings.flashMode = .auto photoOutput.maxPhotoQualityPrioritization = .quality photoOutput.capturePhoto(with: captureSettings, delegate: PhotoDelegate.shared) print("**** CameraManager: capturePhoto") } and the delegate callbacks are: class PhotoDelegate: NSObject, AVCapturePhotoCaptureDelegate { nonisolated(unsafe) static let shared = PhotoDelegate() // MARK: - Delegate callbacks func photoOutput( _ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: (any Error)? ) { print("**** CameraManager: didFinishProcessingPhoto") guard let pData = photo.fileDataRepresentation() else { print("**** photoOutput is empty") return } print("**** photoOutput data is \(pData.count) bytes") } func photoOutput( _ output: AVCapturePhotoOutput, willBeginCaptureFor resolvedSettings: AVCaptureResolvedPhotoSettings ) { print("**** CameraManager: willBeginCaptureFor") } func photoOutput(_ output: AVCapturePhotoOutput, willCapturePhotoFor resolvedSettings: AVCaptureResolvedPhotoSettings) { print("**** CameraManager: willCaptureCapturePhotoFor") } } The crash report significant parts are..... Crashed Thread: 3 Dispatch queue: com.apple.cmio.CMIOExtensionProviderHostContext Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Codes: 0x0000000000000001, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [30850] VM Region Info: 0 is not in any region. Bytes before following region: 4296495104 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 100175000-10017f000 [ 40K] r-x/r-x SM=COW ...tinuityCamera Thread 0:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x7ff803aed552 mach_msg2_trap + 10 1 libsystem_kernel.dylib 0x7ff803afb6cd mach_msg2_internal + 78 2 libsystem_kernel.dylib 0x7ff803af4584 mach_msg_overwrite + 692 3 libsystem_kernel.dylib 0x7ff803aed83a mach_msg + 19 4 CoreFoundation 0x7ff803c07f8f __CFRunLoopServiceMachPort + 145 5 CoreFoundation 0x7ff803c06a10 __CFRunLoopRun + 1365 6 CoreFoundation 0x7ff803c05e51 CFRunLoopRunSpecific + 560 7 HIToolbox 0x7ff80d694f3d RunCurrentEventLoopInMode + 292 8 HIToolbox 0x7ff80d694d4e ReceiveNextEventCommon + 657 9 HIToolbox 0x7ff80d694aa8 _BlockUntilNextEventMatchingListInModeWithFilter + 64 10 AppKit 0x7ff806ca59d8 _DPSNextEvent + 858 11 AppKit 0x7ff806ca4882 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1214 12 AppKit 0x7ff806c96ef7 -[NSApplication run] + 586 13 AppKit 0x7ff806c6b111 NSApplicationMain + 817 14 SwiftUI 0x7ff90e03a9fb 0x7ff90dfb4000 + 551419 15 SwiftUI 0x7ff90f0778b4 0x7ff90dfb4000 + 17578164 16 SwiftUI 0x7ff90e9906cf 0x7ff90dfb4000 + 10340047 17 ContinuityCamera 0x10017b49e 0x100175000 + 25758 18 dyld 0x7ff8037d1418 start + 1896 Thread 1: 0 libsystem_pthread.dylib 0x7ff803b27bb0 start_wqthread + 0 Thread 2: 0 libsystem_pthread.dylib 0x7ff803b27bb0 start_wqthread + 0 Thread 3 Crashed:: Dispatch queue: com.apple.cmio.CMIOExtensionProviderHostContext 0 ??? 0x0 ??? 1 AVFCapture 0x7ff82045996c StreamAsyncStillCaptureCallback + 61 2 CoreMediaIO 0x7ff813a4358f __94-[CMIOExtensionProviderHostContext captureAsyncStillImageWithStreamID:uniqueID:options:reply:]_block_invoke + 498 3 libxpc.dylib 0x7ff803875b33 _xpc_connection_reply_callout + 36 4 libxpc.dylib 0x7ff803875ab2 _xpc_connection_call_reply_async + 69 5 libdispatch.dylib 0x7ff80398b099 _dispatch_client_callout3 + 8 6 libdispatch.dylib 0x7ff8039a6795 _dispatch_mach_msg_async_reply_invoke + 387 7 libdispatch.dylib 0x7ff803991088 _dispatch_lane_serial_drain + 393 8 libdispatch.dylib 0x7ff803991d6c _dispatch_lane_invoke + 417 9 libdispatch.dylib 0x7ff80399c3fc _dispatch_workloop_worker_thread + 765 10 libsystem_pthread.dylib 0x7ff803b28c55 _pthread_wqthread + 327 11 libsystem_pthread.dylib 0x7ff803b27bbf start_wqthread + 15 Of course, the MacBookPro is an old device - but Continuity Camera works with the installed Photo Booth app, so it's possible. Any thoughts on solving this situation would be appreciated. Regards, Michaela
0
0
72
Apr ’25
Xcode UIKit Document App template crashes under Swift 6
I'm trying to switch to UIKit's document lifecycle due to serious bugs with SwiftUI's version. However I'm noticing the template project from Xcode isn't compatible with Swift 6 (I already migrated my app to Swift 6.). To reproduce: File -> New -> Project Select "Document App" under iOS Set "Interface: UIKit" In Build Settings, change Swift Language Version to Swift 6 Run app Tap "Create Document" Observe: crash in _dispatch_assert_queue_fail Does anyone know of a work around other than downgrading to Swift 5?
0
1
65
Apr ’25
How to read a video stream that includes both the physical world and digital space when obtaining a video stream from VisionPro by applying for the Enterprise API but only reading a video stream that contains both the physical world and digital space
We have successfully obtained the permissions for "Main Camera access" and "Passthrough in screen capture" from Apple. Currently, the video streams we have received are from the physical world and do not include the digital world. How can we obtain video streams from both the physical and digital worlds? thank you!
0
0
51
Apr ’25
iPad/iPhone - Display best practices….
So…I am hitting a wall here and could use some guidance towards best practice. I’ve developed an app in Xcode/SwiftUI that renders just fine on the iPhone - text, images, buttons, frames…everything is nicely centered on the screen or scrolls where and when I want. The iPad though…not so much. I’m having issues with tops and bottoms being cut off in scrollviews. These are just straight up text screens too - the ones with other elements/controls…they’re rendering fine. I’ve tried a mix of geometry, vstack, scrollview, padding, spacers…the lot of it. Nothing I seem to do works - the views do not want to fill and fit properly. And, of course, the issue becomes worse the moment you flip the iPad into landscape view. Or use the 13” models. I’d imagine others are battling these issues as well and found solutions, so I decided to hit up the brain trust.
3
0
116
Apr ’25
Missing Files Xcode Build Error
I have an iOS app. When I install pods via CLI to my project for the first time, launch Xcode, and then run the app, everything works fine – no build errors. But after several instances of running the project on my device, all of a sudden build errors appear like: /Pods/FirebaseCrashlytics/Crashlytics/Crashlytics/Settings/Models/FIRCLSApplicationIdentifierModel.m:19:9 'Crashlytics/Shared/FIRCLSByteUtility.h' file not found /Pods/PostHog/vendor/libwebp/ph_sharpyuv_csp.h /Pods/PostHog/vendor/libwebp/ph_sharpyuv_csp.h: No such file or directory And I have no idea why if it's because of my PodFile or any Build Settings/Phases/Rules, but this keeps happening repeatedly and it's impossible to develop anything with this. I've tried a string of commands such as "pod deintegrate", "pod cache clean --all", removing PodFile.lock and doing pod install again, removing derived data, and cleaning build folder. I still keep running into the same build error and it's always after a few builds this happens, nothing is missing prior when the project successfully builds. Here is my PodFile for reference: # Uncomment the next line to define a global platform for your project platform :ios, '17.0' def google_utilities pod 'GoogleUtilities/AppDelegateSwizzler' pod 'GoogleUtilities/Environment' pod 'GoogleUtilities/ISASwizzler' pod 'GoogleUtilities/Logger' pod 'GoogleUtilities/MethodSwizzler' pod 'GoogleUtilities/NSData+zlib' pod 'GoogleUtilities/Network' pod 'GoogleUtilities/Reachability' pod 'GoogleUtilities/UserDefaults' end target 'SE' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for SE pod 'Firebase/Core' pod 'Firebase/Firestore' pod 'Firebase/Auth' google_utilities end target 'NSE' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for NSE pod 'Firebase/Messaging' google_utilities end target 'targetApp' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! #Pods for targetApp pod 'Firebase/Core' pod 'Firebase/Crashlytics' pod 'Firebase/Messaging' pod 'Firebase/Firestore' pod 'Firebase/Storage' pod 'Firebase/Functions' pod 'PromiseKit', '~> 6.0' pod 'lottie-ios' pod 'GooglePlaces' pod 'JWTDecode', '~> 2.4' pod 'PostHog' pod 'Kingfisher', '~> 8.0' pod 'PhoneNumberKit' google_utilities end post_install do |installer| installer.aggregate_targets.each do |target| target.xcconfigs.each do |variant, xcconfig| xcconfig_path = target.client_root + target.xcconfig_relative_path(variant) IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR")) end end installer.pods_project.targets.each do |target| target.build_configurations.each do |config| if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference xcconfig_path = config.base_configuration_reference.real_path IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR")) config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '17.0' end end end installer.pods_project.targets.each do |target| if target.name == 'BoringSSL-GRPC' target.source_build_phase.files.each do |file| if file.settings && file.settings['COMPILER_FLAGS'] flags = file.settings['COMPILER_FLAGS'].split flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' } file.settings['COMPILER_FLAGS'] = flags.join(' ') end end end end end And here is my only "Run Script" in Build Phases: "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" \ -gsp "${PROJECT_DIR}/targetApp/GoogleService-Info.plist" \ -p ios \ "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
3
0
81
Apr ’25
UIPasteControl Not Recognizing Tap
I have an iOS app where I'm trying to paste something previously copied to the user's UIPasteboard. I came across the UIPasteControl as an option for a user to tap to silently paste without having the prompt "Allow Paste" pop up. For some reason, despite having what seemingly is the correct configurations for the UIPasteControl, on testing a tap, nothing is called. I expected override func paste(itemProviders: [NSItemProvider]) to fire, but it does not. Any help would be appreciated as there doesn't seem to be much info anywhere regarding UIPasteControl. import UniformTypeIdentifiers class ViewController: UIViewController { private let pasteControl = UIPasteControl() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground pasteControl.target = self pasteConfiguration = UIPasteConfiguration(acceptableTypeIdentifiers: [ UTType.text.identifier, UTType.url.identifier, UTType.plainText.identifier ]) view.addSubview(pasteControl) pasteControl.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ pasteControl.centerXAnchor.constraint(equalTo: view.centerXAnchor), pasteControl.centerYAnchor.constraint(equalTo: view.centerYAnchor), ]) } } extension ViewController { override func paste(itemProviders: [NSItemProvider]) { for provider in itemProviders { if provider.hasItemConformingToTypeIdentifier(UTType.url.identifier) { provider.loadObject(ofClass: URL.self) { [weak self] reading, _ in guard let url = reading as? URL else { return } print(url) } } else if provider.hasItemConformingToTypeIdentifier(UTType.plainText.identifier) { provider.loadObject(ofClass: NSString.self) { [weak self] reading, _ in guard let nsstr = reading as? NSString else { return } let str = nsstr as String if let url = URL(string: str) { print(url) } } } } } }
2
0
67
Apr ’25
Failed to create folder using Swift in VisionOS
When creating a folder in the code, it prompts that the file creation is successful, but when the folder does not exist in the "Download Container" file, do you have any permissions when creating the folder in VisionOS? static func getFileManager() -&gt; URL { let documentsDirectory = FileManager.default.urls( for: .documentDirectory, in: .userDomainMask ).first! return documentsDirectory.appendingPathComponent("SGKJ_LIBRARY") } static func createFileLibrary() { let folderUrl = getFileManager() let fileManager = FileManager.default do { try fileManager.createDirectory( at: folderUrl, withIntermediateDirectories: true, attributes: nil ) print("Folder created successfully: \(folderUrl.path)") } catch { print("Failed to create folder: \(error.localizedDescription)") } }
1
0
61
Apr ’25
Is It Possible to Restore Previous Browser State After openURL on iOS?
Hi Everyone, I’m currently working on a flow where a web page redirects to our app to perform certain actions, and then returns the user back to the browser. However, on iOS, the only way to go back to the browser is by using the openURL method. The issue is that this method can only open the browser app itself—it can’t control which tab or page is shown, so the user doesn’t return to the original tab they came from. The same limitation also applies to Android. Furthermore, iOS doesn’t allow an app to programmatically return to the previous app (in this case, the browser). While Android doesn’t have an official way either, in some cases, the OS automatically returns to the previous app when ours is closed. I’d like to ask: Is there any known method or workaround that allows returning from my app back to Safari (or the default browser) and restoring the previously active web page or tab? Or, is there any way to programmatically return to the previous app from within my app? Thanks in advance for your support!
0
0
85
Apr ’25
Testing In-App Purchases
Hi, I have a couple of questions in regards to testing in-app purchases. I tested the subscription on a device but I'm not sure how to reset so I can test again. I didn't see the subscription in device settings or in Debug -> StoreKit -> Manage Subscriptions window. Additionally, I was wondering if there was a way to detect the subscription being made. I implemented this, but I'm not sure if that will work: .onChange(of: Product.SubscriptionInfo.RenewalState.subscribed) { if Product.SubscriptionInfo.RenewalState.subscribed == .subscribed { } }
13
0
231
Jul ’25