Swift 包管理器找不到模块 [英] Swift Package Manager can't find module
问题描述
我正在努力熟悉 Swift 包管理器.这就是我所做的:
I'm trying to get familiar with Swift Package Manager. That's what I did:
swift package init --type executable
- 在 Package.swift 中添加了一个依赖项
快速构建
一切都很好,但是在我尝试在代码中 import Dependency
之后,xcode 说:没有这样的模块.
And everything was fine, but after I tried to import Dependency
in the code xcode says: no such module.
我的 Package.swift 看起来像:
My Package.swift looks like:
import PackageDescription
let package = Package(
name: "todo-bot",
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/zmeyc/telegram-bot-swift.git", from: "0.0.0")
],
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(
named: "todo-bot",
dependencies: ["telegram-bot-swift"]),
]
)
当我尝试在没有 xcode 的情况下构建它时
And when i try to build it without xcode it goes
- 编译 Swift 模块SwiftyJSON"(2 个来源)
- 编译 Swift 模块ScannerUtils"(2 个来源)
- 编译 Swift 模块TelegramBot"(135 个来源)
- 编译 Swift 模块todo_bot"(1 个来源)
/opt/local/include/curl/system.h:399:12: 注意:在构建从/opt/local/include/curl/system.h:399 导入的模块 'Darwin' 时:
#
包括^:338:9: 注意:在 :338 包含的文件中:#
导入ncurses.h"^/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/ncurses.h:141:10:注意:在/Applications/Xcode 包含的文件中.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/ncurses.h:141:#
包括^/opt/local/include/unctrl.h:60:63: 错误:未知类型名称屏幕"NCURSES_EXPORT(NCURSES_CONST char ) NCURSES_SP_NAME(unctrl) (SCREEN, chtype);^/opt/local/include/curl/system.h:399:12: 注意:在构建从/opt/local/include/curl/system.h:399 导入的模块 'Darwin' 时:'#' 包括^/opt/local/include/curl/system.h:399:12: note: while building module 'Darwin' imported from /opt/local/include/curl/system.h:399:
#
include ^ :338:9: note: in file included from :338:#
import "ncurses.h" ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/ncurses.h:141:10: note: in file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/ncurses.h:141:#
include ^ /opt/local/include/unctrl.h:60:63: error: unknown type name 'SCREEN' NCURSES_EXPORT(NCURSES_CONST char ) NCURSES_SP_NAME(unctrl) (SCREEN, chtype); ^ /opt/local/include/curl/system.h:399:12: note: while building module 'Darwin' imported from /opt/local/include/curl/system.h:399: '#' include ^推荐答案
我今天也注意到这个问题在我身上蔓延.我按照以下步骤来消除这个错误.
I have noticed this issue creep up on me today too. I followed the following steps to get rid of this error.
- 关闭
Xcode
应用程序 - 删除
.xcodeproj
文件 - 通过运行
swift package generate-xcodeproj
再次重新生成包.
- Close
Xcode
application - Delete the
.xcodeproj
file - Regenerate the packages again by running
swift package generate-xcodeproj
.
下次您打开
Xcode
项目时,软件包将被正确安装,您将不会遇到任何构建问题.不确定这是否会对某人有所帮助,但我希望它能帮助 :)The next time you open the
Xcode
project the packages will be installed correctly and you won't have any build issues. Not sure this is going to help someone but I hope it does :)这篇关于Swift 包管理器找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!