I created an app that compile Swift scripts or projects from server side, shows the output, and then the app downloads the executable file.
I know I can't directly run this file, but I can do that from server side, so in my app's file explorer, it should be able to show a custom file icon if the file is executable. When the app downloads the file, this code is ran:
do {
let attributes: [FileAttributeKey:AnyObject] = [FileAttributeKey.posixPermissions: NSNumber(value: 0o775 as UInt16)]
try FileManager.default.setAttributes(attributes, ofItemAtPath: MY_FILE_PATH)
} catch let error {
print(error.localizedDescription)
}
This is the code to check if the file is executable:
print("Is the file executable?")
if FileManager.default.isExecutableFile(atPath: url.path) { // Is executable
image.image = #imageLiteral(resourceName: "Exe")
print("YES")
}
But in the file explorer, the file icon is not the executable icon and there is no error setting file attributes.
So my question is, when FileManager.default.isExecutableFile returns true?
It's from file permissions or from architecture (the file is compiled for a Raspberry Pi and not for iOS) ?