Is there a way to configure the style and toolbar of the macOS window that Xcode uses in #Preview?
I am working on a macOS application and want to preview some SwiftUI views within different window styles, toolbar styles and window title/subtitle visibilities.
Some of the modifiers to control the look-and-feel of a window are actually Scene Modifiers, not View Modifiers:
.windowStyle
.windowToolbarLabelStyle
.windowToolbarStyle
But #Preview does not accept Scenes, so I can't apply these modifiers:
// Error, not a view modifier.
#Preview {
ContentView()
.windowStyle(...)
}
// Error, Window is not supported in #Preview.
#Preview {
Window("Browser", id: "browser") {
ContentView()
}
}
If I give my ContentView a .toolbar(...), Xcode's Preview will correctly show a window with a toolbar, but not necessarily in the style I want.
Is there a way to apply the Scene Modifiers to #Preview so that I can see how they affect the window's chrome and toolbar?
Posts under macOS tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am facing an issue while codesigning the Content/MacOS executable. The executable name is exactly similar to the .app file, and the signing certificates have not expired yet.
Steps followed to generate signed files:
Executed codesign on files within the .app folder.
Then executed codesign on the .app folder.
Tried to notarize with the new notarization tool.
Do we have to sign each individual file and folder?
Observations:
.DS_Store files were removed from the .app before signing.
Another app with the same certificate is able to sign correctly.
Content/MacOS contains multiple files, including the app executable. These files are signed except the main executable.
same installed_app after copying at another location showing signed.
Getting:
App Sandbox-Not enabled
Hardening-Enabled - Version 10.9.0
Notarization-Granted
Gatekeeper-Can't evaluate
Signed By- Can't verify signature
Hello Team,
We are currently experiencing an issue where some of our devices are not receiving push notifications. We are sending notifications via the Apple Push Notification portal (https://developer.apple.com/notifications/push-notifications-console/) using the following two requests. However, in both cases, the notifications are not being delivered to the devices.
Scenario 1 :
When we send a request with apns-push-type set to alert, we receive the following error.
Request :
curl -v
--header "authorization: bearer ${AUTHENTICATION_TOKEN}"
--header "apns-topic: com.testcompany.sampletest"
--header "apns-push-type: alert"
--header "apns-priority: 10"
--header "apns-expiration: 0"
--data '{"aps":{"alert":{"title":"Test Notification Title","subtitle":"Test Notification Sub Title","body":"Test Notification Body"}}}'
--http2 https://api.push.apple.com:443/3/device/*devicetoken*
Response:
{
"code": 400,
"message": "bad-request",
"reason": "The device token is inactive for the specified topic. There is no need to send further pushes to the same device token, unless your application retrieves the same device token.",
"requestUuid": "c4ae39b4-87e1-4269-a1e9-163f60ec0385"
}
Scenario 2 :
However, if we send the request with apns-push-type set to background, the request is processed successfully by APNs, but no notification is received on the device.
Request :
curl -v
--header "authorization: bearer ${AUTHENTICATION_TOKEN}"
--header "apns-topic: com.testcompany.sampletest"
--header "apns-push-type: background"
--header "apns-priority: 10"
--header "apns-expiration: 0"
--data '{"aps":{"alert":{"title":"Test Notification Title","subtitle":"Test Notification Sub Title","body":"Test Notification Body"}}}'
--http2 https://api.push.apple.com:443/3/device/*devicetoken*
Response:
Getting a message that The notification sent successfully but no notification is received on the device.
In both cases (with alert and background push types), the push notification does not reach the device.
Additionally, when we validated the device token using the APNs Device Token Validator, it appears to be valid and returns the following message.
"Device Token is valid for sending Alert & Background push-type notifications in the Production environment"
Affected Device:
macOS version : MacOS 15.3.1
Processor : Apple M1
Could you please assist me in resolving this issue?
Thanks
In the online documentation for InstallerJS, it is stated that the unit for the availableKilobytes property of the target field is kilobytes.
Isn't it actually bytes because of a bug in the very first release of macOS that supported InstallerJS?
[Q] Has there been a fix in the recent years regarding this property that would explain why the documentation says it's kilobytes? Even though at the time of this writing, the unit is still bytes when you call my.target.availableKilobytes
I'm using this call to dump the value of this property in install.log:
system.log(my.target.availableKilobytes + '');
Ref. https://developer.apple.com/documentation/installer_js/target/1811975-availablekilobytes
(FB20448952)
Hey,
Just recently I realized something I have been overlooking in my build pipelines.
I thought that by adding the the "hardened runtime", I disable 3rd-party library injection (I do not have the disable-library-validation entitlement added).
However, I was using some checks on my code and I noticed that the "library validation" code signature check fails on my applications (e.g. adding the .libraryValidation requirement via the LightweightCodeRequirements framework) - with codesign -dvvvv /path/to/app I can check it doesn't have the CS_REQUIRE_LV flag:
[...]
CodeDirectory v=20500 size=937 flags=0x10000(runtime) hashes=18+7 location=embedded
[...]
then I used in Xcode the "Other Code Signing Flags" setting and added the -o library option, which added the flag:
[...]
CodeDirectory v=20500 size=937 flags=0x12000(library-validation,runtime) hashes=18+7 location=embedded
[...]
Is this flag something I should be explicitly setting? Because I was under the impression enabling hardened runtime would be enough. Popular Developer ID distributed applications (e.g. Google Chrome, Parallels Desktop, Slack) all have this flag set.
Hi,
I am facing a very weird issue where I am unable to download our own application from TestFlight for testing.
This issue only happens for one of our applications; we are able to download our other applications without any issues.
Furthermore, this only happens on one of our MacBooks; the game downloads fine on our other MacBook (macOS 15) and can run our application.
When running the console, I noticed this error being thrown when the TestFlight fails the download:
I have tried reinstalling TestFlight, clearing all instances of our application as what Finder can find, restarting the MacBook but nothing worked.
Is there anyone that faced this similar issue, or any Apple staff that could help with this?
OS version: macOS Tahoe (26 Beta) latest
TestFlight was able to download on this version previously, until one day it couldn't (and not sure why), tried downloading latest version but did not solve the issue.
Note: We noticed that we are unable to install our own application from the Appstore as well, on this MacBook that has the TestFlight issue.
Hey I’m working on a macOS app that wants to detect the MacBook lid / hinge angle (i.e. how far the screen is open) by directly reading the internal sensor via HID / IOKit (a private / undocumented API). I came across this project: LidAngleSensor —
GitHub: https://github.com/samhenrigold/LidAngleSensor?tab=readme-ov-file
Before investing too much effort, I’d like to ask the community:
Has anyone succeeded in getting such an app accepted on the Mac App Store when it includes sensor-level, private API access like this?
What were the reviewer feedback or rejection reasons (if any)?
Are there documented cases (positive or negative) where Apple approved or rejected apps for accessing non-public hardware sensors?
What’s the risk of getting banned or permanently rejected for integrating this kind of functionality?
If you have direct experience (whether it passed or failed), I’d love to hear your stories, strategies, or pointers. Thanks in advance!
Hi,
I have been using external NVMe disk since March 2025 with my Mac M1 1TB until recently couple of days agao I updated Mac OS to Tahoe from Sequpoia 15.6. Now Mac OS Tahoe is disconnecting my NVMe automatically saying please eject the disc before disconnecting and suddenly after an hour it reconnects.
Right now I have reinstall Mac OS Sequoia and My external NVMe disk is working again.
This post is for Mac OS developers to check for APFS drivers on Mac Tahoe as they are messing up with external NVMe SSD. I dont know about others brand of NVMe I am using Transcend inclosure with transcend NVMe 2TB SSD hard disk.
Kindly please check as its not NVMe issue its and OS issue. If it was NVMe issue my SSD should also not work with Sequoia but as it is working with Sequoia so it has to be something with Tahoe OS.
Kindly review your code about APFS drivers or thunderbold USB C drivers or may be something else linked to APFS file system.
I hope this post reaches you and you guys can consider it as help ful.
Kind regards
I am coming from C#, where Forms and Controls are placed similar to Swift Storyboards. I have been trying to learn Storyboards, but keep running across tutorials regarding SwiftUI, and Storyboard examples are few. So the question becomes, "how do I position controls on a Form using SwiftUI?" See the example below.
I have run across many videos that use either horizontal or vertical positioning of controls, but these examples are usually very simple, with items occupying only the center portion of the screen. I get stuck on examples that are more complicated.
The example below only shows the controls for the upper part of a Form, with some type of textbox (Viewform) below making up the rest of the Form.
How does one make more complicated placement of controls with SwiftUI?
When I tried turning on ENABLE_ENHANCED_SECURITY = YES in an Xcode 26.1 beta project, I got a bunch of "module file not found" errors like this:
While building module 'CoreServices':
In file included from <module-includes>:1:
/Applications/Xcode26.1-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19:2: fatal error: module file '/Volumes/Work/Xcode-derived/PlainCalc3-gixjfymjqamwmufdwcseugzjehqa/Build/Intermediates.noindex/ExplicitPrecompiledModules/CoreFoundation-5POB3HW0BHFSPWLD7DOOKAULM.pcm' not found: module file not found
19 | #include <CoreFoundation/CoreFoundation.h>
| ^
I tried deleting the project's derived data.
Is this a known issue?
Hi! I am adding MacOS to a SwiftUI based multiplatform app in XCode, and have noticed an effect on the OTF font I am using. When started for a MacOSX target, the font looks a bit fuzzy, or too bold for the same display:
Above is the display running in an iPhone 13 mini simulator, below the macOS version running for the "My Mac" target.
The font is in both cases just fetched with
static let tkDisplayFont = Font.custom("Segment7Standard", size: 38)
Same applies in dark mode:
This makes the numbers and especially the decimal point a bit harder to read. The same happens with the system font, but it is not such a problem there:
I guess this is handled a bit differently between UIFont and NSFont underneath. Is there a way to tell the font to behave the same way as on iOS?
I have some working Objective-C code that displays a WKWebView and allows printing that content. However, it uses the method -[WKWebView printOperationWithPrintInfo:], which the documentation says is deprecated as of macOS 10.15. However, it doesn't say why this method is deprecated, or what the recommended replacement is. The declaration in WKWebView.h does not even indicate that the method is deprecated. But as an alternative, I tried using +[NSPrintOperation printOperationWithView:printInfo]. Doing it that way just prints a blank page. So, should I keep doing it the doubtful way?
Hi Team,
We are trying to understand deep sleep behaviour, can you please help us clarifying on the below questions:
When will we configure Hibernate 25, is it valid for M series MacBooks?
Is Hibernate 25 called deep sleep mode?
What are the settings I need to do on Mac, to make my Mac go in to deep sleep?
When awakening from deep sleep , what would be macOS system behaviour?
If we have custom SFAuthorization plug in at system.login.screensaver, what would be the behaviour with deep sleep?
My code was running with with the version before Xcode 26 RC. I recompiled one last time. Now I'm getting the error: A server with the specified hostname could not be found
let now = Calendar.current.date(byAdding: .hour, value: 1, to: Date())!
let nextWeek = Calendar.current.date(byAdding: .day, value: 14, to: Date())!
do
{
let (dailyForecast, hourlyForecast, currentWeather, alertWeather) =
try await weatherService.weather(for: thisLocation, including: .daily, .hourly(startDate: now, endDate: nextWeek), .current, .alerts)
Suggestions?
I work on a MacBook Pro M3 Max 36GB RAM
I am running macOS Tahoe Version 26.1 Beta (23B5042k)
The last few days I had a couple of situations where Blender 4.5 LTS Froze and I had to forcequit, I noticed Blender would get Deleted with no notification after the forcequit, it was nowhere to be found on the Application List, Finder.
Thought it was a blender issue because I run a special module with it.
However around 30min ago I was using Mem and the App froze and I had to ForceQuit, The app also got removed, is not on the list of application and nowhere to be found however the icon on the dock which remained shows a Question Mark.
I think this is an OS Behavior I just dont know what to attribute it to.
Hi everybody,
I use a very old photo software called Snapseed v 1.2.1 on 2 MacBook, one runs with El Capitan and the second runs with Mojave. These app has no language selection during install, and no preferences language choice in menu when running.
When I execute app on El Capitan, all menus and topics are translate in French, but on Mojave no translation is done.
I looked Contents of app and found differents languages files (structured as xx.po where xx=country) located in Resources folder. I deduced translation was executed after getting language param. I checked values on both systems and there are same (LANG=fr_FR.UTF-8).
So I tried to change Info.plist file to force code langage to 'fr' in CFBundleLocalizations key. Result is same.
Does somebody has a idea of reason of issue and how to solve it ?
Snapseed release was 2012, El Capitan 2015 and Mojave 2018, it seems framework used to code app runs differently and can't get language value.
I have an existing Mac app which has evolved through over twenty years of development. It is currently written in a mixture of C++ and Objective-C, with a bit of C and Swift in a few places. For a few years now, I have been tinkering with replacing the UI with SwiftUI. The model has been completely rewritten in Swift and works fine. After a few tries, no version has been working acceptably, so I'm thinking that I need to rethink the architecture.
The UI consists of a window with a master-detail view. The detail view is what users spend most of their time with. It contains a lot of subviews, around 100 typically. Keyboard events affect the display, so I've had a dedicated data structure to hold the state that is needed for displaying all the subviews. Using Instruments, I see that the view seems to recreate the subviews three times per keyboard event, so I'm clearly doing something wrong.
A second factor is that there are a couple of dozen commands that are applicable to the detail view, driven either by menu items, keyboard shortcut, or toolbar button. Adding all of those to the view makes for a massive SwiftUI View, which seems unlikely to be good practice. The current implementation has the controller class broken up with categories, but still they are big classes.
Most SwiftUI stuff on the web is iOS-oriented, and typically has a focus on fairly simple apps, so the whole topic of dealing with menu commands doesn't get a lot of coverage, so I've been doing all that through my own solutions, which are probably nothing like optimal.
What I've been able to find is not particularly helpful for a full-fledged application like mine, so I'm looking for advice on how to structure the app. The existing one is largely MVC, but I've tried a similar approach and a shot at MVVM, but I'm not getting good results so far.
So, pointers, places I can read more, or samples of real-world apps is what I'm after. Anyone?
I noticing that Monterey defaults to the NSWindowToolbarStyleAutomatic / NSWindowToolbarStyleUnified toolbar style, which suppresses the "use Small Size" menu item and customization checkbox.
So I've set the window to use NSWindowToolbarStyleExpanded. However, the toolbar will no longer change to a smaller icon size, as it did in MacOS 10.14, 10.15, and 11.0.
I've tried to set the toolbar item sizing to "Automatic" for all of our toolbar icons, but that results in bad positioning in both Regular and Small Size mode -- the height is way too big.
The native size of the icon .png files are 128 x 128. What's odd is that if I resize the window with the toolbar to be wider, the NSToolbarItems in the overflow area will be displayed in the toolbar are 128 x 128, where the rest of the toolbar icons get displayed as a 32 x 32 icon.
The only way to get it to layout remotely correct is to make the NSToolbarItem to have an explicit minimum size of 24 x 24 and maximum size of 32 x 32. And that USED to allow "small size", but on Monterey, it no longer does.
Anyone had any success with small size icons on Monterey?
Dear Team,
We have developed a macOS app using Unity (6000.0.51f1) that includes learning activities, assessments/tests, audio recording, and video playback functionalities. For security and content protection, we want to restrict the ability for users to capture screenshots or screen recordings of the app (especially via the built-in Cmd+Shift+5 / Screenshot toolbar).
We have attempted several approaches, but they have not been reliable. We would appreciate guidance from Apple or the developer community on the feasibility of this requirement.
Our requirements:
Block or disable screenshots/screen recordings (particularly the built-in Cmd+Shift+5) for the app.
Preferably achieve this using public APIs so that the app remains App Store compatible and passes review.
If full blocking is not possible, then at least ensure that any captured content appears blank/black for sensitive sections of the app.
Additionally, we would like our app’s window behavior to work like other apps do:
Red button → Close the application completely.
Yellow button → Minimize the application to the Dock.
Green button → Maximize to full screen while still allowing access to the Dock and menu bar.
Any advice, best practices, or references to relevant documentation would be highly valuable.
Thank you for your support.
Topic:
UI Frameworks
SubTopic:
General
Tags:
Automatic Assessment Configuration
macOS
Mac App Store
ScreenCaptureKit
I encountered an undesired DNS behaviour when using L2TP/ipsec VPN.
I have DHCP configured Wi-Fi connection, which send dns servers and search domain (192.168.0.10, lan)
VPN sends its own DNS server (10.0.0.2), search domain (intranet) is added manually in VPN DNS config settings.
I expect, when VPN is connected, to be still able to resolve local names, i.e some-host.lan. However, they become unresolvable.
quick check shows that the remote dns server is used to resolve local names.
shilishper@mac ~ % host -v some-host.lan
Trying "some-host.lan"
Host some-host.lan not found: 3(NXDOMAIN)
Received 106 bytes from 10.0.0.2#53 in 16 ms
Received 106 bytes from 10.0.0.2#53 in 16 ms
Actually, all dns queries are going to the remote server. I would expect that only queries for the configured domain (intranet) should go to that server. I played with the service order, but it didn't change anything.
Is anything can be done about this, programmatically?
PS new to macOS, but have extensive linux knowledge