SkillAgentSearch skills...

Mongrel

A CocoaPods extension enabling the Podfile and any podspecs to declare Swift Package Manager (SPM) dependencies along with the usual pods.

Install / Use

/learn @doganov/Mongrel
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

🐶 Mongrel Package Manager

A CocoaPods extension enabling the Podfile and any podspecs to declare Swift Package Manager (SPM) dependencies along with the usual pods.

A Podfile or podspec declaring SPM dependencies is a "mongrel" one. During CocoaPods' installation step, Mongrel Package Manager (or just Mongrel, in short) updates the user and Pods Xcode projects to reflect the declared SPM dependencies.

Mongrel assumes to own all the Swift package dependency objects in user and Pods Xcode projects. Any manually applied changes involving such objects are likely to be lost after a Mongrel run (i.e., pod install).

0. License

Copyright (C) 2024-2025 Kaloian Doganov kaloian@doganov.org

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

1. Requirements

  • CocoaPods 1.16.2 or later

    Earlier CocoaPods versions ship with older Xcodeproj that doesn't support all of the Swift package-related Xcode object classes that Mongrel needs to operate.

2. Integration

Place mongrel.rb somewhere where the Podfile could reference it. For example, in the same directory where the Podfile is.

Somewhere near the beginning of the Podfile, add the following line (this must be different if mongrel.rb is placed somewhere else):

require_relative 'mongrel'

Then below (usually near the end of the Podfile) add the hooks:

pre_install(installer) {
  Mongrel.pre_install(installer)
  ...
}

post_install(installer) {
  ...
  Mongrel.post_install(installer)
}

3. CocoaPods DSL extensions

3.1. Podfile

User targets defined in the Podfile can use swift to declare Swift package dependency, just like they would use pod to declare a pod dependency:

swift DEPENDENCY

3.2. Podspec and subspec

Podspecs and subspecs can use dependency_swift to declare Swift package dependency, just like they would use dependency to declare a pod dependency:

spec.dependency_swift DEPENDENCY

4. Dependency declarations

A dependency declaration is a Ruby Hash with exactly two keys: :package and :products.

DEPENDENCY ::= :package => PACKAGE, :products => PRODUCTS

A package declaration is, again, a Ruby hash. It represents either a remote package with exact version, remote package with commit, or a local package:

PACKAGE ::= REMOTE_PACKAGE_WITH_EXACT_VERSION
          | REMOTE_PACKAGE_WITH_COMMIT
          | LOCAL_PACKAGE

REMOTE_PACKAGE_WITH_EXACT_VERSION ::= {:url => URL, :exact_version => EXACT_VERSION[,]}

REMOTE_PACKAGE_WITH_COMMIT ::= {:url => URL, :commit => COMMIT_OR_TAG[,]}

LOCAL_PACKAGE ::= {:path => PATH[,]}

URL ::= String containing the Git URL for the Swift Package.

EXACT_VERSION ::= String representing a SemVer 2.0.0 version, as required by Swift Package
                  Manager.

COMMIT_OR_TAG ::= String containing either the SHA-1 hash of a Git commit or a Git tag. Either
                  are resolved in the repo specified by URL.

PATH ::= String containing the path to a Swift package in the local filesystem. The path could
         be either absolute or relative.  In the latter case, it is relative to the directory
         containing the Podfile.

A products declaration is a non-empty list of product names contained in the package. The enclosing dependency declaration declares all listed products as dependencies.

PRODUCTS ::= PRODUCT [, PRODUCTS]

PRODUCT ::= String containing a product name provided by the package denoted by PACKAGE.

5. Examples:

4.1. Podfile

User target in the Podfile depends on a single-product Swift Atomics 1.2.0 package:

swift :package => {
        :url => 'https://github.com/apple/swift-atomics.git',
        :exact_version => '1.2.0',
      },
      :products => ['Atomics']

User target in the Podfile depends on a single-product Swift Atomics package using commit hash:

swift :package => {
        :url => 'https://github.com/apple/swift-atomics.git',
        :commit => 'cd142fd2f64be2100422d658e7411e39489da985',
      },
      :products => ['Atomics']

User target in the Podfile depends on a patched single-product Swift Atomics package using a tag:

swift :package => {
        :url => 'https://github.com/doganov/swift-atomics.git',
        :commit => '1.2.0-doganov.1',
      },
      :products => ['Atomics']

User target in the Podfile depends on four colorful products from a package in the local filesystem placed in a directory Colors, sibling to the directory containing the Podfile:

swift :package => {
        :path => '../Colors',
      },
      :products => ['Black', 'White', 'Green', 'Red']

4.2. Podspec and subspec

A podspec (s) depends on Swift Collections 1.4.0 with two of its products: BitCollections and OrderedCollections:

s.dependency_swift :package => {
                     :url => 'https://github.com/apple/swift-collections.git',
                     :exact_version => '1.4.0',
                   },
                   :products => ['BitCollections', 'OrderedCollections']
View on GitHub
GitHub Stars5
CategoryProduct
Updated1d ago
Forks0

Languages

Ruby

Security Score

85/100

Audited on Apr 6, 2026

No findings