I have an Ionic project which uses Ionic.io push messaging. It is built with Fastlane and deployed through HockeyApp.
Since upgrading to Xcode 8 push notifications no longer work on iOS 10.
I have an entitlements file containing the push entitlement and it is added to the xcode project file with a ruby script, see https://github.com/fastlane/fastlane/issues/6544
When I build the project with Fastlane push still doesn't work. When I open the project file in Xcode and look at the capabilities section it shows a checkmark in "Add the push notification entitlement to your entitlements file" but shows an error in "add the push notification feature to your app id".
If I press "fix" and rebuild, push does work.
So my problem is:
I want to be able to get the push capability enabled correctly, only using Fastlane, xcodebuild, ruby or whatever, as long as it's only in the command line and allows my ionic project to be built cleanly.
So I managed to get it working by doing two things:
Thanks to https://github.com/Azenet and https://github.com/hjanuschka for getting me 90% of the way.
#!/usr/bin/env ruby
require 'xcodeproj'
name = ARGV[0]
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.save