Phi*_*oft 1 xcodebuild ionic-framework fastlane ios10 xcode8
我有一个使用 Ionic.io 推送消息的 Ionic 项目。它使用 Fastlane 构建并通过 HockeyApp 部署。
由于升级到 Xcode 8 推送通知不再适用于 iOS 10。
我有一个包含推送授权的授权文件,它使用 ruby 脚本添加到 xcode 项目文件中,请参阅https://github.com/fastlane/fastlane/issues/6544
当我使用 Fastlane push 构建项目时,仍然无法正常工作。当我在 Xcode 中打开项目文件并查看功能部分时,它在“将推送通知权利添加到您的权利文件”中显示了一个复选标记,但在“将推送通知功能添加到您的应用程序 ID”中显示了一个错误。
如果我按“修复”并重建, push确实有效。
所以我的问题是:
我希望能够正确启用推送功能,只使用 Fastlane、xcodebuild、ruby 或其他任何东西,只要它仅在命令行中并允许我的 ionic 项目干净地构建。
所以我通过做两件事设法让它工作:
感谢https://github.com/Azenet和https://github.com/hjanuschka让我完成了 90% 的工作。
#!/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
Run Code Online (Sandbox Code Playgroud)