使用 Xcode 执行由 Swift 包管理器创建的项目
Use Xcode to execute project created by Swift Package Manager
我使用 Swift 包管理器创建了一个项目。为此,我 运行 "swift build --init" 然后添加了两个源文件:
main.swift
import Foundation
print("Hello World")
let swifty = NSURLComponents(string: "https://swift.org")!
print("\(swifty.host!)")
let test = [1, 2, 3]
print(test)
if Process.arguments.count != 2 {
print("Usage: hello Name")
} else {
let name = Process.arguments[1]
sayHello(name)
}
和Greeter.swift
func sayHello(name: String) {
print("Hello, \(name)!")
}
所以这是非常基础的。当我 运行 它直接使用可执行文件 (./.build/debug/LeagueScraper) 时,它就像一个魅力。
但是我希望能够 运行 直接从 Xcode;为此,我编辑方案并将可执行文件设置为我的产品。问题是 Xcode 将 .build 存储在派生数据目录中,然后给我这个错误:
dyld: Symbol not found: __TMPdSa
Referenced from: /Users/aevitas/Library/Developer/Xcode/DerivedData/LeagueScraper-difkqqricvojhwdawinwisptcanb/Build/Products/Debug/LeagueScraper
Expected in: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
in /Users/aevitas/Library/Developer/Xcode/DerivedData/LeagueScraper-difkqqricvojhwdawinwisptcanb/Build/Products/Debug/LeagueScraper
(lldb)
遗憾的是,我在这里有点菜鸟,我不知道如何解决这个问题。
我正在使用使用标准安装程序安装的 Swift 的最新开发快照。
如何让 Xcode 为这个特定项目使用不同的工具链?
非常感谢。
Xcode 用于构建您的代码的工具链与 swift build
所属的 swift 之间存在不匹配。
此错误已在下一个快照中修复。现在请确保您使用正确的工具链启动 Xcode:
xcrun launch-with-toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain
我使用 Swift 包管理器创建了一个项目。为此,我 运行 "swift build --init" 然后添加了两个源文件:
main.swift
import Foundation
print("Hello World")
let swifty = NSURLComponents(string: "https://swift.org")!
print("\(swifty.host!)")
let test = [1, 2, 3]
print(test)
if Process.arguments.count != 2 {
print("Usage: hello Name")
} else {
let name = Process.arguments[1]
sayHello(name)
}
和Greeter.swift
func sayHello(name: String) {
print("Hello, \(name)!")
}
所以这是非常基础的。当我 运行 它直接使用可执行文件 (./.build/debug/LeagueScraper) 时,它就像一个魅力。
但是我希望能够 运行 直接从 Xcode;为此,我编辑方案并将可执行文件设置为我的产品。问题是 Xcode 将 .build 存储在派生数据目录中,然后给我这个错误:
dyld: Symbol not found: __TMPdSa
Referenced from: /Users/aevitas/Library/Developer/Xcode/DerivedData/LeagueScraper-difkqqricvojhwdawinwisptcanb/Build/Products/Debug/LeagueScraper
Expected in: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a.xctoolchain/usr/lib/swift/macosx/libswiftCore.dylib
in /Users/aevitas/Library/Developer/Xcode/DerivedData/LeagueScraper-difkqqricvojhwdawinwisptcanb/Build/Products/Debug/LeagueScraper
(lldb)
遗憾的是,我在这里有点菜鸟,我不知道如何解决这个问题。
我正在使用使用标准安装程序安装的 Swift 的最新开发快照。
如何让 Xcode 为这个特定项目使用不同的工具链?
非常感谢。
Xcode 用于构建您的代码的工具链与 swift build
所属的 swift 之间存在不匹配。
此错误已在下一个快照中修复。现在请确保您使用正确的工具链启动 Xcode:
xcrun launch-with-toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain