If you restart Mac after allow LNP, the LNP of APP will not working

The first time my application opened the app on macos15, after I enabled the LNP, my app could access the local network (a socket service was opened locally), but when I restarted the computer and opened the APP again, I could not access the local network at this time, why? Solution :1. Disable and enable the LNP or 2. Reinstall the app

Answered by DTS Engineer in 812081022

It’s better if you reply in as a reply rather than in the comments. See Quinn’s Top Ten DevForums Tips for more on that, and for lots of other hints and tips.

My application is a GUI application, and my packaging adopts the "Direct Distribution" mode of Xcode.

This is working for me. Here’s what I did:

  1. Using Xcode 16.1, I created a new project from the macOS > App template template.

  2. In Signing & Capabilities, I enabled App Sandbox > Outgoing Connections (client).

  3. I modified the content view to issue a request to a server on my local network. The exact code is below.

  4. I ran this on my main Mac and confirmed that it worked there.

  5. I chose Product > Archive.

  6. In the Xcode organiser, I clicked Distribute App and followed the Custom > Direct Distribution > Export workflow.

  7. I copied the app a ‘clean’ VM running macOS 15.1.

  8. On that VM, I launched the app from the Finder.

  9. I clicked Test.

  10. The system presented the Local Network alert. I clicked Allow.

  11. Back in the app, the status label shows that the request failed with failed with -1009. This is expected. I talk about this in TN3179 Understanding local network privacy; search the doc for “deny the operation immediately” to find that discussion.

  12. I clicked Test again. This time the request worked.

  13. I quit the app.

  14. I chose Apple menu > Restart to restart the (virtual) Mac.

  15. After the restart, I launched the app the Finder.

  16. I clicked Test. The request worked as expected.

I’m not sure why this is failing in your case but my experience is that there isn’t a widespread problem with this. If there were, I’d have seen a lot of complaints about it.

I recommend that you run through the above process to confirm that it also works for you. And yes, that means setting up a VM. That’s the only reliable way to test this stuff IME.

Once you’ve confirm that the above process works, we can start exploring why you’re app is failing. It could be as simple as running it in a ‘clear’ VM rather than on your development machine. Or it could be something specific about the API you’re using.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


struct ContentView: View {
    @State var status: String = "Tap Test to start."
    var body: some View {
        VStack {
            Text(status)
            Button("Test") {
                Task {
                    do {
                        status = "Running…"
                        let url = URL(string: "http://192.168.1.39")!
                        let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 60.0)
                        let (data, response) = try await URLSession.shared.data(for: request)
                        let httpResponse = response as! HTTPURLResponse
                        status = "status: \(httpResponse.statusCode), bytes: \(data.count)"
                    } catch let error as NSError {
                        status = "error: \(error.domain) / \(error.code)"
                    }
                }
            }
        }
        .padding()
    }
}

Computer console print:nw_path_libinfo_path_check [F3FF4A69-A8FB-42CE-924A-C17D137BC489 IPv4#07b4aa60:3460 tcp, legacy-socket, attribution: developer] libinfo check path: unsatisfied (Local network prohibited), interface: en111

It’s hard to say what’s triggering this, but I do have some questions:

  • What version of macOS are you testing on? LNP has some issues on macOS 15.0, so I suggest you test with 15.1 or later.

  • Is “my application” a GUI application? Or something less common, like a daemon or agent?

  • If it’s a GUI app, does the problem reproduce if you run the app from the Finder?

  • How are you building your code? With Xcode? Or directly from the command-line? Or with some third-party tools?

  • Is your code signed with a stable code signing? Anything other than ad hoc signing (Sign to Run Locally in Xcode parlance) will be fine.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It’s better if you reply in as a reply rather than in the comments. See Quinn’s Top Ten DevForums Tips for more on that, and for lots of other hints and tips.

My application is a GUI application, and my packaging adopts the "Direct Distribution" mode of Xcode.

This is working for me. Here’s what I did:

  1. Using Xcode 16.1, I created a new project from the macOS > App template template.

  2. In Signing & Capabilities, I enabled App Sandbox > Outgoing Connections (client).

  3. I modified the content view to issue a request to a server on my local network. The exact code is below.

  4. I ran this on my main Mac and confirmed that it worked there.

  5. I chose Product > Archive.

  6. In the Xcode organiser, I clicked Distribute App and followed the Custom > Direct Distribution > Export workflow.

  7. I copied the app a ‘clean’ VM running macOS 15.1.

  8. On that VM, I launched the app from the Finder.

  9. I clicked Test.

  10. The system presented the Local Network alert. I clicked Allow.

  11. Back in the app, the status label shows that the request failed with failed with -1009. This is expected. I talk about this in TN3179 Understanding local network privacy; search the doc for “deny the operation immediately” to find that discussion.

  12. I clicked Test again. This time the request worked.

  13. I quit the app.

  14. I chose Apple menu > Restart to restart the (virtual) Mac.

  15. After the restart, I launched the app the Finder.

  16. I clicked Test. The request worked as expected.

I’m not sure why this is failing in your case but my experience is that there isn’t a widespread problem with this. If there were, I’d have seen a lot of complaints about it.

I recommend that you run through the above process to confirm that it also works for you. And yes, that means setting up a VM. That’s the only reliable way to test this stuff IME.

Once you’ve confirm that the above process works, we can start exploring why you’re app is failing. It could be as simple as running it in a ‘clear’ VM rather than on your development machine. Or it could be something specific about the API you’re using.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


struct ContentView: View {
    @State var status: String = "Tap Test to start."
    var body: some View {
        VStack {
            Text(status)
            Button("Test") {
                Task {
                    do {
                        status = "Running…"
                        let url = URL(string: "http://192.168.1.39")!
                        let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 60.0)
                        let (data, response) = try await URLSession.shared.data(for: request)
                        let httpResponse = response as! HTTPURLResponse
                        status = "status: \(httpResponse.statusCode), bytes: \(data.count)"
                    } catch let error as NSError {
                        status = "error: \(error.domain) / \(error.code)"
                    }
                }
            }
        }
        .padding()
    }
}
If you restart Mac after allow LNP, the LNP of APP will not working
 
 
Q