Add custom entries to acknowledgments.plist generated by Cocoapods

Viewed 262

Cocoapods generates a plist which can be copied "post_install" to the settings bundle.

I'd love to add some custom entries in for items which need attribution but aren't Cocoapods.

I've looked through the source for https://github.com/CocoaPods/cocoapods-acknowledgements but I am not familiar with Ruby and I can't figure out where to start.

post_install do | installer |
    require'fileutils'
    FileUtils.cp_r('Pods/Target Support Files/Pods-xxx/Pods-xxx-acknowledgements.plist', 'xxx/Settings.bundle/Acknowledgements.plist', :remove_destination => true)


end

I don't need someone to write a whole solution for me, just point me in the right direction.

1 Answers

As my not complete answer got deleted, here now the full working version:

Based on this python script: https://gist.github.com/wagyu298/cb11f5d6eabd9acc7425cc106fc03fd2

We came up with a solution in our project:

def add_license_manually
  require 'cfpropertylist'
  additional_license = {
    "FooterText" => "Copyright (c) 2020, Example Dev All rights reserved.

    Redistribution......",
    "License" => "MIT",
    "Title" => "Library",
    "Type" => "PSGroupSpecifier"
  }
  ack_plist_name = 'Pods/Target Support Files/Pods-xxx/Pods-xxx-acknowledgements.plist'
  # read plist
  plist = CFPropertyList::List.new(:file => ack_plist_name)
  # convert to native data
  data = CFPropertyList.native_types(plist.value)
  # append the license
  data["PreferenceSpecifiers"].insert(-1, additional_license)
  # convert back
  plist.value = CFPropertyList.guess(data)
  # write plist to file
  plist.save(ack_plist_name, CFPropertyList::List::FORMAT_XML)
end

And in your post_install, you add add_license_manually() before the

FileUtis.cp_r(...)

line

Related