Search code examples
swiftorsserialport

Type 'AppDelegate' does not conform to protocol 'ORSSerialPortDelegate' when using ORSSerialPort


I created a brand new Xcode project and the first thing I did was follow the 'using an Xcode subproject' steps on this page: https://github.com/armadsen/ORSSerialPort/wiki/Installing-ORSSerialPort which got the ORSSerialPort source imported into my project for me to use and worked fine. Then I went into AppDelegate.swift and added import ORSSerial, and the project was still buildable.

Next I added ORSSerialPortDelegate into the AppDelegate class declaration (class AppDelegate: NSObject, NSApplicationDelegate, ORSSerialPortDelegate {), so I could use its functions later on and got an error: Type 'AppDelegate' does not conform to protocol 'ORSSerialPortDelegate'.

I do not understand why this error is occurring, because I have checked the demo project for ORSSerialPort and this is exactly what they do. All I want to do it create a simple program that reads the output of an Arduino, why is it so hard? I've followed all the instructions and looked absolutely everywhere but nothing has worked. The only thing I can see that may make a difference is that the demo project does not use AppDelegate for anything, but has a separate file called SerialPortDemoController which the interface uses and in which all code is put. However, I do not want to do this, all I want is to simply use the ORSSerial library directly in AppDelegate, just as I would with CLLocationManagerDelegate, NSUserNotificationCenterDelegate or anything else.


Solution

  • According to protocol's declaration you must implement the following method from the protocol:

    - (void)serialPortWasRemovedFromSystem:(ORSSerialPort *)serialPort;
    

    Implement that and you should be good.