Manage ifaddrs to return MAC addresses as well in Swift

前端 未结 2 656
失恋的感觉
失恋的感觉 2020-12-06 08:27

I\'ve got the following code that successfully retrieves all the IPs connected to my router. But I need to a get the MAC Addresses for each IP.

So instead of addres

2条回答
  •  情深已故
    2020-12-06 08:41

    If you will use this inside a framework, you have to add a .modelmap file with this configuration inside it

    module ifaddrs [system]  [extern_c] {
        header
        "/Applications/Xcode_7.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/ifaddrs.h"
        export *
    }
    
    module net [system]  [extern_c] {
    
         module types {
             header "/usr/include/sys/types.h"
             export *
         }
    
         module if_dl {
    
             header
             "/usr/include/net/if_dl.h"
             export *
         }
    
     }
    

    and then in your .swift file

    import ifaddrs
    import net.if_dl
    

提交回复
热议问题