Using SwiftUI on macOS, how can I add a toolbar item on the right-most (trailing) edge of the window's toolbar when an Inspector is used?
At the moment, the toolbar items are all left-of (leading) the split view tracking separator. I want the inspector toolbar item to be placed similar to where Xcode's Inspector toolbar item is placed: always as far right (trailing) as possible.
NavigationSplitView {
// ... snip
} detail: {
// ... snip
}
.inspector(isPresented: $isInspectorPresented) {
InspectorContentView()
}
.toolbar {
// What is the correct placement value here?
ToolbarItem(placement: .primaryAction) {
Button {
isInspectorPresented.toggle()
} label: {
Label("Toggle Inspector", systemImage: "sidebar.trailing")
}
}
}
See the attached screenshot. When the InspectorView is toggled open, the toolbar item tracks leading the split view tracking separator, which is not consistent with how Xcode works.
Posts under macOS tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have FileProvider based MacOS application, where user is trying to copy the folder having mix of small and large files. Large files are having size ~ 1.5 GB from FileProvider based drive to locally on Desktop.
Since the folder was on cloud and not downloaded the copy action triggered the download. Small files were downloaded successfully however during large file download the URLSession timed out.
We are using default timeout for URLSession which is 1 min.
I tried to capture logs Console.app where i found FileProvider daemon errors. PFA
Solutions tried so far:
Increased timeout for URLSession from 5 to 10 mins - configuration.timeoutIntervalForRequest
Set timeout for resource - configuration.timeoutIntervalForResource
It happens when we have low network bandwidth. Network connectivity is there but the bandwidth is low.
Any clue by looking at these errors?
I have sadly not found any updated documentation regarding NSPasteboard or clipboard history in Spotlight on macOS Tahoe.
However...
It seems to support the standards outlined in NSPasteboard.org.
Here's my example code in macOS 26.0 Beta:
private func addPasswordToClipboardAsSimpleString() {
NSPasteboard.general.declareTypes([.string], owner: nil)
NSPasteboard.general.setString("Insecure password :(", forType:
.string)
}
private func addPasswordToClipboardAsNSPasteboardOrgString() {
NSPasteboard.general.declareTypes(
[
.string,
.init("org.nspasteboard.ConcealedType"),
.init("org.nspasteboard.TransientType")
],
owner: nil
)
NSPasteboard.general.setString(
"Secure password :)",
forType: .string
)
}
When calling addPasswordToClipboardAsSimpleString(), the string is always visible in clipboard history in spotlight.
When calling addPasswordToClipboardAsNSPasteboardOrgString(), the string is not visible in clipboard history in spotlight. Once the org.nspasteboard.* types are removed from the declaration, the item is visible in clipboard history.
Can someone from Apple confirm what the behavior of the clipboard history is regarding NSPasteboard.org standards? Or is there an official API to mark a confidential (e.g. password) item that I write to NSPasteboard.general not show up in Spotlight's clipboard history?
Hi,
I am curious about if hyperthreading is enabled/disabled on my macbook pro M1 or M4. Howto figure out?
I am using macOS 15.5.
Further, I develop a multi-threaded audio sequencer that creates threads per instrument. I use vector operations to increase performance.
I recognized lowering synchronization rate from 250 Hz to 60 Hz gives additional performance advantages.
Howto programmatically check if Hyperthreading is enabled/disabled and howto enable/disable it programmatically?
After some research I found sysctl() and nvram SMTDisable=%01.
https://support.apple.com/en-us/101870
Can anyone provide me an Objective C example?
regards, Joël
Hello, I am currently researching to develop an application where I want to apply the MacOS updates without the password prompt shown to the users.
I did some research on this and understand that an MDM solution can apply these patches without user intervention.
Are there any other ways we can achieve this? Any leads are much appreciated.
I have a Swift Package, it's added to both the main app and the autofill extension. The main app is an iOS app that run directly on my mac from Xcode.
I use this extension to access the bundle
import Foundation
import OSLog
class CurrentBundleFinder {}
extension Foundation.Bundle {
static let myModule: Bundle = { /* The name of your local package, prepended by "LocalPackages_" */
let bundleName = "DesignSystem_DesignSystem"
let logger = Logger(subsystem: "DesignSystem", category: "Bundle")
logger.error("Searching for bundle: \(bundleName)")
let candidates = [ /* Bundle should be present here when the package is linked into an App. */
Bundle.main.resourceURL, /* Bundle should be present here when the package is linked into a framework. */
Bundle(for: CurrentBundleFinder.self).resourceURL, /* For command-line tools. */
Bundle.main.bundleURL, /* Bundle should be present here when running previews from a different package (this is the path to "…/Debug-iphonesimulator/"). */
Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent(), /* For app extensions - look in parent app bundle */
Bundle.main.bundleURL.deletingLastPathComponent().deletingLastPathComponent(),
]
logger.error("all bundle: \(candidates, privacy: .public)")
for (index, candidate) in candidates.enumerated() {
logger.error("Checking candidate \(index): \(candidate?.absoluteString ?? "nil", privacy: .public)")
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
logger.error("Bundle path: \(bundlePath?.absoluteString ?? "nil", privacy: .public)")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
logger.error("Successfully found bundle at: \(bundlePath?.absoluteString ?? "unknown", privacy: .public)")
return bundle
}
}
logger.error("Unable to find bundle named \(bundleName)")
fatalError("unable to find bundle named \(bundleName)")
}()
}
Bellow is the log from the main app and the autofill extension
log.txt
I have check that /private/var/folders/cb/fctmx0_x3_dbxy_9wnm7g0s40000gn/X/1CC84EBB-DAC0-5120-9346-5EFBC8691CF1/d/Wrapper/Proton Pass.app/PlugIns/AutoFill.appex/DesignSystem_DesignSystem.bundle
exist in the file system, but the autofill extension is unable to create a bundle from that
Our app connects to the headend to get a IDP login URL for each connection session, for example: “https://myvpn.ocwa.com/+CSCOE+/saml/sp/login?ctx=3627097090&acsamlcap=v2” and then open embedded webview to load the page. (Note: the value of ctx is session token which changes every time). Quite often the webview shows blank white screen. After user cancel the connection and re-connect, the 2nd time webview loads the content successfully.
The working case logs shows:
didReceiveAuthenticationChallenge is called
decidePolicyForNavigationAction is called twice
didReceiveAuthenticationChallenge is called
decidePolicyForNavigationResponse is called
didReceiveAuthenticationChallenge is called
But the failure case shows:
Filed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x11461c240 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}}
didReceiveAuthenticationChallenge is called
decidePolicyForNavigationAction is called
decidePolicyForNavigationResponse is called
If we stop calling evaluateJavaScript code to get userAgent, the blank page happens less frequently. Below is the code we put in makeUIView():
func makeUIView(context: Context) -> WKWebView
{
if let url = URL(string: self.myUrl)
{
let request = URLRequest(url: url)
webview.evaluateJavaScript("navigator.userAgent")
{
result, error in
if let error = error
{
NSLog("evaluateJavaScript Error: \(error)")
}
else
{
let agent = result as! String + " " + self.myUserAgent
webview.customUserAgent = agent
webview.load(request)
}
}
}
return self.webview
}
Found some posts saying call evaluateJavaScript only after WKWebView has finished loading its content. However, it will block us to send the userAgent info via HTTP request. And I don’t think it is the root cause since the problem still occurs with less frequency.
There is no problem to load same web page on Windows desktop and Android devices. The problem only occurs on iOS and macOS which both use WKWebview APIs.
Is there a bug in WKWebview?
Thanks,
Ying
The attached file bellow contains the full error
error
I clone this repo to my mac, change team id and group, and run it in Xcode: https://github.com/protonpass/ios-pass
There's no issue when I ran it with the Debug configuration, but when I go to Product > Scheme > Edit Scheme and change the iOS target build configuration to Release then I got that error above.
I have tried Archive and export the ipa, verify that the provisioning profile contains my Mac UDID, but when double clicking the ipa to install, I also got the error This app cannot be installed because its integrity could not be verified.
I am trying to intercept localhost connections within NETransparentProxyProvider system extension. As per NENetworkRule documentation
If the address is a wildcard address (0.0.0.0 or ::) then the rule will match all destinations except for loopback (127.0.0.1 or ::1). To match loopback traffic set the address to the loopback address.
I tried to add
NWHostEndpoint *localhostv4 = [NWHostEndpoint endpointWithHostname:@"127.0.0.1" port:@""];
NENetworkRule *localhostv4Rule = [[NENetworkRule alloc] initWithDestinationNetwork:localhostv4 prefix:32 protocol:NENetworkRuleProtocolAny];
in the include network rules. I tried several variations of this rule like port 0, prefix 0 and some others. But the provider disregards the rule and the never receives any traffic going to localhost on any port.
Is there any other configuration required to receive localhost traffic in NETransparentProxyProvider?
When I have created my developer account I do it on a MacPro 2019.
Now I develop to a new silicon Mac. To submit the (Mac) application
App store Connect give a six-digit verification code.
This code must be enter to popup window that appear on Desktop.
But the popup window appear on MacPro 2019 instead of silicon Mac.
How can I receive popup window in the silicon Mac Desktop, not in MacPro 2019 ?
iCloud staff tell that it imposible to change the computer destination that receive popup window...
Is it true ?
Yes, I can use phone to enter the six-digit verification code but it is very more easy
to enter the code in the popup window.
The result Plist for the InstalledApplicationList MDM command is reporting duplicate Application identifiers. Sometimes with different version, other times with the same version.
The device is MacOS 15.5, Enrolled via ABM (Supervised). Here are a couple samples from the returned list.
Duplicate app:
<key>BundleSize</key>
<integer>398051</integer>
<key>Identifier</key>
<string>com.adobe.Acrobat.NativeMessagingHost</string>
<key>Installing</key>
<false/>
<key>Name</key>
<string>NativeMessagingHost</string>
<key>ShortVersion</key>
<string>5.0</string>
<key>Version</key>
<string>5.0</string>
</dict>
<dict>
<key>BundleSize</key>
<integer>398051</integer>
<key>Identifier</key>
<string>com.adobe.Acrobat.NativeMessagingHost</string>
<key>Installing</key>
<false/>
<key>Name</key>
<string>NativeMessagingHost</string>
<key>ShortVersion</key>
<string>5.0</string>
<key>Version</key>
<string>5.0</string>
</dict>
Different Version:
<key>BundleSize</key>
<integer>4197200</integer>
<key>Identifier</key>
<string>com.adobe.adobe_licutil</string>
<key>Installing</key>
<false/>
<key>Name</key>
<string>adobe_licutil</string>
<key>ShortVersion</key>
<string>11.0.0.39</string>
<key>Version</key>
<string>11.0.0.39</string>
</dict>
<dict>
<key>BundleSize</key>
<integer>4443177</integer>
<key>Identifier</key>
<string>com.adobe.AcroLicApp</string>
<key>Installing</key>
<false/>
<key>Name</key>
<string>AcroLicApp</string>
<key>ShortVersion</key>
<string>25.001.20432</string>
<key>Version</key>
<string>25.001.20432</string>
</dict>
<dict>
<key>BundleSize</key>
<integer>7380980</integer>
<key>Identifier</key>
<string>com.adobe.adobe_licutil</string>
<key>Installing</key>
<false/>
<key>Name</key>
<string>adobe_licutil</string>
<key>ShortVersion</key>
<string>10.0.0.274</string>
<key>Version</key>
<string>10.0.0.274</string>
</dict>
Topic:
Business & Education
SubTopic:
Device Management
Tags:
macOS
Apple Business Manager
Device Management
I reported this as a bug (FB18614667), but also wanted to ask here in case this is actually just me doing something wrong, or maybe I'm misunderstanding the entire use case of metadataRead. (My understanding is that metadataRead is basically read but it checks a cache that the kernel manages before trying to read the physical resource, and in the case of a cache miss it would just go to the physical resource and then add the bytes to the cache. Is that right?)
I’m encountering an issue in an FSKit file system extension where (for example)
read(into: buf, startingAt: 0, length: Int(physicalBlockSize))
works, but
metadataRead(into: buf, startingAt: 0, length: Int(physicalBlockSize))
throws an EIO error (Input/output error) no matter what I do.
(Note: physicalBlockSize is 512 in this example.)
The documentation (https://developer.apple.com/documentation/fskit/fsblockdeviceresource/metadataread(into:startingat:length:)) indicates that the restrictions on metadataRead are that the operations must be sector-addressed (which is the case here, especially as regular read has the same restriction and succeeds) and that partial reading of metadata is not supported. (I don’t think that applies here?)
In a sample project I was able to replicate this behavior where the module only ever reads the block device in its enumerateDirectory implementation, and so trying to list the contents of a directory leads to an "Input/output error" when e.g. running ls on the volume.
The enumerateDirectory sample implementation is like so:
func enumerateDirectory(_ directory: FSItem, startingAt cookie: FSDirectoryCookie, verifier: FSDirectoryVerifier, attributes: FSItem.GetAttributesRequest?, packer: FSDirectoryEntryPacker) async throws -> FSDirectoryVerifier {
let buf = UnsafeMutableRawBufferPointer.allocate(byteCount: Int(blockDevice.physicalBlockSize), alignment: 1)
defer {
buf.deallocate()
}
// metadataRead will throw...
try blockDevice.metadataRead(into: buf, startingAt: 0, length: Int(blockDevice.physicalBlockSize))
// but read will work.
// try await blockDevice.read(into: buf, startingAt: 0, length: Int(blockDevice.physicalBlockSize))
// ... return dummy file here (won't reach this point because metadataRead throws)
}
I'm observing this behavior on both macOS 15.5 (24F74) and macOS 15.6 beta 3 (24G5074c).
Has anyone been able to get metadataRead to work? I see it used in Apple's msdos FSKit implementation so it seems like it has to work at some level.
Hello,
I used icon composer to create an icon for my Mac OS app and it seemed to have worked. I see the app icon everywhere except for window expose or stage manager.
Any help or guidance would be greatly appreciated!
The toolbar in the the Mail app uses seems to force a
.soft scrollEdgeEffectStyle, however I can't seem to reproduce this. Even when putting .scrollEdgeEffectStyle(.soft, for: .top) all over my code, a NavigationSplitView seems to force a "classic" toolbar.
Example, top is the mail app, bottom is my swiftUI app:
I am building a tool that enables the user to write, auto-compile and interact with SwiftUI code (think something like a mini Xcode Canvas). Which so far works really well.
The app is not sandboxed since it uses tools like swiftc and sourcekit-lsp.
The obvious problem here is that since the 'Preview' part of the app is driven by arbitrary code a crash/hang there would lead to a termination of the whole app.
I understand that there are some private apis like NSRemoteView or CALayerHost but I would like to avoid them if I can.
From what I see reading other similar solutions IOSurface sharing + event forwarding might be the best solution.
So my question is: Is there a proper or recommended way to achieve this? Meaning having a fully interactive SwiftUI view presented in my host app but running on a separate process?
Any pointers to the right direction or examples or whatever could help me with this would be greatly appreciated.
[Q] Has there been a change in macOS 15.3.2 and later that can explain why some UDP traffic is not seen by some Network Extensions when it is in previous macOS minor and major versions?
It works on Monterey, but not work on Ventura.
struct ContentView: View {
@FocusState private var focus: FocusableElement?
@FocusedValue(\.focusedElement) var focusElement
var body: some View {
VStack(spacing: 30) {
HStack {
GroupBox {
Circle()
.focusable()
.focused($focus, equals: .circle)
.focusedValue(\.focusedElement, .circle)
.frame(width: 100, height: 100)
.padding()
Text(focus == .circle ? "Selected" : "Not selected")
}
.onTapGesture {
focus = .circle
}
GroupBox {
Rectangle()
.focusable()
.focused($focus, equals: .rectangle)
.focusedValue(\.focusedElement, .rectangle)
.frame(width: 100, height: 100)
.padding()
Text(focus == .rectangle ? "Selected" : "Not selected")
}
}
.onTapGesture {
focus = .rectangle
}
Text("Focused Element: \(focusElement?.rawValue ?? "None")")
}
.padding()
.frame(width: 500, height: 300)
}
}
enum FocusableElement: Equatable, Hashable {
case rectangle
case circle
}
enum Selection: String, Hashable {
case none
case rectangle
case circle
}
extension FocusedValues {
struct FocusedElement: FocusedValueKey {
typealias Value = Selection
}
var focusedElement: FocusedElement.Value? {
get { self[FocusedElement.self] }
set {
self[FocusedElement.self] = newValue
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
.commandsRemoved() does not work for the Window and WindowGroup scenes if it’s the primary group (first one).
Then I tried to add new menu using the code
.commands {
CommandGroup(replacing: .newItem) {
Button("New Document") {
newDocument { TestDocument() }
}
.keyboardShortcut("n")
}
But app crashed with error " Expected subclass override"
The test app is a document-based app, with a welcome window using the new Window scene.
Hello, I'm working on a Transparent Proxy and when the proxy is being stopped, I'm stopping all the flows by calling
flow.closeWriteWithError(POSIXError(.ECANCELED))
flow.closeReadWithError(POSIXError(.ECANCELED))
Then all the flows are deallocated.
When deallocating the flow the crash occurs:
OS Version: macOS 14.1.2 (23B92)
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018c2ef704
Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process: exc handler [553]
Thread 32 Crashed:: Dispatch queue: <my dispatch queue>
0 CoreFoundation 0x18c2ef704 CF_IS_OBJC + 76
1 CoreFoundation 0x18c23f61c CFErrorGetDomain + 32
2 libnetworkextension.dylib 0x19fe56a00 flow_error_to_errno + 28
3 libnetworkextension.dylib 0x19fe56920 flow_handle_pending_write_requests + 216
4 libnetworkextension.dylib 0x19fe5667c __NEFlowDeallocate + 380
5 CoreFoundation 0x18c2efe28 _CFRelease + 292
6 NetworkExtension 0x19d208390 -[NEAppProxyFlow dealloc] + 36
Is there any way to debug what is happening and if it's related to closing the flow with POSIXError?
Thank you
Hi everyone,
I’m working an Objective-C lib that performs Keychain operations, such as generating cryptographic keys and signing data. The lib will be used by my team in a Java program for macOS via JNI.
When working with the traditional file-based Keychain (i.e., without access control flags), everything works smoothly, no issues at all.
However, as soon as I try to generate a key using access control flags SecAccessControlCreateWithFlags, the Data Protection Keychain returns error -34018 (errSecMissingEntitlement) during SecKeyCreateRandomKey. This behavior is expected.
To address this, I attempted to codesign my native dynamic library (.dylib) with an entitlement plist specifying various combinations of:
keychain-access-groups
com.apple.security.keychain
etc.
with:
My Apple Development certificate
Developer ID Application certificate
Apple Distribution certificate
None of these combinations made a difference, the error persists.
I’d love to clarify:
Is it supported to access Data Protection Keychain / Secure Enclave Keys in this type of use case?
If so, what exact entitlements does macOS expect when calling SecKeyCreateRandomKey from a native library?
I’d really appreciate any guidance or clarification. Thanks in advance!
Best regards,
Neil