Я пытаюсь установить правильный шебанг для выполнения скрипта Swift для iOS
#!/usr/bin/env xcrun --sdk iphonesimulator swift -target x86_64-apple-ios12.1-simulator
import Foundation
import UIKit
print("Hello, World!")
, но он не работает.когда я запускаю свой скрипт:
./myScript.swift
Я читаю это в терминале:
<unknown>:0: error: could not load the swift standard library
Я пробовал другой шебангнастройки, чтобы он работал #!/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -target x86_64-apple-ios12.1-simulator
, но все равно безуспешно.
наконец, но не в последнюю очередь важно запустить версию iOS, потому что мне нужно импортировать UIKit.
Спасибо
/// myScript fullversion:
#!/usr/bin/swift
import Foundation
import UIKit
public class FileSystem {
@discardableResult init() {
let fileManager = FileManager.default
do {
let resourceKeys: [URLResourceKey] = [.creationDateKey, .isDirectoryKey]
let documentsURL = fileManager.currentDirectoryPath
guard let enumerator = FileManager.default.enumerator(at: URL(fileURLWithPath: documentsURL),
includingPropertiesForKeys: resourceKeys,
options: [.skipsHiddenFiles], errorHandler: { (url, error) -> Bool in
print("directoryEnumerator error at \(url): ", error)
exit(1)
}) else {
print("error, can't find directory")
exit(1)
}
for case let fileURL as URL in enumerator {
let file = fileURL.lastPathComponent
print(file)
// check if file is a class that conforms to protocol X
}
}
}
}
FileSystem()
./myScript.swift:4:8: error: no such module 'UIKit'