Search code examples
iosswiftosc

Swift iOS - OSC Library


Anyone knows a OSC Swift Library to integrate inside an iOS App?

I am experimenting with this however, I am finding hard to make it work with swift.

I have added in my project a bridge-header file, the project load but cannot convert code into swift.

I want to convert the objective-C code below into swift however I cannot find the property "messageWithAddressPattern" when I try the conversion:

- (IBAction)sendSliderMessage:(UISlider *)sender {
    F53OSCMessage *message = [F53OSCMessage messageWithAddressPattern:@"/slider" arguments:@[[NSNumber numberWithFloat:sender.value]]];
    [self.oscClient sendPacket:message toHost:SENDHOST onPort:SENDPORT];
}

Solution

  • I'm successfully using MetatoneOSC without any issue in a Swift app.

    Here's some working code for sending a message:

    let oscClient = F53OSCClient.init()
    oscClient.host = "127.0.0.1"
    oscClient.port = 3000
    
    let message = F53OSCMessage(addressPattern: "/hello", arguments: [0, 1, 2])
    oscClient.sendPacket(message)
    
    print("Sent '\(message)' to \(oscClient.host):\(oscClient.port)")