Swift 优先,Swift 最佳的 TextBundle 软件包。支持版本 2 的规范。
如果您正在寻找替代实现,请尝试 shinyfrog/TextBundle。
在 Package.swift
中
dependencies: [
.package(url: "https://github.com/mcritz/TextBundle.git", .upToNextMajor(from: "1.0.0")),
],
... 以及更 नीचे 在 targets 中…
dependencies: [
.product(name: "TextBundle", package: "TextBundle"),
],
从磁盘读取 TextBundle 文本包,可以是 .textbundle
或 .textpack
格式
let myFileURL: URL = ...
let myTextBundle = try TextBundle.read(myFileURL)
let contents: String = myTextBundle.textContents
let myBundle = TextBundle(name: "HelloWorld", contents: "# Hello, World!")
myBundle.bundle(destinationURL: myURL) { bundleFileURL in
print(bundleFileURL.path)
}
感谢 Guillermo Casales @gcasales 在 Unsplash 上免费提供这张照片 🎁 https://unsplash.com/photos/LQfcolSv2M0