如何使用 Carthage 从 Cartfile 更新一个库?

How to update just one library from the Cartfile with Carthage?

我的 Cartfile 有很多库。当我执行 carthage update 时,它会遍历所有库。这可能需要很长时间。

有没有办法只用迦太基更新一个库?是这样的吗? (这行不通)

carthage update "evgenyneu/moa"

现在答案是否定的......如果你的 运行 carthage help update 你会看到

Update and rebuild the project's dependencies

[--configuration Release]
    the Xcode configuration to build (ignored if --no-build option is present)

[--platform all]
    the platform to build for (ignored if --no-build option is present)

[--verbose]
    print xcodebuild output inline (ignored if --no-build option is present)

[--no-build]
    skip the building of dependencies after updating

[--use-ssh]
    use SSH for downloading GitHub repositories

[--use-submodules]
    add dependencies as Git submodules

[--no-use-binaries]
    check out dependency repositories even when prebuilt frameworks exist (ignored if --no-build option is present)

[--color auto]
    whether to apply color and terminal formatting (one of ‘auto’, ‘always’, or ‘never’)

[/path/to/your/app]
    the directory containing the Carthage project

如您所见,没有提及仅指定一个要更新的依赖项的选项。

你应该open an issue on the project repo请求支持。

我最终编写了自己的脚本,该脚本为我构建了一个依赖项并将其与我现有的依赖项合并。 您可以在 https://github.com/ruipfcosta/carthage-workarounds.

找到它

0.12 version buildcheckoutupdate 获取可选的 space 分隔的依赖项列表

对于像下面这样的 Cartfile

github "Alamofire/Alamofire"
github "ReactiveX/RxSwift"

您可以选择更新一个依赖项

carthage update Alamofire

或多个依赖关系

carthage update Alamofire RxSwift

如果需要添加标志,请最后添加:

carthage update Alamofire --platform iOS

Carthage 支持更新单个依赖项now.If你的 Cartfile 中有这样的东西:

github "bitstadium/HockeySDK-iOS"

然后你可以通过运行

只更新这个依赖
carthage update HockeySDK-iOS

如果框架未存储在 GitHub 中,或者您正在使用 git 标识符,并且您的 cartfile 如下所示:

git "ssh://git@bitbucket.org/teamname/repo-name.git" ~> 1.0

然后你可以只更新那个运行下面的命令

carthage update repo-name

我尝试了所有的答案,对我来说只是 删除评论 临时存储库和 运行

carthage update --platform ios

我将 Catfile 恢复到之前的状态后

Swift 5

//MARK:- Step 1
carthage update KeychainAccess --platform iOS

carthage update SDKNAME(like i mention KeychainAccess upper) --platform iOS

如果您遇到这样的错误

//MARK:- If this error occur
error: unable to find utility "xcodebuild", not a developer tool or in PATH

然后再次在终端中使用第 1 部分

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

再一次

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Carthage --no-use-binaries 和特定模式

[Carthage flow]

carthage [update|bootstrap|checkout|build] [dependency1] [dependency2] [--no-use-binaries] [--platform <name>]

//--no-use-binaries - does not use prebuild binary and use source code
//--platform - specify a platform

最长的阶段是 carthage build(xcodebuild) 步骤,因为:

  1. carthage build 生成 fat binary 是使用 lipo[About]

    构建的
  2. Carthage 构建了一个项目的所有 shared frameworks schemes。如果您确切知道您需要哪个模式,您可以:

    • [UI] 从 Carthage/Checkouts 文件夹打开构建的项目 -> 管理方案... -> 检查特定方案

    • [手动] 在 xcschemes 文件夹中保留特定方案 .../Carthage/Checkouts/<dependency>/<project>.xcodeproj/xcshareddata/xcschemes/<schema>.xcscheme

看起来 carthage update repo-nameCarthage 0.36.0 上不起作用。 我通过手动更新 Carthage.resolved 解决了这个问题。例如,向 Cartfile 添加一个新的依赖项:

github "konkab/AlamofireNetworkActivityLogger" ~> 3.0.0

手动添加到 Cartfile.resolved 新依赖项:

github "konkab/AlamofireNetworkActivityLogger" "3.0.0"

然后carthage bootstrap只更新一个依赖:

carthage bootstrap

它将使用 Carthage.resolved 并且只添加一个依赖项。