Module: Pod::Podfile::DSL

Defined in:
lib/cocoapods-podfile_patch/main.rb

Instance Method Summary collapse

Instance Method Details

#use_patch_file!(patchfile_path = 'Podfile.patch') ⇒ Object

Enable Podfile Patch feature.

Thid feature provide the ability to override podfile in another file.

Place a ‘Podfile.patch` at the same directory with Podfile. Configurate the pods in patchfile just like in Podfile. It will append to original podfile, and override the settings in podfile if duplicated.

For example:

Podfile: “‘

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

“‘

Podfile.patch “‘

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

“‘

The final result equal to “‘

target EVA do
    pod "A", :path => "path/to/local/A"
    pod "B", :path => "some/path"
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.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cocoapods-podfile_patch/main.rb', line 40

def use_patch_file!(patchfile_path = 'Podfile.patch')
    
    @current_patch_files ||= []
    if @current_patch_files.include? patchfile_path
        # Yes, you could even use it recureively, but don't use the same patch file.
        raise "`use_patch_file!` called recursively. Most case is it's used in Patch file."
        return 
    end
    
    @current_patch_files << patchfile_path
    require 'cocoapods-podfile_patch/podfile_patch'
    @patch_target = PodfilePatch.new.load_patch_target self, patchfile_path
    @current_patch_files.delete(patchfile_path)
end