百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

cocoapods-spm

> 编程语言
开源

一个 CocoaPods 插件,用于向基于 CocoaPods 的项目添加 SPM 依赖项

99 stars0 点赞5 次浏览
访问官网GitHub

工具介绍

一个 CocoaPods 插件,用于向基于 CocoaPods 的项目添加 SPM 依赖项

cocoapods-spm (CocoaPods + SPM)

A CocoaPods plugin to add SPM dependencies to CocoaPods-based projects.

Installation

Via Bundler: Add the gem cocoapods-spm to the Gemfile of your project.

rb
gem "cocoapods-spm"

Via RubyGems:

bash
$ gem install cocoapods-spm

Usage

Check out the demo at: examples.

Declaring SPM packages

In a podspec

In the podspec of a pod, use spm_dependency to specify the SPM package that the pod depends on, in the following format:

rb
s.spm_dependency "/"

For example, if a pod depends on the Orcam library of this Orcam package, you just need to declare the depenency in the podspec as follows:

rb
Pod::Spec.new do |s|
  s.name = "Foo"
  s.spm_dependency "Orcam/Orcam" #  "https://github.com/trinhngocthuyen/orcam.git", :branch => "main"

Check out this doc for the spm_pkg syntax: declaring packages.

Using Swift Macros with cocoapods-spm

There are two approaches when integrating a Swift macro to a project.

First, you can integrate the macro package just like any other SPM package, by declaring it in Podfile using the spm_pkg method, instructed in the previous section.

Another way is to integrate a macro to the project as prebuilt binary. This was inspired by the approach mentioned in this blog post. This approach helps reduce some build time. This is really beneficial because:

  • It takes time to build such a macro package. swift-syntax, one of its dependencies, already takes up 10-15s.
  • A macro is usually used by many dependants. This leads to delays in compiling those dependants.

By integrating macros as prebuilt binaries, the additional build time should be insignificant.

Integrating macros as prebuilt binaries

In Podfile, simply use the :macro option when declaring a pod.

rb
pod "MacroCodableKit", :macro => {
  :git => "https://github.com/mikhailmaslo/macro-codable-kit",
  :tag => "0.3.0"
}

When running pod install, the plugin prebuilds the declared macros (if not prebuilt before) from their sources.

Wanna know more about its under-the-hood? Check out this doc.

Alternatively, you can prebuild macros with the CLI. Check the subsequent section for details.

Using the CLI

This plugin offers some CLI usages under the spm subcommand (bundle exec pod spm). To explore the usages, run the command with the --help option.

As follows are some common usages.

Fetching macro sources

bash
bundle exec pod spm macro fetch --all

The downloaded sources are put in the .spm.pods/.downloaded folder.

Prebuilding macros

bash
# Prebuild all macros
bundle exec pod spm macro prebuild --all

# Prebuild some macros with the given config
bundle exec pod spm macro prebuild --macros=Orcam --config=debug

Troubleshooting

Refer to the troubleshooting guidelines for details.

Contribution

Refer to the contributing guidelines for details.

License

The plugin is available as open-source under the terms of the MIT License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言