FileKit
public class FileKit
Resolves commonly used paths, including the project, executable and working directories.
-
The absolute path to the folder containing the project executable.
For example, when running an executable called
MySwiftProject
within Xcode this would be “/Users/username/MySwiftProject/.build/debug”, when running the same project from the command line this would be “/Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug”.Usage Example:
let urlString = FileKit.executableFolder
Declaration
Swift
public static let executableFolder: String
-
URL that points to the directory containing the project executable, or, if run from inside Xcode, the
/.build/debug
folder in the project’s root folder.For example when running an executable called
MySwiftProject
within Xcode this would befile:///Users/username/MySwiftProject/.build/debug/
.Usage Example:
let urlObject = FileKit.executableFolderURL
Declaration
Swift
public static let executableFolderURL: URL
-
URL that points to the executable.
For example, when running an executable called
MySwiftProject
from the command line this would be:file:///Users/username/MySwiftProject/.build/x86_64-apple-macosx10.10/debug/MySwiftProject
.When running within Xcode it would be:
file:///Users/username/Library/Developer/Xcode/DerivedData/MySwiftProject-fjgfjmxrlbhzkhfmxdgeipylyeay/Build/Products/Debug/MySwiftProject
.Usage Example:
let urlObject = FileKit.executableURL
Declaration
Swift
public static let executableURL: URL
-
Absolute path to the directory containing the
Package.swift
of the project (as determined by traversing up the directory structure starting at the directory containing the executable), or if noPackage.swift
is found then the directory containing the executable.For example, when running an executable called
MySwiftProject
this would be something like:/Users/username/MySwiftProject
.Usage Example:
let urlString = FileKit.projectFolder
Declaration
Swift
public static let projectFolder: String
-
URL that points to the directory containing the
Package.swift
of the project (as determined by traversing up the directory structure starting at the directory containing the executable), or if noPackage.swift
is found then the directory containing the executable.For example, when running an executable called
MySwiftProject
this would be something like:file:///Users/username/MySwiftProject/
.Usage Example:
let urlObject = FileKit.projectFolderURL
Declaration
Swift
public static let projectFolderURL: URL
-
Provides the standardized working directory accounting for environmental changes. When running in Xcode, this returns the directory containing the
Package.swift
of the project, while outside Xcode it returns the current working directory.Usage Example:
let urlString = FileKit.workingDirectory
Declaration
Swift
public static let workingDirectory: String
-
URL that points to the standardized working directory accounting for environmental changes. When running in Xcode, this returns the directory containing the
Package.swift
of the project, while outside Xcode it returns the current working directory.Usage Example:
let urlObject = FileKit.workingDirectoryURL
Declaration
Swift
public static let workingDirectoryURL: URL