Frameworks

RSS for tag

Ask questions about APIs that can drive features in your apps.

Posts under Frameworks tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Issue with In-app system disclosure sheet
We are utilizing the StoreKit external purchase link within the app and have configured the necessary keys in the entitlements according to the documentation. The Info.plist file has also been updated with the required key and a single destination URL, following the guidelines from this documentation. However, when we click the link in the app, it redirects to the default browser, and the in-app system disclosure sheet does not appear. Should the in-app disclosure sheet appear automatically, or do we need to design and implement it ourselves?
0
1
124
1w
Custom Container View with ForEach(subviews:content:)
Hi, I’m trying to implement a custom horiztonal Picker using the newly introduced API on ForEach like the following: struct ScopeBar<SelectionValue: Hashable, Content: View>: View { // MARK: Initializers @Binding private var selection: SelectionValue @ViewBuilder private var content: () -> Content public init(selection: Binding<SelectionValue>, @ViewBuilder content: @escaping () -> Content) { _selection = selection self.content = content } // MARK: Content var body: some View { ScrollView(.horizontal) { LazyHStack { ForEach(subviews: content()) { subview in Button { // selection = subview.id as! SelectionValue } label: { subview } .tag(subview.id) } } } } } The following implementation is what I’m trying to achieve for the custom container usage: struct MyOtherView: View { enum SomeScopes: String, CaseIterable, Hashable { case first case second case third case fourth case fifth } @State private var selection: SomeScopes = .first var body: some View { ScopeBar(selection: $selection) { ForEach(SomeScopes.allCases, id: \.rawValue) { scope in Text(scope.rawValue) } } } } I’m having some trouble figuring out two things: How can I make my SelectionValue equal to the Subview.ID so that my selection behaves internally like a Picker would? Say I wanted to add an Image(…) in addition to the Text(scope.rawValue), how would I do it in order for the Button { … } label: { … } to use both views, and not each separately…?
2
0
101
1w
How to symbolize memory graph if symbols is not compiled into application
To reduce the app size, the application dmg file does not contains the symbols in it. But when we meet memory issue, I use "leaks 'appName' --outputGrap =memoryLeak.memgraph" to get a memory graph Because there is no symbols contained the application, there is no function names(module names) which allocate the memory from the memory graph. But, we save the symbols as separate .dSYM files when compile, Is there any way to use the .dSYM files to symbolize the memory graph in this case ?
0
0
86
1w
How to log app termination on firebase?
In my React Native mobile application, we are experiencing app termination issues on a few devices (iPhone 13 & 14). We have implemented Firebase Crashlytics, we are getting crashes logs but we are not receiving any logs for app terminations when app terminates due to memory leak or terminates by OS. Could you please suggest a way to log app terminations or recommend any other platform where we can log such events? Alternatively, do you have any suggestions on how to resolve app termination issues?
0
0
131
2w
NavigationSplitView does not properly show detail pages on macOS 15
The Problem My team has recently discovered a problem in one of our macOS apps. It uses SwiftUI and Combine, as it still needs to support macOS 13. It uses a NavigationSplitView to display a sidebar-detail UI. On macOS 15, we started running into a bug: When selecting an item from the sidebar, the corresponding detail does not initially show up, and a detail page shows up only when selecting a second item from the sidebar. The following message would be printed into Xcode's console: Publishing changes from within view updates is not allowed, this will cause undefined behavior. This message would only get printed into the console, and would not be attached to any specific line. Oftentimes, selecting a subsequent item from the sidebar also either completely clears the detail page, doesn't do anything, and there was a crash reported as well. The app is compiled using Xcode 16.0. Architecture Overview The app uses NavigationSplitView with multiple different detail pages. .id is attached to the detail view in its corresponding NavigationLink, which used to properly show the corresponding detail page. The ID is stored in an observable AppState, which uses Combine's ObservableObject in the production app, and Observation's Observable in the minimal example. Example Code Minimal Reproductible Example You can see a minimal reproducible example here: https://github.com/buresdv/Navigation-Problems This example also features a debug field at the end of the sidebar, called "navigationSelection". When clicking one of the items, the ID gets correctly set, but the detail page does not update. Production App The production app is a bit more complex, but the core system is the same. For complete code, see: https://github.com/buresdv/Cork Some relevant lines include the navigation root, sidebar list, and the navigation links Notes We were able to reproduce these issues on multiple user systems This issue seems to have started occuring when we updated to macOS 15 At the same time, we updated the app to Strict Concurrency Checking and Swift 6, although we did not change anything in the navigation system
3
0
333
2w
[iPadOS 18] A series of TabBar questions
Hello, I am currently implementing the new iPadOS 18 TabBar with the new Tab API, but there are several things that don't look very good or aren't operating quite the way I'd hope and would like to know if there is a way around them or to change them. Here is what my sidebar for the TabBar looks like: My questions: The tabViewSidebarBottomBar isn't actually at the "bottom". Instead there is a gap below which you can see the sidebar scrolling. Is there a way to get the tabViewSidebarBottomBar actually at the bottom? Is there a way to make it so that the sections themselves are also reorderable? Can we turn scrollIndicators to .never or are we stuck with them being on? Is there any way at all to make the SF Symbols in the sidebar render in another color mode, particularly .palette? Is it possible to allow sections in between plain tabs? Like I want Dashboard, then the whole Events section, then the rest can continue. On iPhone why are sections not honored at all, in any way? Like even if they weren't going to be expandable menus, at least treating it like a list section would allow some visual hierarchy?! Bonus Question: Any way to make the tabViewSidebarHeader sticky so it's always at the top? Thank you in advance!
1
0
189
1w
Max OS X App Bundle Framework folder
Hi, the documentation says that an application bundle for Mac OS X can have a Frameworks folder within Contents. Using a framework for console applications (no bundle) and GUI applications (bundle), I cannot load the console applications anymore on Ventura. Prior to Ventora I have tested and ran both on Mojave or earlier - I am not sure. To fix the issue, I have moved the frameworks within the application bundle to match the rpath for /Users/lothar/Library/Frameworks when I place the console into /Users/lothar/bin, the same rpath for application bundles works for those within the bin folder. Can I publish an application bundle with that modified layout or do I have to expect getting problems and do rather a Symlink pointing from /Users/lothar/Frameworks to /Users/lothar/Library/Frameworks? Thanks, Lothar
1
0
193
2w
How to observe AVCaptureDevice.DiscoverySession devices property?
At Apple Developer documentation, https://developer.apple.com/documentation/avfoundation/avcapturedevice/discoverysession you can find the sentence You can also key-value observe this property to monitor changes to the list of available devices. But how to use it? I tried it with the code above and tested on my MacBook with EarPods. When I disconnect the EarPods, nothing was happened. MacBook Air M2 macOS Sequoia 15.0.1 Xcode 16.0 import Foundation import AVFoundation let discovery_session = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.microphone], mediaType: .audio, position: .unspecified) let devices = discovery_session.devices for device in devices { print(device.localizedName) } let device = devices[0] let observer = Observer() discovery_session.addObserver(observer, forKeyPath: "devices", options: [.new, .old], context: nil) let input = try! AVCaptureDeviceInput(device: device) let queue = DispatchQueue(label: "queue") var output = AVCaptureAudioDataOutput() let delegate = OutputDelegate() output.setSampleBufferDelegate(delegate, queue: queue) var session = AVCaptureSession() session.beginConfiguration() session.addInput(input) session.addOutput(output) session.commitConfiguration() session.startRunning() let group = DispatchGroup() let q = DispatchQueue(label: "", attributes: .concurrent) q.async(group: group, execute: DispatchWorkItem() { sleep(10) session.stopRunning() }) _ = group.wait(timeout: .distantFuture) class Observer: NSObject { override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { print("Change") if keyPath == "devices" { if let newDevices = change?[.newKey] as? [AVCaptureDevice] { print("New devices: \(newDevices.map { $0.localizedName })") } if let oldDevices = change?[.oldKey] as? [AVCaptureDevice] { print("Old devices: \(oldDevices.map { $0.localizedName })") } } } } class OutputDelegate : NSObject, AVCaptureAudioDataOutputSampleBufferDelegate { func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { print("Output") } }
6
0
207
1w
Apple pay integration in asp.net website
Hi Guys, I have asp.net web application targeting framework 4.7.2 . The requirement is to integrate apple pay to the site as a payment method. Can any one help me on the below queries. As the development will be in visual studio, is it require to have a apple developer account. if yes, which subscription is required (individual/organization). I believe to obtain merchantID, payment processing certificate apple developer account is required but not sure like which subscription is required. Is there any supporting document or code snippet to integrate apple pay in .net application. Is it required to use browser safari or iphone or ipad for testing the apple pay? can the testing be done using chrome browser? Is it a direct integration using c# code or do I need to use any third party payment gateway like stripe, authorize. Thanks in Advance
1
0
221
1w
Wallpaper Api
Hey, I have an app that user selects wallpaper for iPhone. I want a feature that user can set wallpaper direct from app itself for lock screen and home screen not download the image and manually set the wallpaper. As my research there was a PhotoLibrary api that contains PLWallpaperImageViewController.h which allows you to set wallpaper directly. Thank You!
1
0
203
2w
Instagram login using ASWebAuthenticationSession
I am currently using the ability to log in with my Instagram account using ASWebAuthenticationSession and it is not working! I filled in the URL directly and there was no problem on the web, but when I run it in SwiftUI in Xcode, it doesn't work and Error: The operation couldn’t be completed. (com.apple.AuthenticationServices.WebAuthenticationSession error 2.) I get this error. I was told that I need a custom scheme to return to mobile, but the Instagram redirect URL says no custom scheme. What should I do? IDs and URLs are placed under assumption. I have no idea since this is my first implementation. Should I send the scheme URL from the website to mobile once using Django or something else? import SwiftUI import AuthenticationServices struct InstagramLoginView: View { @State private var authSession: ASWebAuthenticationSession? @State private var token: String = "" @State private var showAlert: Bool = false @State private var alertMessage: String = "" var body: some View { VStack { Text("Instagram Login") .font(.largeTitle) .padding() Button(action: { startInstagramLogin() }) { Text("Login with Instagram") .padding() .background(Color.blue) .foregroundColor(.white) .cornerRadius(10) } if !token.isEmpty { Text("Token: \(token)") .padding() } } .alert(isPresented: $showAlert) { Alert(title: Text("Error"), message: Text(alertMessage), dismissButton: .default(Text("OK"))) } } func startInstagramLogin() { let clientID = "XXXXXXXXXX" // Instagram client ID let redirectURI = "https://example.com" // Instagram Redirect URI guard let authURL = URL(string: "https://api.instagram.com/oauth/authorize?client_id=\(clientID)&amp;redirect_uri=\(redirectURI)&amp;scope=user_profile,user_media&amp;response_type=code") else { print("Invalid URL") return } authSession = ASWebAuthenticationSession(url: authURL, callbackURLScheme: "customscheme") { callbackURL, error in if let error = error { print("Error: \(error.localizedDescription)") return } guard let callbackURL = callbackURL else { print("Invalid callback URL") return } if let code = URLComponents(string: callbackURL.absoluteString)?.queryItems?.first(where: { $0.name == "code" })?.value { print("Authorization code: \(code)") getInstagramAccessToken(authCode: code) } } authSession?.start() } func getInstagramAccessToken(authCode: String) { let tokenURL = "https://api.instagram.com/oauth/access_token" var request = URLRequest(url: URL(string: tokenURL)!) request.httpMethod = "POST" let clientID = "XXXXXXXXXXXX" let clientSecret = "XXXXXXXXXXXXXX" // Instagram clientSecret let redirectURI = "https://example.com/" let params = "client_id=\(clientID)&amp;client_secret=\(clientSecret)&amp;grant_type=authorization_code&amp;redirect_uri=\(redirectURI)&amp;code=\(authCode)" request.httpBody = params.data(using: .utf8) request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error.localizedDescription)") return } guard let data = data else { print("No data") return } if let jsonResponse = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any], let accessToken = jsonResponse["access_token"] as? String { print("Access Token: \(accessToken)") // ここでアクセストークンを使用してInstagram APIにアクセスする } else { print("Failed to get access token") } }.resume() } } #Preview { InstagramLoginView() }
1
0
174
2w
Files and Folders permission of App keeps denied, even from Settings.
Hi Apple Engineer, My app is using ImageCaptureCore framework to communicate to external DSLR Camera. When I connect my device to a camera, I execute the requestContentsAuthorization(completion:) to request for Access Files on Connected Cameras. This is the dialog when the request is executed: When I tap "OK", the status of content authorization keeps "Denied". even when I open "Files and Folders" permission in "Privacy & Security" Settings. When I switched ON the permission, the switch keeps back to turned off. You could see the reproduce in this GoogleDrive video https://drive.google.com/file/d/15B-R5TONgMWg8qFiYUGK0hTy62dsVGUX/view?usp=sharing The occurrence keeps happen even: I uninstall and install the app back Do "Reset Location & Privacy" Do "Reset All Settings" I attached the sysdiagnose files in this GoogleDrive file https://drive.google.com/file/d/11lovl_xC95AKXQTkZ1_e6UbEgS5md0Z3/view?usp=sharing I firstly experience this issue after researching ImageCaptureCore's API. I executed resetContentsAuthorizationWithCompletion:. After that, my permission request keeps denied as described above :( There are other developer that experiences the same as mine https://forums.developer.apple.com/forums/thread/756960 . There is a simple sample project there and it's reproducible in my case. Could you help me how to accomplished my app can be granted for permission to "Files and Folders" permission when using ImageCaptureCore? Could it be a bug from the system?
1
1
180
2w
How to migrate macOS keychain entry to new rewritten app?
I'm working on replacing an AppKit-based Mac app with one built on Catalyst, and the Catalyst app doesn't seem to be able to read the keychain item that was saved by the old app. Both apps are using the same bundle ID. The old app uses the old SecKeychain APIs - SecKeychainFindGenericPassword and friends - and the Catalyst app uses the newer SecItemCopyMatching and such. When I try using the new API in the old app to search for the entry, it works, but the exact same code in Catalyst fails. Here's how I save an item in the old app: NSString *strItemId = @"my_item_id; NSString *username = @"user"; const char *userPointer = [username UTF8String]; NSString *password = @"password"; const char *pwPointer = [password UTF8String]; SecKeychainItemRef ref = NULL; OSStatus status = SecKeychainFindGenericPassword(0, (UInt32)strlen(strItemId.UTF8String), strItemId.UTF8String, 0, NULL, NULL, NULL, &ref); if (status == errSecSuccess && ref != NULL) { //update existing item SecKeychainAttribute attr; attr.length = (UInt32)strlen(userPointer); attr.data = (void *)userPointer; attr.tag = kSecAccountItemAttr; SecKeychainAttributeList list; list.count = 1; list.attr = &attr; OSStatus writeStatus = SecKeychainItemModifyAttributesAndData(ref, &list, (UInt32)strlen(pwPointer), pwPointer); } else { status = SecKeychainAddGenericPassword(NULL, (UInt32)strlen(strItemId.UTF8String), strItemId.UTF8String, (UInt32)strlen(userPointer), userPointer, (UInt32)strlen(pwPointer), pwPointer, NULL); } And here's the query code that works in the old app but returns errSecItemNotFound in Catalyst: NSMutableDictionary *queryDict = [[[NSMutableDictionary alloc]init]autorelease]; [queryDict setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; [queryDict setObject:(@"my_item_id") forKey:(__bridge id)kSecAttrService]; [queryDict setObject:(__bridge id)kSecMatchLimitOne forKey:(__bridge id)kSecMatchLimit]; [queryDict setObject:(__bridge id)kCFBooleanTrue forKey:(__bridge id)kSecReturnAttributes]; CFMutableDictionaryRef outDictionary = nil; OSStatus err = SecItemCopyMatching((__bridge CFDictionaryRef)queryDict, (CFTypeRef *)&outDictionary); I tried creating a new blank AppKit-based Mac app project in Xcode and gave it the old Mac app's bundle ID, and the SecItemCopyMatching query code above works there. Then I created a new iOS target with Catalyst enabled, also with the same bundle ID, and the query code running there under Catalyst returned errSecItemNotFound. So maybe the issue is something specific to Catalyst? Is there something I need to do with the Catalyst app to give it access to the old app's keychain entry, besides setting its bundle ID to match the old app?
1
0
272
3w
Document-Based App with MVVM
ExampleCode.txt Dear all, I made an app for computing Finite Element Analysis of electric motors. I (think I) managed to follow the MVVM principle by not exposing the model to the views. Now, my goal is to be able to use documents, each representing a different motor. I want to have my files saved on iCloud, and I want to be able to read plain text from it, so some other code (i.e. python) can create new configurations, even though this app is made for building, graphically. Before trying to work with FileDocument, my class ViewModel: ObservableObject had properties with Published, like @Published var staOD = 80.0, and I would have views with TextFields to change these values. Now, I’m trying to blend in FileDocument, and I’m lost. I don’t know how I should work with my data. Under the “Separation of Concerns”, I guessed that: ViewModel: Should handle computations, updates, and application logic. Document: Should focus on data persistence and encapsulate data to be saved/loaded as a document. My ViewModel looks a bit strange to me, and I’m not sure I’m updating it the right way. I have around 100 parameters, I’m afraid I’m updating these parameters too often and unnecessarily every parameter at the same time, even when only one value is changed in the document. What I’m asking: Clarifications on how to work with FileDocument in my case of MVVM (I’m open to change the entire workflow, my main knowledge is on the Model built in Swift, but not SwiftUI) Why isn’t the computed area on the DocumentView at the right value when I open a document? I would like to open documents and have it in the “right” state. In reality, I’m computing an image of the electric motor, and it would be nice to open the document and see the “real” image, and not a dummy image before I can validate the geometry. I have these warnings popping every time I open a document and that scares me, especially because I want ideally to use swift 6 in the coming future, with concurrency the right way. Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates. Thanks a lot for your help, Guillaume I made an example/simplified code that has all the logic. I can't show the entire code in this prompt due to space limitation. Therefore, I put everything (184 lines) in a single Swift file for you to download. You can just create a Multiplatform Document App. Remove all files except the ...App file, in which you can paste the content of the shared swift file. Run on iPhone simulator. Development environment: Xcode 16, macOS 15 Run-time configuration: iOS 18, macOS 15 Open the app, click on "New motor" You will see "Computed area: 3'063..." Click on "Geometry", change "Stator OD" to 60 instead of 80. Click on "Save" button, now Computed area is 863... Click on "Cancel" button, and reopen the same document Problem: area is again 3'063 while when you open Geometry, you see that "Stator OD" is rightfully 60.
1
0
316
2w
Xcode Instruments: Mismatch Time Profiler results vs. CPU Cycles
Recently, we reworked a crucial part of our app and managed to half the amount of CPU cycles our app requires (according to Xcode Instruments). Nonetheless, when using the Time Profiler component in instruments, it shows that the CPU time spent was either higher or the same (depending on execution). The main time-consuming factor here: libsystem_pthread.dylib - the amount of CPU time spent by this library has doubled from original implementation to reworked implementation. Therefore, I'm having a few questions: How should I interpret this result? How is this even possible if the CPU clock cycles halved? What is the better metric here, the CPU cycles or the time profiler? How can I reduce the impact of that said library? What does that library do and how can I influence its performance? Thanks in advance.
2
0
196
3w