Home > Mobile >  Exclude Private Pods from Acknowledgements.plist
Exclude Private Pods from Acknowledgements.plist

Time:09-16

The CocoaPods Podfile for my iOS app uses a post_install hook to copy the generated Acknowledgements.plist file to my application's Settings bundle. However, the file contains (proprietary) private pods that I'd like to exclude.

Question

I'm aware that I can manually modify the items in the copied Acknowledgements.plist file. How would I exclude specific private pods from the file programmatically?

Code

This is the post_install hook that copies Acknowledgements.plist to the Settings bundle.

post_install do |installer|
  raw_acknowledgements = File.read('Pods/Target Support Files/Pods-MyApp/Pods-MyApp-Acknowledgements.plist')
  formatted_acknowledgements = raw_acknowledgements.gsub(/(?<!>)(?<!\n)\n( *)(?![ \*])(?![ -])(?!\n)(?!<)/, ' ')
  # How do I exclude specific pods before the file is copied?
  File.open('MyApp/Supporting Files/Settings.bundle/Acknowledgements.plist', "w") { |file| file.puts formatted_acknowledgements }
end

Update

I added an answer below that works for now. However, I'm open to accepting another answer that does not involve modifying licenses or using a plugin.

CodePudding user response:

Option 1

It's possible to exclude private pods from the generated Acknowledgements.plist by removing both the LICENSE file and the license object from the Podspec. In the private podspec.json file, the license object looks similar to this:

"license": { "type": "Proprietary", "file": "LICENSE" }

This solution will not work without also removing the LICENSE file.

Option 2

An alternative solution that does not require modifying private pod licenses is to use the CocoaPods Acknowledgements plugin. After installing the cocoapods-acknowledgements gem, add something like this to your Podfile:

plugin 'cocoapods-acknowledgements',
  :settings_bundle => true,
  :targets => ['MyApp'],
  :exclude => ['PrivatePodA', 'PrivatePodB']

Note that the post_install hook from the question is not needed with this solution.

  • Related