Skip to content

Instantly share code, notes, and snippets.

@wagyu298
Last active October 6, 2018 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wagyu298/0279da4bd19c3b0336cba37ddfb1b8eb to your computer and use it in GitHub Desktop.
Save wagyu298/0279da4bd19c3b0336cba37ddfb1b8eb to your computer and use it in GitHub Desktop.
Adding local patch to Podfile
# Save this file to the same directory of the Podfile
module PodPatch
def self.apply(installer, patch_target, diff_file)
sandbox_state = installer.analysis_result.sandbox_state
installer.pods_project.targets.each do |target|
pods_to_install = sandbox_state.added | sandbox_state.changed
if target.name == patch_target and pods_to_install.include?(patch_target)
cmd = <<-SHELL
if [ -n "$PODS_ROOT" ]; then
cd "$PODS_ROOT"/Pods/#{patch_target}
else
cd Pods/#{patch_target}
fi
patch -N -r - -p1 < #{Dir.pwd}/#{diff_file}
SHELL
system(cmd)
end
end
end
end
platform :ios, '8.0'
# Add this line to the headding of the Podfile
require './pod_patch'
target 'YourProject' do
pod 'PodNameForPatch'
# And add the patch instructions
pod 'PodNameForPatch'
post_install do |installer|
PodPatch.apply installer, 'PodNameForPatch', "files/patches/PodNameForPatch.diff"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment