Post

Replies

Boosts

Views

Activity

Reply to NWBrowser scan for arbitrary Bonjour Services with Multicast Entitlement ?!
Hi Quinn, I've been experimenting with NetServiceBrowser to try to get a list of all local Bonjour broadcasts (for a developer app communicating with local devices). I have the com.apple.developer.networking.multicast entitlement and I have confirmed that Xcode is adding the entitlement to the app bundle. private let serviceBrowser = NetServiceBrowser() serviceBrowser.searchForServices(ofType: "_services._dns-sd._udp", inDomain: "local.") serviceBrowser.schedule(in: RunLoop.main, forMode: .common) Running in MacCatalyst under macOS 15.5, the NetServiceDelegate only gets an error, no services are found. didNotSearch: ["NSNetServicesErrorDomain": 10, "NSNetServicesErrorCode": -72008] On iOS 18, the NetServiceDelegate didFind function gets called for each local service, however calls to resolve for each service, result in didNotResolve. Calling the exact same code with a known service, such as "_airplay._tcp" works perfectly, resulting in the delegate receiving didFind for the service and subsequent netServiceDidResolveAddress and didUpdateTXTRecord call backs. I have tried NWBrowser instead, but then found one of your posts stating that this API does not support searching for all available broadcasts. I also tried to adapt your BonjourResolver code but with that I only got a -65540: BadParam error when passing the _services._dns-sd._udp name. I'm at a loss, and wonder if you know of any way I can get this to work under macOS 15 and iOS 18 ? Many thanks
May ’25
Reply to EditMode Example not working
Neither of these solutions worked for me. I needed a ForEach () with rows which can be deleted in EditMode and other views which show or hide depending on Edit Mode. Without any solution, the Edit mode button allowed my ForEach list items to see Edit mode, but not my custom views. The environment variable never changed. The first solution didn't work due to Bindings, key paths and other arguments needing to be passed through to lower levels which just got too complicated. The second solution allowed my custom views to see the changes from the edit button, but the ForEach loop was not able to see the editMode anymore. I came up with the following simple solution which didn't disrupt the ForEach loop, and enabled my CustomViews to react. struct IfEditMode<Content: View>: View { var showView: () -> Content var notEditingView: (() -> Content)? init(@ViewBuilder show: @escaping () -> Content, @ViewBuilder `else`: @escaping () -> Content) { self.showView = show self.notEditingView = `else` } init(@ViewBuilder show: @escaping () -> Content) { self.showView = show self.notEditingView = nil } @Environment(\.editMode) var editMode var body: some View { if editMode?.wrappedValue.isEditing == true { showView() } else if let notEditingView = notEditingView { notEditingView() } } } Use it as follows: // With a single argument, providing a View to show only in EditMode IfEditMode { Text("In Edit Mode") } // Or a second argument, providing a View to show when not in EditMode IfEditMode { Text("In Edit Mode") } else: { Text("Read Only !") } Hope this helps
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’24
Reply to Mac Catalyst 18 TabView selection binding broken
OK I am happy to report I have found a workaround which is benign on other platforms, until Apple fixes TabView on Catalyst. Adding an onAppear() to each tab subview, and manually setting the selectedView stops Catalyst from resetting the subview, and doesn't appear to have any issue on iOS/iPadOS. struct ContentViewFixed: View { @State private var selectedTab: Int = 1 var body: some View { TabView(selection: $selectedTab) { Button("First tab") {} .tabItem {Text("First tab")} .tag(1).onAppear {selectedTab = 1} TestViewButton(color: .blue) .tabItem {Text("Blue")} .tag(2).onAppear {selectedTab = 2} TestViewButton(color: .green) .tabItem {Text("Green")} .tag(3).onAppear {selectedTab = 3} TestViewButton(color: .red) .tabItem {Text("Red")} .tag(4).onAppear {selectedTab = 4} Button("No change") {} .tabItem {Text("No change")} .tag(5).onAppear {selectedTab = 5} } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to Mac Catalyst 18 TabView selection binding broken
I have run into the same issue. If any subview of the TabView is invalidated due to an ObservableObject being updated, on MacCatalyst or Mac designed for iPad builds, the TabView resets to the default tab. No issue on iOS or iPadOS. import SwiftUI @main struct TestTabViewApp: App { var body: some Scene { WindowGroup { ContentView() } } } class AppState: ObservableObject {} struct TestViewButton: View { var color: Color @ObservedObject var appState: AppState = AppState() var body: some View { ZStack { color Button("\(color.description)") { appState.objectWillChange.send() } .padding() .background(.white) } } } struct ContentView: View { var body: some View { TabView { Button("First tab") {} .tabItem {Text("First tab")} TestViewButton(color: .blue) .tabItem {Text("Blue")} TestViewButton(color: .green) .tabItem {Text("Green")} TestViewButton(color: .red) .tabItem {Text("Red")} Button("No change") {} .tabItem {Text("No change")} } } } In the above basic application, each tab has a button. When run on My Mac (Mac Catalyst) or My Mac (made for iPad), pressing the button under the Red, Green or Blue tabs causes the tab view to reset. Pressing the button on the "No change" tab, does not reset the TabView, as the subview state is not invalidated. When run on an iPad 18.0.1 or My Mac (macOS), the TabView behaves correctly, without any reset. Feedback submitted (FB15436253)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to App Store Connect Operation Error: expired profile
Same for me. I have been battling with profiles and certificates all morning. I get the following error Invalid Provisioning Profile Signature. The provisioning profile included in the bundle 'xx.xx.xx' (Payload/xx.app) cannot be used to submit apps to the iOS App Store until it has a valid signature from Apple. (Expired profile signing certificate.) For more information, visit the iOS Developer Portal. With error code STATE_ERROR.VALIDATION_ERROR.90165 for id xxx When I build in Xcode, it says my iOS Team Store Provisioning Profile: (Expires 21/9/22). My Apple Development certificate in the Keychain expires on 10/9/22 I can't find anything expired. As Xcode, Keychain, and the online developer account use different terms for things, I am totally lost as to what the error is actually due to or what I am expected to do (if anything).
Apr ’22