All Projects → jpsim → pod-diffs

jpsim / pod-diffs

Licence: other
Guide and example for a neat way to modify pods using patchfiles

Programming Languages

objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Modifying Pods with Diffs

Times were simpler (but suckier) when Xcode projects didn't have package management. Now that we have cocoapods, modifying vendored code isn't as obvious.

This project guides you through a neat way to modify pods using patchfiles.

For an overview of the approaches available to modify pods, please read my article on Cocoapods Tips & Tricks.

Process

  • Start off with an Xcode project using cocoapods.

  • Then copy the file you wish to patch into the project's root directory.

  • Edit the file in the root directory with the changes you'd like to make.

  • Create a Diffs directory where you'll keep your patches: mkdir Diffs

  • Generate the patchfile:

diff -u Pods/JPSImagePickerController/JPSImagePickerController/JPSImagePickerController.m JPSImagePickerController.m > Diffs/JPSImagePickerController.m.diff
  • Edit the patchfile to remove dates and have both paths point to Pods:
+++ Pods/JPSImagePickerController/JPSImagePickerController/JPSImagePickerController.m
--- Pods/JPSImagePickerController/JPSImagePickerController/JPSImagePickerController.m
  • Add a post_install block to your Podfile to apply the patch on every pod install:
post_install do | installer |
	`patch -p0 < Diffs/JPSImagePickerController.m.diff`
end
  • Finally, remove the temporary file you created: rm JPSImagePickerController.m

The next times you run pod install, your patches will be applied.

You can take a look at the project in this repo to see this process in action. The Diffs and Podfile will be of interest.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].