Skip to content

Instantly share code, notes, and snippets.

@aitoraznar
Created January 11, 2018 08:26
Show Gist options
  • Save aitoraznar/87e2c3b458b2d799ae049be5e84d578d to your computer and use it in GitHub Desktop.
Save aitoraznar/87e2c3b458b2d799ae049be5e84d578d to your computer and use it in GitHub Desktop.
Enable IOS Push notificacion script
#!/usr/bin/env ruby
require 'xcodeproj'
name = "app_name" // <-Replace with your app name
projectpath = "platforms/ios/" + name + ".xcodeproj"
puts "Adding entitlement push to " + name
puts "Opening " + projectpath
proj = Xcodeproj::Project.open(projectpath)
entitlement_path = name + "/" + name + ".entitlements"
group_name= proj.root_object.main_group.name
file = proj.new_file(entitlement_path)
attributes = {}
proj.targets.each do |target|
attributes[target.uuid] = {"SystemCapabilities" => {"com.apple.Push" => {"enabled" => 1}}}
#target.add_file_references([file])
puts "Added to target: " + target.uuid
end
proj.root_object.attributes['TargetAttributes'] = attributes
proj.build_configurations.each do |config|
config.build_settings.store("CODE_SIGN_ENTITLEMENTS", entitlement_path)
end
puts "Added entitlements file path: " + entitlement_path
#proj.recreate_user_schemes
proj.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment