@eskimo
Whoops 🤦🏼
I've added it now. Apparently something is wrong with my dispatch queue too, as even when properly starting the path monitor, I never got the updates. But it works fine using the main queue… Not entirely sure why yet. But anyway everything seems to work fine now even when enabling the Sandbox, I still get the warnings in the console but it works regardless. Thanks a lot for your help!
_nwqueue = _nwqueue = dispatch_get_main_queue();
__block nw_interface_t intf = NULL;
if (@available(macOS 13.0, *)) {
_monitor = nw_path_monitor_create_for_ethernet_channel();
nw_path_monitor_set_queue(_monitor, _nwqueue);
nw_path_monitor_set_update_handler(_monitor, ^(nw_path_t _Nonnull path) {
nw_path_enumerate_interfaces(path, ^bool(nw_interface_t _Nonnull interface) {
const char *name = nw_interface_get_name(interface);
uint32_t index = nw_interface_get_index(interface);
NSLog(@"Interface %u: %s", index, name);
return true;
});
});
nw_path_monitor_start(_monitor);
} else {
// ...
}
Post
Replies
Boosts
Views
Activity
Thanks @eskimo,
I just tried the new API, however I never get it to print any interfaces, maybe I am doing some obvious mistake here that I am missing?
dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, -1);
attributes = dispatch_queue_attr_make_initially_inactive(attributes);
_nwqueue = dispatch_queue_create("de.epirat.nwqueue", attributes);
if (@available(macOS 13.0, *)) {
nw_path_monitor_t monitor = nw_path_monitor_create_for_ethernet_channel();
nw_path_monitor_set_queue(monitor, _nwqueue);
nw_path_monitor_set_update_handler(monitor, ^(nw_path_t _Nonnull path) {
nw_path_enumerate_interfaces(path, ^bool(nw_interface_t _Nonnull interface) {
const char *name = nw_interface_get_name(interface);
uint32_t index = nw_interface_get_index(interface);
NSLog(@"Interface %u: %s", index, name);
return true;
});
});
} else {
// ...
}
In addition, when Sandbox is enabled, I get a bunch of log messages warning about not being able to access preferences:
2022-07-22 17:02:34.351448+0200 LEDSender[28683:2062406] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x60000338c100> (Domain: com.apple.powerlogd, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access
2022-07-22 17:02:34.466892+0200 LEDSender[28683:2062406] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
2022-07-22 17:02:34.467026+0200 LEDSender[28683:2062406] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
(I already updated my Feedback with these information as well)
I've filed a duplicate Feedback too as I need the same missing API (currently using private API for this) as FB9753262. I've got the update that they believe this is fixed in macOS 13 Beta 3, however as far as I can tell by looking at the API diffs, there is no new API in Beta 3 in the Network framework that would help me get an nw_interface_t, is anyone aware of any new API I might be missing?
I just found this thread after being stuck quite a while trying to figure out how to actually create an nw_interface_t for an interface. Is there any update on this, maybe some new API that I am overlooking here or do I still need this cumbersome workaround?
(Edit: I accidentally posted this as answer, it was meant to be a comment but there is no way to delete this now apparently. Sorry!)
@edford How is this supposed to be handled when building a static library that contains assembly objects, assembled by yasm or nasm, which have no way to set the needed options indicating what exact target/version it's building for?