Skip to content

Instantly share code, notes, and snippets.

@daltonclaybrook
Last active January 21, 2022 22:36
Show Gist options
  • Save daltonclaybrook/e109033af85e6efd6972 to your computer and use it in GitHub Desktop.
Save daltonclaybrook/e109033af85e6efd6972 to your computer and use it in GitHub Desktop.
A post install script for CocoaPods that changes the bundle identifier of all pods to the one specified.
post_install do |installer|
installer.project.targets.each do |target|
target.build_configurations.each do |config|
if config.name == 'BREnterprise'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution: The Carter Group LLC'
config.build_settings['PROVISIONING_PROFILE'] = '${BR_ENTERPRISE_PROVISIONING_PROFILE}'
end
end
end
# change bundle id of each pod to 'com.bottlerocketapps.*'
bundle_id = 'com.bottlerocketapps'
directory = installer.config.project_pods_root + 'Target Support Files/'
Dir.foreach(directory) do |path|
full_path = directory + path
if File.directory?(full_path)
info_plist_path = full_path + 'Info.plist'
if File.exist?(info_plist_path)
text = File.read(info_plist_path)
new_contents = text.gsub('org.cocoapods', bundle_id)
File.open(info_plist_path, "w") {|file| file.puts new_contents }
end
end
end
end
@peter-mach
Copy link

Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment