gpt4 book ai didi

Swift Package Manager - 语音依赖不加载

转载 作者:可可西里 更新时间:2023-11-01 01:51:50 25 4
gpt4 key购买 nike

我在为我的项目创建 Swift 包时遇到问题。我有 CocoaPods 和 Travis CI 正在运行并且两者都在流畅地工作,但是我现在还打算通过 Swift Package Manager 提供该项目。这就是我遇到问题的地方。我的包文件如下所示:

// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Voxosonus",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Voxosonus",
targets: ["Voxosonus"]),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Voxosonus",
path: "Voxosonus"),
.testTarget(
name: "VoxosonusTests",
dependencies: ["Voxosonus"],
path: "VoxosonusTests"),
]
)

然而,当我运行 swift build 时,我遇到了以下问题:

/Users/<hidden>/Documents/Projecten/Voxosonus/Voxosonus/SpeechRecognizer.swift:8:8: error: no such module 'Speech'
import Speech

我的问题是 - 为什么找不到“语音”模块?这是 Apple 自己的核心功能,到目前为止,互联网还没有让我变得更聪明。该项目的一些细节:

构建目标:iOS 12.x

苹果操作系统:10.14

swift 版本:4.2.1

最佳答案

Swift Package Manager Github 中所述,您还不能定义 Swift 包 的目标平台:

At this time there is no explicit support for depending on UIKit, AppKit, etc, though importing these modules should work if they are present in the proper system location. We will add explicit support for system dependencies in the future. Note that at this time the Package Manager has no support for iOS, watchOS, or tvOS platforms.

因此,当您尝试使用 Xcode(或使用 swift build 命令)构建库时,编译器无法找到 Speech 模块,因为它仅适用于 iOS 10+。

你可以查看这个github project (swift-package-manager-ios) 它提供了一个 ruby​​ 脚本,它通过添加必要的信息来修改由 Swift Package Manager 生成的 xcodeproj,以便为 iOS 构建平台。

关于Swift Package Manager - 语音依赖不加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54020478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com