Rog*_*are 7 xcode command-line swift
我正试图在Xcode(8 beta 2)的命令行工具中获取资源的路径.这是我得到的:
在我的main.swift文件中,我有以下代码:
guard let filePath = Bundle.pathForResource("file",
ofType: "xyz",
inDirectory: "Resources") else{
fatalError("Could not find file")
}
Run Code Online (Sandbox Code Playgroud)在fatalError每次触发.有任何想法吗?我知道命令行工具没有应用程序包,这就是为什么资源被复制到Resources文件夹中的原因,但我的inDirectory论点有点猜测...感谢阅读.
编辑:我的主要目标是从CLT访问资源文件(在本例中为文本文件) - 我没有附加到这种特定的方式,所以如果有另一种方法也很棒!
小智 -2
作为解决方法,您可以使用源文件的绝对路径例如,如果在 iCloud 驱动器上:
让路径 =“/Users/myName/Library/Mobile Documents/com~apple~CloudDocs/myDirectory/file.xyz”
| 归档时间: |
|
| 查看次数: |
1636 次 |
| 最近记录: |