Posts

Post not yet marked as solved
3 Replies
1.3k Views
I think I've found a bug with focusable(_: onFocusChange:) on MacOS with SwiftUI and wanted to sanity check it here before using feedback assistant. This is with Xcode 11.3.1When I create the window, the VStack inside thinks it is in focus. But the onFocusChange closure never gets called to say it loses focus. As a result, both my VStacks in both my windows think they are infocus.Demonstration project at https://github.com/darrellroot/focusBug/Here's my ContentView which displays whether it thinks it is in focus:struct ContentView: View { @State var inFocus = false let windowCount: Int var body: some View { VStack { Text("Focus Window \(windowCount)") inFocus ? Text("This window thinks it is in focus") : Text("This window does not think it is in focus") }.padding(50).focusable() { newFocus in debugPrint("onFocusChange: \(newFocus)") self.inFocus = newFocus } } }Here's my appDelegate code which spawns 1 window on launch and 1 more every time a particular menu is selected: var windows: [Int:NSWindow] = [:] var windowCount = 0 func applicationDidFinishLaunching(_ aNotification: Notification) { newWindow() } @IBAction func newFocusWindow(_ sender: NSMenuItem) { newWindow() } func newWindow() { windowCount = windowCount + 1 let contentView = ContentView(windowCount: windowCount) let window = NSWindow( contentRect: NSRect(x: 100, y: 100, width: 1000, height: 1000), styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false) window.isReleasedWhenClosed = false windows[windowCount] = window window.title = "Focus Window \(self.windowCount)" window.tabbingMode = .disallowed window.center() //window.setFrameAutosaveName("Window \(self.windowCount)") window.contentView = NSHostingView(rootView: contentView) window.makeKeyAndOrderFront(nil) }DebugPrint output shows that onFocusChange got called once per window:2020-03-09 10:24:22.363001-0700 focusBug[2555:258395] Metal API Validation Enabled"onFocusChange: true""onFocusChange: true"
Posted
by droot.
Last updated
.
Post marked as solved
12 Replies
2.7k Views
The "advances in networking" talks for WWDC had this example of using NWEthernetChannel to monitor a custom protocol.import FoundationImport Networklet path = NWPathMonitor(requiredInterfaceType: .wiredEthernet).currentPathguard let interface = path.availableInterfaces.first else { fatalError("not connected to Internet")}let channel = NWEthernetChannel(on: interface, etherType: 0xB26E)For my application I need to use a NWEthernetChannel to monitor a custom protocol* on an Ethernet link which does not have IP Internet connectivity (but it does have physical link to a switch). NWPath appears to only give me a NWInterface struct if it is a valid path to the Internet.How can I get a list of NWInterface Structs on the Mac without having a valid Internet path?In my particular use case I'm only interested in .wiredEthernet.Darrell* I'm trying to use Network.framework to receive LLDP (link-layer discovery protocol) and CDP (Cisco discovery protocol) traffic when I'm plugged into an ethernet switch, which may or may not have Internet connectivity.
Posted
by droot.
Last updated
.
Post not yet marked as solved
1 Replies
847 Views
I'm trying to validate an updated version archive of an existing (and previously approved) MacOS App with Xcode 11.5 on MacOS 10.15.5. When submitting my archive for validation, I get the following errors: App Store Connect Operation Error Invalid Code Signing Entitlements. Your application bundle's signature contains code signing entitlements that are not supported on macOS. Specifically, key 'com.apple.security.network.client' in 'net.networkmom.netrek.pkg/Payload/Netrek.app/Contents/MacOS/Netrek' is not supported. App Store Connect Operation Error Invalid Code Signing Entitlements. Your application bundle's signature contains code signing entitlements that are not supported on macOS. Specifically, key 'com.apple.security.app-sandbox' in 'net.networkmom.netrek.pkg/Payload/Netrek.app/Contents/MacOS/Netrek' is not supported. I've restarted Xcode, cleaned my build folder, deleted and re-added my sandbox capability, and deleted and rebuilt my archive. The above entitlements are "standard". In fact sandbox is a MacOS App Store requirement. Possibly related: this is WWDC week. I'm wondering if something changed on the server side and if we need to wait for Xcode 11.6 to for MacOS Archive validation to work properly. I've gone ahead and submitted my app for review despite the failed archive validation. Fingers crossed the archive validation error is cosmetic (will update post after review).
Posted
by droot.
Last updated
.
Post marked as solved
6 Replies
1.7k Views
I'm working on a packet-capture GUI application using the pcap library (which uses /dev/bpf0) in XCode 11. When in App Sandbox it fails with the following error:pcap_open_live failed with error en0: (cannot open BPF device) /dev/bpf0: Operation not permittedWith app sandbox disabled it succeeds.I set the all of following entitlements but pcap_open_live still failed while sanboxed:sandbox->incoming connections(server)sandbox->outgoing connections(client)Custom network protocolAll 4 network extensions (app proxy, content filter, packet tunnel, dns proxy)Questions:1) Is it possible to use pcap/BPF from within the sandbox (with some other entitlement perhaps?)2) Are the pcap libraries (which are documented in a manpage) considered "non-public API" for purposes of app review guidline 2.5.1 (apps may only use public API's)?(contingency question if the answers to #1/#2 are bad): Is there another way to capture ethernet frames that is acceptable to the app store?Note that app review guideline 2.4.5(i) requires that MacOS apps in the app store be appropriately sandboxed.Thanks!Darrell
Posted
by droot.
Last updated
.