Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ifaddrs library in Swift

Tags:

xcode

ios

swift

I´m not able to import ifaddrs to my Swift project. The compiler says:

No such module "ifaddrs"

Aim is to get iPhones IP address in the current wifi network at the end. Any suggestions?

like image 705
Duckjd Avatar asked Dec 19 '22 14:12

Duckjd


1 Answers

Normally under your file ****-Bridging-Header.h (where **** is the name of your project - xcode creates it for you when you include objective c resources) you have to add:

#include <arpa/inet.h>

#include <sys/socket.h>

#include <ifaddrs.h>

After ifaddrs is added to the bridge file, the objective c class can be used in swift.

like image 86
jaumard Avatar answered Dec 22 '22 03:12

jaumard