cocoapods-podfile_patch

This plugin provides the ability to override podfile in another file.

Place a Podfile.patch at the same directory with Podfile. Configure the pods in patchfile just like in Podfile. It will be merged to the original podfile, and override the pods settings in podfile if duplicated.

For example:

Podfile:

    use_patch_file!
    target EVA-0 do
        pod "A", "1.5.3", :inhibit_warning => true
        pod "B", :path => "some/path"
    end

    target EVA-1 do
        pod "A", "1.5.3"
    end

Podfile.patch

    target EVA-0 do
        pod "A", :path => "path/to/local/A"
    end

The final result equal to

    target EVA-0 do
        pod "A", :path => "path/to/local/A"
        pod "B", :path => "some/path"
    end
    target EVA-1 do
        pod "A", :path => "path/to/local/A"
    end

This function is base on the parsed result of podfile. It means you could do ANYTHING you do in podfile, i.e. your custom pod function or other plugins.

Installation

$ gem install cocoapods-podfile_patch

Usage

Basic

  • add use_patch_file! in podfile
  • make your own Podfile.patch in the same directory with Podfile, and code just like in the podfile.
  • pod install

The most common case is to override a pod in podfile with a local pod. You could do like the example above. If you don't want to add a target, you also could do this:

pod "A", :path => "path/to/local/A"

Adding a pod in the root level of podfile is actually supported by the original podfile. It means add the pod to all targets. If you add a root level pod A in the patchfile, it will add A to all targets in podfile.

Advanced

How it works?

The patch file will be eval when use_patch_file! executed. That means you could do ANYTHING as in the podfile. The pod configuration in patchfile will be merged with podfile manually to resolve the conflicts.

Custom patchfile name

use_patch_file! "your_custom_patchfile_name_or_path"