Here an excerpt of my recent little App that is creating a FIFO, writes from low level C into it and tries to obtain the written contents from Swift high level code:
@IBAction func sendUDP(_ sender: Any) {
print("calling C and writing to MYFIFO:")
udpC()
var textFromFile = LoadFileAsString(path: "MYFIFO")
}
func LoadFileAsString(path: String) -> String? {
let fm = FileManager()
let exists = fm.fileExists(atPath: path)
if(exists){
let content = fm.contents(atPath: path)
let contentAsString = String(data: content!, encoding:
String.Encoding.utf8)
return(contentAsString)
}
return (nil)
}
Although the function is defined, trying to use it results in an error
Use of unresolved identifier.