I'm trying to get familiar with Swift Package Manager. That's what I did:
swift package init --type executable
- added a dependency in Package.swift
swift build
And everything was fine, but after I tried to import Dependency
in the code xcode says: no such module.
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"]),
]
)
And when i try to build it without xcode it goes
- Compile Swift Module 'SwiftyJSON' (2 sources)
- Compile Swift Module 'ScannerUtils' (2 sources)
- Compile Swift Module 'TelegramBot' (135 sources)
- Compile Swift Module 'todo_bot' (1 sources)
/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
application.xcodeproj
fileswift package generate-xcodeproj
.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 :)