How to check file is writable in Swift

Last Updated: October 16, 2017

You can use the following code in iOS app development to check the whether the operation system appears able to execute a given file

// First create a FileManager instance
let fileManager = FileManager.default
// Check for executable file
        if fileManager.isExecutableFile(atPath: "test.swift") {
            print("File is executable")
        }else {
            print("File is not  executable")
        }