Sha256: f88ee049733fa480a6a4d3905691cce0d6b8cff8a444f9f3ca3e734a9c7e709f
Contents?: true
Size: 1.88 KB
Versions: 5
Compression:
Stored size: 1.88 KB
Contents
# frozen_string_literal: true require 'xcodeproj' require 'cfpropertylist' module GoNative module Plugins module IOS class SetBundleId extend DSL::Serviceable attr_reader :bundle_id def initialize(bundle_id, update_entitlements) @bundle_id = bundle_id @update_entitlements = update_entitlements end def call update_project update_entitlements if update_entitlements? end def update_project proj = Xcodeproj::Project.open('./GoNativeIOS.xcodeproj') proj.targets.each do |target| case target.product_type when Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application] set_target_bundle_id(target, bundle_id) when Xcodeproj::Constants::PRODUCT_TYPE_UTI[:app_extension] set_target_bundle_id(target, "#{bundle_id}.#{target.name}") else next end end proj.save end def update_entitlements entitlement_files = `find -E . -maxdepth 2 -regex ".*\.(entitlements)"`.split("\n") entitlement_files.each do |entitlement_file| plist = CFPropertyList::List.new(file: entitlement_file) entitlements = CFPropertyList.native_types(plist.value) entitlements['com.apple.security.application-groups'] = ["group.#{bundle_id}"] plist.value = CFPropertyList.guess(entitlements) plist.save(entitlement_file, CFPropertyList::List::FORMAT_XML) end end private def set_target_bundle_id(target, bundle_id) target.build_configurations.each do |config| config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = bundle_id end end def update_entitlements? @update_entitlements end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems