我正在尝试学习Twilio的绳索。目的是从我的应用程序发送短信。我在this getting started guide
之后最后一步是在终端中运行此命令:(是的,我已经用自己的项目名称更改了SwiftSMS
)
swift build && ./.build/debug/SwiftSMS
此命令导致以下结果:
MyMac:MyProject MyName $快速构建&& ./.build/debug/myProject编译 Swift模块“ myProject”(1个来源) /卷/myProject/myProject/Sources/myProject/main.swift:2:8:错误: 没有这样的模块“ Alamofire”
导入Alamofire^错误:终止(1):/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Volumes/myProject/myProject/.build/debug.yaml主要输出:
我还没有在Xcode中使用Twilio完成任何配置。据我从指南中了解,这应该发送消息而不用Xcode做任何事情吗?
编辑* :
Package.swift:
// 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: "myProject",
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.0.0")
],
targets: [
.target(
name: "myProject",
dependencies: ["Alamofire"]),
.testTarget(
name: "myProjectTests",
dependencies: ["Alamofire"]),
]
)
答案 0 :(得分:2)
使用它作为您的Package.swift
-您不能简单地说“ Alamofire”并期望SPM神奇地知道从何处获取来源。
import PackageDescription
let package = Package(
name: "myProject",
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.0.0")
],
targets: [
.target(
name: "myProject",
dependencies: ["Alamofire"]),
.testTarget(
name: "myProject Tests",
dependencies: ["Alamofire"]),
]
)