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
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:
-
Using Xcode 16.1, I created a new project from the macOS > App template template.
-
In Signing & Capabilities, I enabled App Sandbox > Outgoing Connections (client).
-
I modified the content view to issue a request to a server on my local network. The exact code is below.
-
I ran this on my main Mac and confirmed that it worked there.
-
I chose Product > Archive.
-
In the Xcode organiser, I clicked Distribute App and followed the Custom > Direct Distribution > Export workflow.
-
I copied the app a ‘clean’ VM running macOS 15.1.
-
On that VM, I launched the app from the Finder.
-
I clicked Test.
-
The system presented the Local Network alert. I clicked Allow.
-
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.
-
I clicked Test again. This time the request worked.
-
I quit the app.
-
I chose Apple menu > Restart to restart the (virtual) Mac.
-
After the restart, I launched the app the Finder.
-
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()
}
}