title: Get IP address of Apple Watch
body: <p>How to access IP address of Apple Watch programatically? I have used UIDevice extension in iOS for finding IP. This is an extension of UIDevice but which is not supported in watchOS what could be the other option?</p>
  <pre><code>extension UIDevice {
  
      private struct InterfaceNames {
          static let wifi = [&quot;en0&quot;]
          static let wired = [&quot;en2&quot;, &quot;en3&quot;, &quot;en4&quot;]
          static let cellular = [&quot;pdp_ip0&quot;,&quot;pdp_ip1&quot;,&quot;pdp_ip2&quot;,&quot;pdp_ip3&quot;]
          static let supported = wifi + wired + cellular
      }
  
      func ipAddress() -&gt; String? {
          var ipAddress: String?
          var ifaddr: UnsafeMutablePointer&lt;ifaddrs&gt;?
  
          if getifaddrs(&amp;ifaddr) == 0 {
              var pointer = ifaddr
  
              while pointer != nil {
                  defer { pointer = pointer?.pointee.ifa_next }
  
                  guard
                      let interface = pointer?.pointee,
                      interface.ifa_addr.pointee.sa_family == UInt8(AF_INET) || interface.ifa_addr.pointee.sa_family == UInt8(AF_INET6),
                      let interfaceName = interface.ifa_name,
                      let interfaceNameFormatted = String(cString: interfaceName, encoding: .utf8),
                      InterfaceNames.supported.contains(interfaceNameFormatted)
                      else { continue }
  
                  var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
  
                  getnameinfo(interface.ifa_addr,
                              socklen_t(interface.ifa_addr.pointee.sa_len),
                              &amp;hostname,
                              socklen_t(hostname.count),
                              nil,
                              socklen_t(0),
                              NI_NUMERICHOST)
  
                  guard
                      let formattedIpAddress = String(cString: hostname, encoding: .utf8),
                      !formattedIpAddress.isEmpty
                      else { continue }
  
                  ipAddress = formattedIpAddress
                  break
              }
  
              freeifaddrs(ifaddr)
          }
  
          return ipAddress
      }
  
  }
  
   UIDevice.current.ipAddress() 
  </code></pre>
  <p>How is this possible in watchOS</p>