Re: Adding the com.apple.security.network.client entitlement
Re: Adding the com.apple.security.network.client entitlement
- Subject: Re: Adding the com.apple.security.network.client entitlement
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Mon, 01 Oct 2018 16:31:40 -0700
On 1 Oct 2018, at 13:58, Carl Hoefs <email@hidden> wrote:
> I've tried running the program from within Xcode, as a standalone
> command-line invocation, and as a Launch Agent, and even using sudo.
I’m not sure what’s going on in your environment but CoreWLAN is working for
me. I tested it both from an app and from a command-line tool:
* The app was sandboxed, and thus needed the
`com.apple.security.network.client` entitlement.
* The tool was not sandboxed and thus has no networking entitlements (remember
that on macOS the App Sandbox is an /app/ sandbox, and is only appropriate for
apps and app extensions).
In both case the executable was signed with my Developer ID.
My tests shown the same behaviour on 10.13.6 and 10.14, that is:
* A sandboxed app needs the `com.apple.security.network.client` entitlement.
* A non-sandboxed app does not.
* Likewise for a command-line tool.
I’ve included a copy of my command-line tool’s code below, so you can try this
for yourself. I built it with Xcode 10.0 and ran it on macOS 10.14.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
---------------------------------------------------------------------------
import Foundation
import CoreWLAN
class Main : NSObject, CWEventDelegate {
let client: CWWiFiClient = CWWiFiClient.shared()
func start() throws {
self.client.delegate = self
try self.client.startMonitoringEvent(with: .powerDidChange)
}
func powerStateDidChangeForWiFiInterface(withName interfaceName: String) {
guard let interface = client.interface(withName: interfaceName) else {
NSLog("tool power no interface, name: %@", interfaceName)
return
}
let isPowerOn = interface.powerOn()
NSLog("tool power, name: %@, on: %@", interfaceName, isPowerOn ? "yes"
: "no")
}
}
func mainThrowing() throws {
NSLog("tool start")
let m = Main()
try withExtendedLifetime(m) {
try m.start()
dispatchMain()
}
}
func main() {
do {
try mainThrowing()
} catch {
NSLog("tool failed, error: %@", "\(error)")
}
}
main()
exit(EXIT_SUCCESS)
---------------------------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden