SwiftKit 使您能够轻松地从命令行生成跨平台的 Swift 框架。
它是启动您的下一个开源 Swift 框架 📦 的最佳方式。
SwiftKit 的灵感来自 SwiftPlate
iOS
, tvOS
, watchOS
和 macOS
CocoaPods
, Carthage
和 Swift Package Manager
README.md
模板tests
和 release
Jazzy
用于生成文档SwiftLint
构建阶段CI-Service
配置模板 (GitHub, Travis, GitLab, Azure Pipelines)CocoaPods
占用Bug reports
和 Feature requests
Mint 是一个包管理器,用于安装和运行 Swift 命令行工具包。
$ mint install SvenTiigi/SwiftKit
Homebrew 是一个免费和开源的软件包管理系统,简化了在 Apple 的 macOS 操作系统上安装软件的过程。
$ brew tap SvenTiigi/SwiftKit
$ brew install swiftkit
要将 SwiftKit 更新到最新版本,只需运行
$ swiftkit update
update
命令仅在 SwiftKit 通过 Mint 🌱 或 Homebrew 🍺 安装时有效
要创建一个新的 Kit,只需运行
$ swiftkit new MyAwesomeKit
这将在当前目录中创建一个新文件夹,以您的 Kit 名称命名
要在当前目录中创建一个 Kit,只需运行
$ swiftkit new
这将根据您的目录名称推断 Kit 名称
如果您希望在生成 Kit 后打开 Xcode 项目,只需运行
$ swiftkit new MyAwesomeKit --open
请访问
Arguments
部分,以了解有关可用参数的更多信息
默认情况下,SwiftKit 将创建一个支持 iOS
、tvOS
、watchOS
、macOS
的 Kit。 如果您只想支持某些 Targets,只需运行
$ swiftkit new MyAwesomeKit --target iOS --target tvOS
这将创建一个仅支持
iOS
和tvOS
的 Kit
以下部分将详细解释您生成的 Kit 的结构。
在生成的 Xcode 项目中,您将找到四个重要的目录。
目录 | 描述 |
---|---|
Sources |
放置您的 Swift 源文件的地方 |
Tests |
放置您的单元测试文件 |
Example |
您的 Kit 的 iOS 应用程序示例 |
Configs |
所有配置文件,如 Plist、Package.swift、Podspec 等。 |
在上述 Sources
目录中,您将找到一个 Swift 文件,该文件以您的 Kit 命名。
// Include Foundation
@_exported import Foundation
当导入您的 Kit 时,此 文件 用于继承
Foundation
的导入。
每个生成的 Kit 都将附带一个预定义的 Fastfile
。
tests
lane 将运行您的单元测试。
$ fastlane ios tests
compatibilityTests
lane 将验证您的 Kit 是否与 Carthage
、CocoaPods
和 Swift Package Manager
兼容。
$ fastlane ios compatibilityTests
release
lane 将允许您自动发布 Kit 的新版本。
$ fastlane ios release version:1.1.0
该 lane 验证 Kit 的各个方面。
步骤 | 描述 |
---|---|
1 | 确保您在干净的 master 分支上 |
2 | 运行 compatibilityTests lane |
3 | 运行 tests lane |
4 | 递增版本 |
5 | 添加并推送 Git tag |
6 | 通过 pod trunk push 推送 Podspec |
☝️ 请确保您已使用
pod trunk register
注册您的机器,以便成功将 Podspec 推送到 CocoaPods
一个 README.md
模板文件将自动在您的 Kit 中创建。
README 包含典型的部分,例如
请随时根据您的需要更新 ReadMe 👍
您可以将 JSON 环境配置文件放置在您的主目录 ~/.swiftkit-env.json
中,以便为以下各项提供默认值
键 | 描述 |
---|---|
authorName |
作者姓名 |
authorEmail |
作者电子邮件地址 |
organizationName |
组织名称 |
organizationIdentifier |
组织标识符 |
SwiftKit 将使用这些值,并在运行 swiftkit new
时跳过相应的 CLI 问题。
{
"authorName": "Sven Tiigi",
"authorEmail": "sven.tiigi@gmail.com",
"organizationName": "Sven Tiigi",
"organizationIdentifier": "de.tiigi"
}
路径:
~/.swiftkit-env.json
仅当不存在相应值的参数时,才会使用环境配置值。
除了使用 CLI 输入外,SwiftKit 还支持在启动时使用参数。 支持以下参数
长参数 | 短参数 | 描述 |
---|---|---|
--target |
-t |
应包含在您的 Kit 中的 Target 📱 |
--destination |
-d |
生成的 Kit 应保存的位置 💾 |
--kit-name |
-k |
您的 Kit 的名称 📦 |
--name |
-n |
您的姓名 👨💻 |
--email |
-e |
您的电子邮件地址 📫 |
--url |
-u |
存储库 url 🌎 |
--ci-service |
-c |
CI-Service 🛠1 = Travis CI - 仅限 macOS 2 = Travis CI - macOS & Linux 3 = GitLab CI 4 = Azure Pipelines 5 = GitHub CI |
--organization |
-o |
您的组织名称 🏢 |
--organization-identifier |
-i |
组织标识符 🖋 |
--repository |
-r |
SwiftKit 模板存储库 url 🌎 |
--force |
-f |
无需确认即可生成 Kit ✅ |
--open |
-o |
在生成 Kit 后打开 Xcode 项目 📂 |
设置了所有参数的示例。
swiftkit new \
--target iOS \
--target tvOS \
--target watchOS \
--target macOS \
--destination ~/Desktop/MyAwesomeKit \
--kit-name MyAwesomeKit \
--name SvenTiigi \
--email sven.tiigi@gmail.com \
--url https://github.com/SvenTiigi/MyAwesomeKit \
--ci-service 1 \
--organization SvenTiigi \
--organization-identifier com.tiigi \
--repository https://github.com/SvenTiigi/SwiftKit.git \
--force \
--open
非常欢迎大家贡献 🙌 🤓
SwiftKit 的灵感来自 SwiftPlate
,由 JohnSundell 提供
SwiftKit
Copyright (c) 2021 Sven Tiigi <sven.tiigi@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.