Giter Site home page Giter Site logo

ixrevo / cocoapods-spm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trinhngocthuyen/cocoapods-spm

0.0 0.0 0.0 12.59 MB

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

License: MIT License

Ruby 98.89% Makefile 1.11%

cocoapods-spm's Introduction

cocoapods-spm (CocoaPods + SPM)

Test License Gem

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.

gem "cocoapods-spm"

Via RubyGems:

$ 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:

s.spm_dependency "<package-name>/<ProductName>"

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:

Pod::Spec.new do |s|
  s.name = "Foo"
  s.spm_dependency "Orcam/Orcam" # <--- HERE
end

NOTE: Like pod dependencies, the SPM depenency in a podspec should not state its source. Rather, the source of an SPM package (ex. its repo, which branch, commit...) should be declared in Podfile.

In Podfile

The spm_pkg method to declare the package being used. This method's usage is pretty much similar to the pod method.

spm_pkg "Orcam", :url => "https://github.com/trinhngocthuyen/orcam.git", :branch => "main"

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.

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

bundle exec pod spm fetch --all

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

Prebuilding macros

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

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

Contribution

Feel free to report an issue for submit a PR to make changes in the codebase.

License

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

cocoapods-spm's People

Contributors

trinhngocthuyen avatar github-actions[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.