Ice

Build Status

❄️ 一款对开发者友好的 Swift 包管理器;100% 兼容 Swift Package Manager

动机

官方的 Swift Package Manager 在实际管理包(解析包版本,编译源码等)方面做得很好,但在开发者友好性方面有所欠缺。 Ice 在其核心中使用 Swift Package Manager,但在 SPM 之上提供了一个更加对开发者友好的层。

Ice 具有一些 SPM 缺乏的特性

安装

Mint(推荐)

mint install jakeheis/Ice

手动

git clone https://github.com/jakeheis/Ice
cd Ice
swift build -c release
install .build/release/ice /usr/local/bin

更好的输出

Init

new

Build

build

Test

test

命令式地管理 Package.swift

管理依赖

ice add RxSwift
ice add Alamofire 4.5.1
ice add jakeheis/SwiftCLI
ice remove Alamofire

管理 targets

ice target add Core
ice target add --test CoreTests --dependencies Core
ice target remove CoreTests

管理 products

ice product add CoreLib --static
ice product add cli --exec --targets=CoreLib
ice product remove CoreLib

集中的包注册表

内置注册表 (https://github.com/jakeheis/IceRegistry) 包含 Github 上 star 最多的 Swift 仓库。 您可以免费使用这些,但您也可以将自己的个人条目添加到本地注册表

> ice registry lookup Alamofire
https://github.com/Alamofire/Alamofire
> ice registry add https://github.com/jakeheis/SwiftCLI SwiftCLI
> ice registry lookup SwiftCLI
https://github.com/jakeheis/SwiftCLI

一旦包进入注册表(无论是共享注册表还是您的本地注册表),您只需通过项目名称即可引用它们

> ice add Alamofire
> ice add SwiftCLI

自动重新构建/重启

ice buildice run 都接受一个 watch 标志,该标志指示它们在源代码文件更改时重新构建/重启您的应用程序

> ice build -w
[ice] rebuilding due to changes...
Compile CLI (20 sources)

  ● Error: use of unresolved identifier 'dsf'

    dsf
    ^^^
    at Sources/CLI/Target.swift:74

[ice] rebuilding due to changes...
Compile CLI (20 sources)
Link ./.build/x86_64-apple-macosx10.10/debug/ice
> ice run -w
[ice] restarting due to changes...

其他命令

ice outdated

检查是否有任何依赖项已过期

> ice outdated
+-----------------+-----------------+----------+--------+
| Name            | Wanted          | Resolved | Latest |
+-----------------+-----------------+----------+--------+
| FileKit         | 4.1.0 ..< 5.0.0 | 4.1.1    | 4.1.1  |
| Rainbow         | 3.1.1 ..< 4.0.0 | 3.1.1    | 3.1.1  |
| Regex           | 1.1.0 ..< 2.0.0 | 1.1.0    | 1.1.0  |
| SwiftCLI        | 4.0.0 ..< 5.0.0 | 4.0.3    | 4.0.4  |
| SwiftyTextTable | 0.8.0 ..< 1.0.0 | 0.8.0    | 0.8.0  |
+-----------------+-----------------+----------+--------+

ice update

更新当前包的依赖项

> ice update
Update https://github.com/jakeheis/SwiftCLI
Resolve https://github.com/jakeheis/SwiftCLI at 4.0.4
> ice update SwiftCLI 5.0.0

ice clean

通过删除构建产物来清理当前项目

ice reset

删除 .build 文件夹中的所有内容(构建产物、已检出的依赖项等)

ice init

在当前目录中初始化一个新包

ice dump

将当前包转储为 JSON

ice describe Alamofire

描述注册表中名称为 "Alamofire" 的包

ice search CLI

在注册表中搜索名称或描述中包含 "CLI" 的包

ice xc

为当前项目生成一个 Xcode 项目并打开它

ice config get/set

配置 Ice 的行为。 可识别的键

FAQ

我可以同时使用 Ice 和 SPM 吗?

可以! 因为 Ice 构建在 SPM 之上,所以您可以无缝地在 iceswift 命令之间来回切换。

为什么 Ice 在内部完全使用 Swift Package Manager? 为什么不编写一个全新的包管理器?

Ice 的一个目标是保持与 SPM 100% 的兼容性 -- Ice 不应以任何方式分裂生态系统。 通过在 SPM 之上构建 Ice,我们可以轻松实现该目标。

为什么不直接将这些改进贡献给 SPM,而是在其之上创建一个新层?

Swift Package Manager 已经考虑了 Ice 中提供的一些改进,但(目前)拒绝了它们。 值得注意的是,SPM 选择将包管理器保留在 swift 可执行文件中,这意味着命令通常非常冗长。 我认为像清理包这样常见的任务不应要求用户键入像 swift package clean 这样长的命令。

话虽如此,我希望 Ice 可以成为这些功能的试验场,一个可以对其进行微调并最终进入 SPM 核心的地方。 理想情况下,Ice 总有一天会变得不必要。