Post

Replies

Boosts

Views

Activity

Extracting IP with swift on visionOS
Hey everyone, I’m developing an app for visionOS where I need to display the Apple Vision Pro’s current IP address. For this I’m using the following code, which works for iOS, macOS, and visionOS in the simulator. Only on a real Apple Vision Pro it’s unable to extract an IP. Could it be that visionOS currently doesn’t allow this? Have any of you had the same experience and found a workaround? var address: String = "no ip" var ifaddr: UnsafeMutablePointer<ifaddrs>? = nil if getifaddrs(&ifaddr) == 0 { var ptr = ifaddr while ptr != nil { defer { ptr = ptr?.pointee.ifa_next } let interface = ptr?.pointee let addrFamily = interface?.ifa_addr.pointee.sa_family if addrFamily == UInt8(AF_INET) { if let name: Optional<String> = String(cString: (interface?.ifa_name)!), name == "en0" { var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST)) getnameinfo(interface?.ifa_addr, socklen_t((interface?.ifa_addr.pointee.sa_len)!), &hostname, socklen_t(hostname.count), nil, socklen_t(0), NI_NUMERICHOST) address = String(cString: hostname) } } } freeifaddrs(ifaddr) } return address } Thanks in advance for any insights or tips! Best Regards, David
2
1
153
Jun ’25
Use CoreMotion in Landscape mode
Hello friends I’m currently developing an iOS application that uses the attitude from CoreMotion. For this I need to evaluate the specific values of Pitch, Roll and Yaw. As long as the app is in landscape mode and the device upright (X-axis up), I only need some small adjustments of the values to get the right attitude data. New: Pitch -> Y-axis, Yaw -> X-axis and Roll = Z-axis. func startDeviceMotion() { if motionManager.isAccelerometerAvailable { self.motionManager.deviceMotionUpdateInterval = self.interval self.motionManager.showsDeviceMovementDisplay = true self.motionManager.startDeviceMotionUpdates(using: .xTrueNorthZVertical) // Configure a timer to fetch the motion data self.timer = Timer(fire: Date(), interval: self.interval, repeats: true, block: { (timer) in if let motion = self.motionManager.deviceMotion { // write the values my own orientation data structure self.orientation.azimuthAngle = Measurement(value: -motion.attitude.yaw, unit: UnitAngle.radians) self.orientation.inclinationAngle = Measurement(value: -motion.attitude.roll-(Double.pi/2.0), unit: UnitAngle.radians) self.orientation.bankAngle = Measurement(value: motion.attitude.pitch, unit: UnitAngle.radians) } }) // Add the timer to the current run loop. RunLoop.current.add(self.timer!, forMode: RunLoop.Mode.default) } } However, when I use it in portrait mode (Y-axis up), I can't find a suitable conversion that provides me good values. Most of the time I get mixed values. The goal is that the following axes define Pitch, Roll and Yaw. Pitch -> X-axis, Yaw -> Y-axis, Roll -> Z-axis Has anyone ever had this problem and could explain how to get meaningful pitch, roll and yaw values with an iPad in portrait mode? Kind regards
0
0
708
Sep ’23
SwiftUI FileImporter crashes
Hello Friends I am currently developing a framework that offers a SwiftUI menu among other things. In this menu I use a normal FileImporter. import SwiftUI import UIKit import UniformTypeIdentifiers struct SimulatorConnectionView: View { @State private var isImporting: Bool = false @State private var fileSelected: Bool = false @State private var filename: String = "Select File" @State private var url: URL = URL(string: "/")! var body: some View { VStack{ // some code HStack { StandardButton(title: filename, width: 250, locked: false, action: { isImporting = true }) } // some code }.fileImporter( isPresented: $isImporting, allowedContentTypes: [UTType.text], allowsMultipleSelection: false ) { result in do { guard let selectedFile: URL = try result.get().first else { return } url = selectedFile fileSelected = true filename = selectedFile.lastPathComponent } catch { // Handle failure. print(error.localizedDescription) } } } } I’m using XCode 14.3.1 and I’m building for an iPad Air (4. Gen) with iOS 16.2 When I now run the application that uses the framework and open the FileImporter, the standart window opens. But after a certain time, it starts to flicker and eventually crashes. The following Error Message occurs: 2023-08-29 09:36:37.652586+0200 “MyApplication” [2161:397002] [lifecycle] [u 8130AA3A-2C68-4F54-91D0-9CA032B2644F:m (null)] [com.apple.DocumentManagerUICore.Service(1.0)] Connection to plugin interrupted while in use. 2023-08-29 09:36:37.654256+0200 “MyApplication” [2161:397002] [lifecycle] [u 8130AA3A-2C68-4F54-91D0-9CA032B2644F:m (null)] [com.apple.DocumentManagerUICore.Service(1.0)] Connection to plugin invalidated while in use. 2023-08-29 09:36:37.663598+0200 “MyApplication” [2161:396793] [DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted} 2023-08-29 09:36:37.663672+0200 “MyApplication” [2161:396793] [DocumentManager] Remote view controller crashed with error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}. Trying to relaunch. 2023-08-29 09:36:37.668171+0200 “MyApplication” [2161:397042] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}> Unfortunately, I’ve no idea what this messages want to tell me and google couldn’t help me ether so far. Has maybe someone an idea what the problem could be or can give me at least a hint in which direction I have to search? Kind regards
0
0
666
Aug ’23