Hi, I am using xCode26.x. But my Metal4 classes are not compiling. I downloaded the sample code from Apple's website - https://developer.apple.com/documentation/Metal/processing-a-texture-in-a-compute-function. For example, I am getting errors like "Cannot find protocol declaration for 'MTL4CommandQueue';
I have hit a deadline. Any recommendations are very welcome.
I have downloaded the Metal Tool chain. When I run the following commands on the terminal - xcodebuild -showComponent metalToolchain ; xcrun -f metal ; xcrun metal --version
I get the following response -
Asset Path: /System/Library/AssetsV2/com_apple_MobileAsset_MetalToolchain/86fbaf7b114a899754307896c0bfd52ffbf4fded.asset/AssetData
Build Version: 17A321
Status: installed
Toolchain Identifier: com.apple.dt.toolchain.Metal.32023
Toolchain Search Path: /Users/private/Library/Developer/DVTDownloads/MetalToolchain/mounts/86fbaf7b114a899754307896c0bfd52ffbf4fded
/Users/private/Library/Developer/DVTDownloads/MetalToolchain/mounts/86fbaf7b114a899754307896c0bfd52ffbf4fded/Metal.xctoolchain/usr/bin/metal
Apple metal version 32023.830 (metalfe-32023.830.2)
Target: air64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Users/private/Library/Developer/DVTDownloads/MetalToolchain/mounts/86fbaf7b114a899754307896c0bfd52ffbf4fded/Metal.xctoolchain/usr/metal/current/bin
Overview
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
The "Remind me later" button doesn't work on the "Customize your experience with Apple Developer" page on the Developer Forums. It just redirects me back to the same page.
https://github.com/feedback-assistant/reports/issues/723
I’ve been trying to set up a UIDocument and override writeContents(...). This works correctly in older projects, but I haven’t been able to get it working in my new iOS 26 app using Swift 6.
To troubleshoot, I tested the Particles demo and successfully overrode writeContents there. However, as soon as I switch that project to iOS 26 and Swift 6, calling save; which triggers writeContents, causes the same crash.
override public func writeContents(
_ data: Any,
to url: URL,
for _: UIDocument.SaveOperation,
originalContentsURL _: URL?,
) throws {
...
}
Thread 10 Queue : UIDocument File Access (serial)
Topic:
UI Frameworks
SubTopic:
UIKit
I've developed a custom FSKit module which all seems to work OK when tested with a dummy test FSResource.
However, the end goal is to mount a user's entire home directory via my FSKit module. I obviously need the mount to occur before that user logs in for the first time, since that is when their home directory will be first populated. I also have to perform the mount as the user in question since their home directory must be owned by them.
I have written a LaunchDaemon module to call /sbin/mount, running as that user, however I notice that whether FSKit modules are enabled or disabled seems to be a per-user setting. If I enable my FSKit module as User A in 'System Settings > Login Items and Extensions' and then log in as User B and go into Login Items and Extensions, the module shows as disabled.
Is there a way to enable my FSKit module globally so that it is enabled for all users without each user having to go into System Settings and manually enable it? Or a way of enabling it via command line that I can run with "sudo -u" ? And would this enable me to mount a filesystem before any user has logged in?
I’m building a firefighter app that needs to automatically check in a firefighter when they arrive at the station and check them out when they leave — even if the app is killed. We need reliable enter/exit detection, low latency, and only one fixed location per user.
We’re evaluating Region Monitoring, which works in the killed state but may introduce delays and inconsistent accuracy. To ensure mission-critical reliability, we are considering the Location Push Service Extension, since it can fetch precise location on demand and wake the extension even when the app is terminated.
Before requesting the restricted entitlement, we need clarification on Apple’s expectations:
Is Region Monitoring recommended for this fixed-location use case?
Would Apple consider approving the Location Push Service Extension for a public-safety workflow?
What prerequisites do we need before submitting the entitlement request (Always permission, prototype, privacy disclosures, etc.)?
What details should be included in the justification form?
Our goal is to follow the most reliable and Apple-approved approach for firefighter check-in/out. Any guidance would be greatly appreciated.
I’m running Xcode 26.1.1 (17B100) with deployment target iOS 18.0+, and I’m seeing a consistent and reproducible issue on real devices (iPhone 13 Pro, iPhone 15 Pro):
Problem
The first time the user taps into a TextField or a SwiftUI .searchable field after app launch, the app freezes for 30–45 seconds before the keyboard appears.
During the freeze, the device console floods with:
XPC connection interrupted
Reporter disconnected. { function=sendMessage, reporterID=XXXXXXXXXXXX }
-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:]
perform input operation requires a valid sessionID.
inputModality = Keyboard
customInfoType = UIEmojiSearchOperations
After the keyboard finally appears once, the issue never happens again until the app is force-quit.
This occurs on device
Reproduction Steps
Minimal reproducible setup:
Create a new SwiftUI app.
Add a single TextField or .searchable modifier.
Install Firebase (Firestore or Analytics is enough).
Build and run on device.
Tap the text field immediately after the home screen appears.
Result:
App freezes for 30–45 seconds before keyboard appears, with continuous XPC/RTIInputSystem errors in the logs.
If Firebase is removed, the issue occurs less often, but still happens occasionally.
Even If Firebase initialization is delayed by ~0.5 seconds, the issue is still there.
Question
Is this a known issue with iOS 18 / RTIInputSystem / Xcode 26.1.1, and is there a recommended workaround?
Delaying Firebase initialization avoids the freeze, but this isn’t ideal for production apps with startup authentication requirements.
Any guidance or confirmation would be appreciated.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi,
I am developing a music app. We are using siri media search functionality for a while. We recently had a case where siri would not provide keyword for a search.
When user speaks "Play Kid songs" (in Turkish, çocuk şarkıları çal), when I debug I see mediaSearch.mediaName is nil.
When user speaks "Play Kids" (in Turkish, çocuklar çal) a keyword is given and we can search and play related song.
Normally I would think that siri is somehow censoring the word "Kid". But when i try the same voice search in Spotify, I get a children song search result.
I've read documentations and searched web but couldnt find any similar experience.
What would be the cause, is there an extra setting for this kind of behaviour. What would be the cause or a different capability that Spotify can get a keyword out of this voice search but not us?
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Siri and Voice
SiriKit
App Intents
Hi Apple Developer Community and Support Team,
I'm reaching out for advice and potential escalation on a stalled organization enrollment that's blocking our app launch. Here's a quick timeline:
Initial enrollment hit issues with D-U-N-S verification (now resolved) and email code delivery, leading to multiple failed attempts and temporary blocks.
After unblocking via support, we resubmitted and were directed to higher department review.
Submitted all required docs (company formation, passport/ID, etc.) on Wednesday, November 26, 2025. No updates since—it's now Day 6 with zero communication on ETA.
This is critically urgent for our business: We have ~4,000 users pre-registered and waiting to download our personal development app (focused on habit-building and goal tracking). Projections show another 10,000 sign-ups in the next two weeks alone, pushing us to 15,000+ if resolved soon. These folks are already investing—our physical planners (promoting the app) are selling via Amazon and our website, http://www.freedommastery.com selling Life planners) and they're expecting seamless iOS access on launch day. Every day of delay risks churn, lost revenue, and momentum in a competitive space.
I've followed up via phone/email multiple times, but frontline support can't provide timelines or status. Enrollment ID: [Redact or insert your anonymized ID here for tracking].
Has anyone navigated a similar higher-review holdup? Tips for bumping priority (e.g., additional proof of urgency like waitlist data)? Any rough ETAs from recent org approvals? Grateful for any insights—Apple's ecosystem is key to our growth, and we'd love to get these users onboard ASAP.
Thanks in advance!
Topic:
Developer Tools & Services
SubTopic:
Apple Developer Program
Tags:
Subscriptions
Accounts
App Review
Developer Program
I have a script that stop working since Tahoe migration.
The script need to send a notification on the my mac.
The issue is this line:
osascript -e 'display notification "The task has been completed" with title "✅ My script"'
It doesn't fail (return 0), nothing in outputs, but doesn't show anything.
I check all my notification settings, but all seems to be right, I tested the configuration of iterm & script editor.
And the global ettongs of the notifications:
When using a Swift Build Plugin, the generated code definitions are available through autocomplete, but it is currently not possible to view them directly in Xcode using Option+click.
An example of such a plugin is swift-openapi-generator.
According to information from "Meet Swift Package plugins" from WWDC22
the generated code is stored with other build artifacts.
It would be immensely helpful if there was support for viewing these intermediate files in read-only mode using Option+click. Currently, I have to resort to opening these files through Finder, or opening the project in VS Code where viewing the generated files using Cmd+click works without a problem.
Am I missing something? If not, it seems like a big oversight that this is not supported to the same extent in Apple's own tools.
腾龙:----TL 9655. C0M-----创办于1998年,总部位于缅甸掸邦老街,是果敢四大家族之一企业的产业。该集团旗下子公司超过多家,员工达上万余人。明面上主要经营文旅、酒店、房地产等产业,如2019年正式运营的腾龙大酒店,曾是当地最豪华的酒店,同年还启动运营了新天地房地产项目。此外,2023年在佤邦建设的新盛大酒店于2023年正式运营,2023年在新盛大酒店也正式运营。
Issue Summary:
iOS 26 UI components are not visible in the Expo app when installed via TestFlight. All components render correctly in local builds or when running with expo run:ios.
Details:
The app is built using Expo managed workflow.
iOS 26-specific UI components do not appear in TestFlight builds.
The same components display correctly in local builds and simulators.
Test device: iPhone running iOS 26.1.
There are no crashes or runtime errors; only the components are missing.
This issue occurs only in TestFlight/release builds.
Expected Behavior:
All iOS 26 UI components should render in TestFlight builds the same way they do in local builds.
Actual Behavior:
Components fail to render or are completely missing.
Device Information:
Device: iPhone
iOS Version: 26.1
Distribution: TestFlight
Local Build: Working correctly
Additional Notes:
This may be related to Expo release build optimization or iOS 26 SDK compatibility.
Hi everyone,
I’m trying to reproduce the layout Apple Music uses for playlists, where there is header content above the table (artwork, title, buttons), and when you scroll, everything scrolls together—the header and table rows move as a single scrollable region.
Here’s an example of what I’m trying to achieve:
I’m using SwiftUI’s Table view and I haven’t found a clean way to place custom content above the table while keeping everything inside the same scroll view.
Is there currently a recommended way to achieve Apple Music–style scrollable header + table content using SwiftUI?
Thanks!
When utilizing Paperkit in its simplest form, PaperMarkupViewController does not show the option to add images.
Furthermore, trying to add images directly to the PaperMarkup's insertNewImage() function does not display anything. It seems like image functionality is entirely broken on Xcode 26.
This can be seen through the following example done by a fellow member here on the forums:
https://gist.github.com/clarkezone/68eb3ee13b5607782ceb2e20cece4ab3
Deterministic RNG behaviour across Mac M1 CPU and Metal GPU – BigCrush pass & structural diagnostics
Hello,
I am currently working on a research project under ENINCA Consulting, focused on advanced diagnostic tools for pseudorandom number generators (structural metrics, multi-seed stability, cross-architecture reproducibility, and complementary indicators to TestU01).
To validate this diagnostic framework, I prototyped a small non-linear 64-bit PRNG (not as a goal in itself, but simply as a vehicle to test the methodology).
During these evaluations, I observed something interesting on Apple Silicon (Mac M1):
• bit-exact reproducibility between M1 ARM CPU and M1 Metal GPU,
• full BigCrush pass on both CPU and Metal backends,
• excellent p-values,
• stable behaviour across multiple seeds and runs.
This was not the intended objective, the goal was mainly to validate the diagnostic concepts, but these results raised some questions about deterministic compute behaviour in Metal.
My question: Is there any official guidance on achieving (or expecting) deterministic RNG or compute behaviour across CPU ↔ Metal GPU on Apple Silicon? More specifically:
• Are deterministic compute kernels expected or guaranteed on Metal for scientific workloads?
• Are there recommended patterns or best practices to ensure reproducibility across GPU generations (M1 → M2 → M3 → M4)?
• Are there known Metal features that can introduce non-determinism?
I am not sharing the internal recurrence (this work is proprietary), but I can discuss the high-level diagnostic observations if helpful.
Thank you for any insight, very interested in how the Metal engineering team views deterministic compute patterns on Apple Silicon.
Pascal ENINCA Consulting
Topic:
Graphics & Games
SubTopic:
Metal
Tags:
ML Compute
Metal
Metal Performance Shaders
Apple Silicon
I spend a lot of time here on DevForums. Over the years I’ve read many posts, both good and bad. This page is my attempt at writing down what makes a good one. Hopefully some of you will find it useful.
Before you read this, read the official Apple Developer > Support > Developer Forums page.
If you have questions or feedback about any of the points raised here, start a new thread in the Developer Tools & Services > Developer Forums subtopic.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Quinn’s Top Ten DevForums Tips
Here are my top ten DevForums tips:
Is DevForums right for you?
Search before you ask
Keep your expectations realistic
Topic, subtopic, and tags
Craft a quality post
Prefer text over images
Include details with your questions
Crash reports
Cross posting courtesy
Resize screenshots
Include a Spinal Tap reference
Close your threads
Think about your title
Post URLs in the clear
Many of these boil down to one word: Empathy. Think about the person who’s reading your post. Can they read it? Will they understand it? Will it help them?
1. Is DevForums right for you?
To quote Apple Developer > Support > Developer Forums, the Apple Developer Forums (aka DevForums) are:
a great place to post questions, exchange knowledge, and connect with
fellow developers and Apple engineers on a variety of development
topics.
DevForums is focused on developer issues. That includes the APIs in Apple’s platform SDKs, Apple tools, developer-oriented Apple services like App Store Connect, and accessory development. If you have a user-level question, you’ll have more luck over in Apple Support Communities, run by Apple Support.
DevForums is focused on Apple technologies. If you’re using a third-party tool or library, feel free to ask questions about it here, but you’re more likely to find folks with relevant expertise in that technology’s dedicated support channel.
If you want to file a bug report, do that using Feedback Assistant. If you want to discuss a bug you’ve already filed, DevForums is a great place for that. Make sure to include your bug number in your post. For more hints and tips on the bug reporting process, see Bug Reporting: How and Why?.
2. Search before you ask
DevForums has a history stretching back to 2015. Many questions have been asked and answered here. Before you start a thread, search the forums for similar threads.
For details about the search syntax, see Apple Developer > Support > Developer Forums. For a quick summary, click in the search field.
Remember that DevForums is world readable and thus indexed by Internet search engines.
3. Keep your expectations realistic
DevForums is an informal support channel; no one is being paid to answer DevForums questions full time. Keep that in mind when you post.
Apple provides a number of formal support channels. To request formal support, go to the Apple Developer > Contact Us page.
One of those support channels is the code-level support provided by Apple Developer Technical Support (DTS). For more information about DTS, see Apple Developer > Support > Requesting Technical Support.
Asking about Apple’s unannounced plans is unlikely to yield useful results. Apple folks can’t discuss The Future™, and non-Apple folks can only speculate.
Apple folks can’t discuss Apple’s internal business practices. For example, we can’t answer why question — “Why did Apple do this?” or “Why hasn’t Apple done that?” — unless there’s existing documentation that offers an explanation. If you think Apple should do something differently, file a bug that explains what you’d like to see change and the rationale for that.
Not everyone works the same hours as you do. DevForums is a worldwide community, so there are time zones to consider, but there’s also just individual preferences. This is especially relevant around weekends, where your reply on Friday may not be seen by other folks until Monday.
Different folks use DevForums in different ways. Some folks lean in to the notification system, whereas others allocate certain times of the day, or the week, to help out.
4. Topic, subtopic, and tags
DevForums organises threads by two attributes:
A high-level topic and subtopic
A fine-grained set of tags
Folks willing to offer help often monitor a specific set of subtopics or tags, and only see threads with those attributes. To increase the odds of getting a response, choose your subtopic and tags carefully.
The list of subtopics is immediately visible on the top-level page. For a list of tags and their descriptions, go to Developer > Support > Forums Tags. That’s a lot of tags!
When choosing a subtopic, choose the most specific one. For example, if you have a question about SwiftUI, choose UI Frameworks > SwiftUI rather than Programming Languages > Swift. The latter is primarily focused on the Swift language itself.
When choosing a tag, read the description of that tag. With so many tags there are inevitably cases where a tag doesn’t mean what you think it means. For example, the Exception Handling tag is about the rarely used Exception Handling framework, not about exception handling in general, and the description makes that clear.
5. Craft a quality post
When replying, use a reply rather than a comment. Comments are best reserved for short messages, like “Thanks!” or “See this other thread.”
IMPORTANT If you reply in the comments, other folks on the thread may not be notified of your reply.
DevForums supports Markdown formatting, similar to that used on GitHub and by DocC. The editor UI has buttons for the most common things, like Bold and Italic, but don’t feel the need to limit yourself to that.
Correct formatting is particularly important for preformatted text:
Use the Inline Code button, which inserts single backquote delimiters (```), for inline text in code style: identifiers and so on.
Use the Code Block button, which inserts triple backquote delimiters (`````), for blocks of text in code style: code snippets, logs, and so on.
After submitting your post, look it over to make sure that it reads well. If not, you have a short window where you can edit the post to fix things.
6. Prefer text over images
Don’t use screenshots for data that’s essentially textual, like code snippets and logs. For example, if you want to post a log message, include that as text rather than adding a screenshot. That makes it much easier for your readers to work with the text.
Use the Code Block button, which inserts triple backquote delimiters (`````), to format blocks of text in code style.
Reserve screenshots for situations where the issue is visual, for example:
When discussing view layout problems
When posting instructions to achieve some task in a GUI app, like Xcode
7. Include details with your questions
When starting a thread, try to include all the relevant details in your post. If you skimp on these details, folks will have to reply asking for them, and that slows things down.
Specifically, anticipate the following questions:
What platform are you targeting? And what version of that platform?
What version of Xcode are you using?
What version of the OS are you testing on?
What specific API are you using?
What are the exact steps you took?
If something failed, what are the symptoms of that failure? If an API returned an error, what was that error?
If nothing failed, what results did you see? And what were you expecting?
If you filed a bug, what was the bug number?
Have you tried reproducing the issue in a small test project?
What else have you tried?
For more thoughts on this, see Tips on writing forums posts.
Oh, and if you’re having a build problem, consider attaching a full build log.
8. Crash reports
If you’re trying to get help with a crash, include a crash report. For advice on how to do that, see Posting a Crash Report.
9. Cross posting courtesy
Don’t start multiple threads for the same issue. That just wastes everyones time.
Sometimes this happens by accident. If that’s the case, add a comment to one of the threads redirecting folks to the other one.
If you find a bunch of old threads that might be related to your issue, don’t post full replies to all of them. Pick a lead thread and post your full reply there, then reply on the other threads with a link to the lead thread. Alternatively, start a new thread and reply on all the old threads with a link to that. That’ll help focus the discussion on your specific issue.
If you post your question to another support channel, provide a link to that in your DevForums question, and vice versa. That avoids folks working on a question that’s already been answered elsewhere.
10. Resize screenshots
If your post includes an image, make sure it renders well. Screenshots from Retina displays are often ridiculously large. Use Preview to crop the screenshot and, if necessary, downsample it by 50% (using Tools > Adjust Size).
11. Include a Spinal Tap reference
To be clear, this is a joke. While the occasional Spinal Tap reference is allowed, please don’t add one to all your posts (-:
12. Close your threads
If someone replies with the answer you need, mark that as accepted. That gives them some credit and helps other folks with similar questions find that answer.
If you find the answer by yourself, please post a short summary of what you did. Feel free to mark that as accepted.
There’s no way to change the accepted answer. See this thread for specific advice.
You can’t delete your own threads. If you accidentally post two copies of the same question, choose one as the primary and, in the other one, add a reply that links to it. Beyond that, see this thread for more advice.
13. Think about your title
When creating a thread, think carefully about your title. Your title is your thread’s ‘marketing statement’, a way to entice folks to read your post. Try to summarise your issue in 15 words or less.
Adding tags to your title makes it harder to read. Instead, add your tags with the tagging UI. See tip 4 for more on tags.
14. Post URLs in the clear
DevForums has a list of websites you can link to at will. For example, it places no restrictions on links to Swift Forums.
To link to a site that’s not on the allowlist, skip the Markdown link syntax and post your link in the clear. So, this won’t work:
Apple is based in [Cupertino](https://www.cupertino.org).
but this will:
Apple is based in Cupertino.
https://www.cupertino.org
Revision History
2025-12-02 Tidied up and expanded tip 12.
2025-06-19 Made minor editorial changes.
2024-08-29 Added a link to Creating a test project.
2024-08-07 Add more hints to tip 7.
2024-05-27 Reworked tip 4 to account for the new topic and subtopic model. Made other minor editorial changes.
2023-11-16 Added a link to [Public and Private Tags][refPaPT].
2023-02-22 Expanded tip 3.
2023-02-10 Added a note about why questions to tip 3 (another great suggestion from Scott). Added a link to Bug Reporting: How and Why?.
2023-01-09 Added a note about tags to tip 13.
2022-12-09 Expanded tip 12.
2022-08-22 Expanded tip 5 to explain why you shouldn’t reply in the comments.
2022-08-11 Expanded tip 9.
2022-06-17 Added tip 14. Updated the preamble to include a link to the main DevForums page.
2022-06-04 Added a discussion of unannounced plans to tip 3 (thanks to Scott).
2022-06-03 Added tip 13.
2022-05-24 Added tips suggested by Claude31 and Scott.
2022-05-23 First posted.
The published "Next steps for apps distributed in Texas" says "A parent or guardian in Texas can withdraw consent for any app, which will block launching of the app on the child or teen’s device."
My question is: will this also block notifications sent to that app from showing up on that device? Or will notifications still be delivered to the notification center, even though the app can't be launched? (Specifically, notifications sent from a server via Firebase topic/token).
If notifications are not blocked automatically, what is the expected flow for this scenario? My app sends notifications from a server like this.
I could implement client-side code to say "if consent is revoked, unsubscribe from notifications", but if the OS blocks launching of the app, this client-side code would never run.
Similarly, I could subscribe to the server notifications for when consent is revoked, but my app is free & accountless, so I'm not aware of any information in the server notification that I could use to identify the specific user whose notifications should be stopped. (For example my users won't have an appAccountToken because they never made a purchase).
Guidance would be much appreciated. I'm trying to comply with the law but I don't know how.
Can someone please explain why Mac app packaging is so farcically convoluted?
Windows app packaging can be picked up in an hour or so.
But I've spent longer trying to fathom how to package the Mac version than I did building the app.
And it's not done with me yet.
Every single line of code requires a deep dive into a new, unrelated skillset.
So, it’s sidebar after sidebar.
Kafka’s ‘The Trial’ comes to mind.
Why does it have to be like this?
Topic:
Code Signing
SubTopic:
Notarization
Best approach for high-quality textured room reconstruction using ARKit / RoomPlan / Object Capture?
I am developing an IOS App that allow users to scan rooms, view the scans on device, and add notes. I need to preserve actual geometry (odd angles, chamfers, fixtures), not simplified RoomPlan boxes.
Are there any easy ways to incorporate high quality texture mapping or PBR? Where is the documentation for scene reconstruction?
Hello Apple Developer Community,
I'm experiencing an issue on macOS where ASWebAuthenticationSession fails to display its authentication window.
The session is created successfully and start() returns true, but:
no UI is shown,
presentationAnchor(for:) is never invoked,
the completion handler is never called,
and no errors appear in Console.app or Xcode logs.
This happens both when using the session via a Flutter plugin and when calling ASWebAuthenticationSession directly from Swift.
Environment
macOS 14.6 (Sonoma)
Xcode latest stable
Target: macOS 10.15+
App type: sandboxed macOS app, hardened runtime enabled
The project also includes a Login Item (SMAppService) target
Redirect URI scheme: myapp-auth://callback
Problem Description
When I trigger authentication, the logs show:
[AuthPlugin] Starting ASWebAuthenticationSession...
After that:
no authentication sheet appears,
presentationAnchor(for:) is never called,
the completion handler is not invoked.
The main window is visible and active when the method is called.
Swift Implementation
public class AuthPlugin: NSObject, FlutterPlugin, ASWebAuthenticationPresentationContextProviding {
private var webAuthSession: ASWebAuthenticationSession?
private var resultHandler: FlutterResult?
private func authenticate(url: URL, callbackScheme: String, result: @escaping FlutterResult) {
NSLog("[AuthPlugin] authenticate() called")
NSLog("[AuthPlugin] URL: %@", url.absoluteString)
NSLog("[AuthPlugin] Callback scheme: %@", callbackScheme)
resultHandler = result
let session = ASWebAuthenticationSession(
url: url,
callbackURLScheme: callbackScheme
) { [weak self] callbackURL, error in
NSLog("[AuthPlugin] completion handler invoked")
if let error = error {
NSLog("[AuthPlugin] error: %@", error.localizedDescription)
return
}
guard let callbackURL = callbackURL else {
NSLog("[AuthPlugin] missing callback URL")
return
}
self?.resultHandler?(callbackURL.absoluteString)
}
session.presentationContextProvider = self
session.prefersEphemeralWebBrowserSession = false
self.webAuthSession = session
NSLog("[AuthPlugin] Starting ASWebAuthenticationSession...")
let started = session.start()
NSLog("[AuthPlugin] start() returned: %@", started ? "true" : "false")
}
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
NSLog("[AuthPlugin] presentationAnchor called")
if let keyWindow = NSApplication.shared.windows.first(where: { $0.isKeyWindow }) {
NSLog("[AuthPlugin] using key window")
return keyWindow
}
if let firstWindow = NSApplication.shared.windows.first {
NSLog("[AuthPlugin] using first window")
return firstWindow
}
NSLog("[AuthPlugin] creating fallback window")
let window = NSWindow(
contentRect: .init(x: 0, y: 0, width: 400, height: 300),
styleMask: [.titled, .closable],
backing: .buffered,
defer: false
)
window.center()
window.makeKeyAndOrderFront(nil)
return window
}
}
Key Observations
The session is created successfully.
ASWebAuthenticationSession.start() returns true.
presentationAnchor(for:) is never invoked.
The completion handler is never triggered.
No errors appear in system logs.
The same code works correctly in a non-sandboxed macOS app.
The main window is visible and the app is active when the session is started.
Questions
What conditions must be met for macOS to call presentationAnchor(for:)?
Does the window need to be key, main, visible, or foreground?
Does ASWebAuthenticationSession.start() need to be called strictly on the main thread?
Are additional entitlements, sandbox permissions, or Info.plist keys required for using ASWebAuthenticationSession in a sandboxed macOS application?
Could the existence of a Login Item (SMAppService) affect the app’s ability to present the authentication sheet?
Are there known restrictions for using custom URL schemes (myapp-auth://callback) on macOS?
Is there any way to obtain more detailed diagnostics when start() silently fails to display UI?
Summary
In a sandboxed macOS application, ASWebAuthenticationSession starts without errors but never attempts to present its UI.
Since presentationAnchor(for:) is never called, it seems macOS is blocking the presentation for some reason — possibly sandbox configuration, entitlements, or window state constraints.
Any guidance or suggestions would be greatly appreciated.
Thank you!
Topic:
Community
SubTopic:
Apple Developers