swift - 如何在 Xcode 中添加可由 Swift 包管理器运行的可执行文件?
问题描述
我使用 SPM 来初始化包,然后生成 xcodeproj 以在 Xcode 中进行编辑。我在 Xcode 中添加了一个可执行文件,但 SPM 在构建时没有选择它。如果我使用 SPM 再次运行 generate-xcodeproj,可执行产品就消失了。我查看了 .build 文件夹,可执行文件不存在。现在这是我的 Package.swift:
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Swerver",
products: [
.library(
name: "Swerver",
targets: ["Swerver"]),
],
dependencies: [
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "1.0.8"),
],
targets: [
.target(
name: "Swerver",
dependencies: [
"Socket"
],
path: "Sources/SwerverCore"),
.testTarget(
name: "SwerverTests",
dependencies: ["Swerver"]),
]
)
解决方案
You can't add an executable in Xcode and have it picked up by the Swift Package Manager. You need to add it in the Package.swift file and regenerate the Xcode project.
Alternatively, add the executable to a new project that references the generated project.
推荐阅读
- excel - 如何将一个文件夹中多个excel工作簿上除工作表1和2之外的所有工作表复制到另一个工作簿中
- javascript - 我得到 TypeError: Cannot read property 'state' of undefined 我不明白是什么原因
- objective-c - 替代 HID API 来实现 MacOS 应用程序的游戏控制器?
- database - 插入前触发以根据姓名和姓氏创建主键
- swift - 由于权利不足,代码签名无效
- angular - ngIf 指令中的异步管道
- c# - 找不到 Nuget 包 (Microsoft.EntityFrameworkCore.SqlServer)
- python - 如何在我的 curses 程序中实现类似于 vim 的“命令行”
- wso2 - WSO2 EI/ESB:将负载工厂中的负载附加到后端调用中的路径参数
- javascript - JavaScript 中的双辅音