测试已测试 | ✓ |
Lang语言 | SwiftSwift |
许可 | MIT |
发布最后发布 | 2017年3月 |
SwiftSwift 版本 | 3.0.2 |
SPM支持 SPM | ✓ |
由 Thiago Lioy 维护。
Swift 框架的 cookiecutter 模板
要将 Swifixture 作为 Swift Package Manager 包使用,只需将以下内容添加到您的 Package.swift 文件中。
import PackageDescription
let package = Package(
name: "HelloSwifixture",
dependencies: [
.Package(url: "https://github.com/tplioy/Swifixture.git", "0.0.1")
]
)
如果您不希望使用上述任一依赖管理工具,可以通过手动方式将 Swifixture 集成到项目中。
cd
到您的顶级项目目录,并运行以下命令(如果您的项目尚未初始化为 git 仓库)$ git init
$ git submodule add https://github.com/tplioy/Swifixture.git
$ git submodule update --init --recursive
打开新的 Swifixture
文件夹,并拖动 Swifixture.xcodeproj
到您的应用 Xcode 项目的 Project Navigator 中。
它应该嵌套在您的应用蓝色项目图标之下。它是否在所有其他 Xcode 组之上或之下无关紧要。
在 Project Navigator 中选择 Swifixture.xcodeproj
并验证其部署目标与您的应用目标匹配。
+
按钮。您将看到两个不同的 Swifixture.xcodeproj
文件夹,每个文件夹中都有一个不同的版本 Swifixture.framework
,嵌套在 Products
文件夹中。
您可以选择哪个
Products
文件夹无关紧要。
选择 Swifixture.framework
。
就是这样!
在拷贝文件构建阶段,
Swifixture.framework
会自动被视为目标依赖、链接框架和嵌入框架,这是您在模拟器和设备上构建所需的所有内容。
+
按钮。Swifixture.framework
。要运行示例项目,首先克隆仓库,然后从 Example 目录运行 pod install
。
describe("these will pass") {
it("should be able to load json") {
let json = try! Swifixture("jsonfile").toSwiftyJSON()
expect(json!["prop1"]) == "first prop"
}
it("should be able to map string to obj") {
let object = try! Swifixture("jsonfile").mapTo(FixtureObjectMapper)
expect(object!.prop1) == "first prop"
expect(object!.prop2) == "second prop"
}
it("should be able to load json string") {
let string = try! Swifixture("simple").toString()
expect(string).toNot(beNil())
}
}
describe("these will fail") {
it("should fail if invalid json name is given") {
expect{try Swifixture("invalid").toSwiftyJSON()}.to(throwError())
}
}
Swifixture 在 MIT 许可证下发布。有关详细信息,请参阅 LICENSE。