Class: NotificationExtensionIntegrator
- Inherits:
-
Object
- Object
- NotificationExtensionIntegrator
- Defined in:
- lib/mmine/notification_extension_integrator.rb
Instance Method Summary collapse
- #addNotificationExtensionSourceCode ⇒ Object
- #createAppGroupEntitlements(_entitlements_name) ⇒ Object
- #createNotificationExtensionDir ⇒ Object
- #createNotificationExtensionTarget ⇒ Object
- #getNotificationExtensionGroupReference ⇒ Object
- #getXMLStringValue(key, plist_path) ⇒ Object
-
#initialize(application_code, project_file_path, app_group, main_target_name, cordova = false, swift_ver) ⇒ NotificationExtensionIntegrator
constructor
A new instance of NotificationExtensionIntegrator.
- #logger ⇒ Object
- #logger=(_logger) ⇒ Object
- #putAppGroupEntitlement(filepath) ⇒ Object
- #putApplicationCodeInSourceCode ⇒ Object
-
#putKeyArrayElement(key, value, filepath) ⇒ Object
check if it appends to existing array.
- #putStringValueIntoXML(key, value, plist_path) ⇒ Object
- #removeEmbedFrameworkPhase ⇒ Object
- #resolveAbsolutePath(path) ⇒ Object
- #resolveXcodePath(path) ⇒ Object
- #setNotificationExtensionBuildSettings(key, debug_value, release_value = nil) ⇒ Object
- #setupAppGroupPlistValue ⇒ Object
- #setupBackgroundModesPlistValue ⇒ Object
- #setupBuildNumber ⇒ Object
- #setupCopyFrameworkScript ⇒ Object
- #setupDeploymentTarget ⇒ Object
- #setupDevelopmentTeam ⇒ Object
- #setupEmbedExtensionAction ⇒ Object
- #setupEntitlements(_build_settings_debug, _build_settings_release, target_name) ⇒ Object
- #setupExtensionTargetCapabilities ⇒ Object
- #setupFrameworkSearchPaths ⇒ Object
- #setupLibCordovaLink ⇒ Object
- #setupMainTargetCapabilities ⇒ Object
- #setupMainTargetDependency ⇒ Object
- #setupMainTargetEntitlements ⇒ Object
- #setupNotificationExtension ⇒ Object
- #setupNotificationExtensionBundleId ⇒ Object
- #setupNotificationExtensionEntitlements ⇒ Object
- #setupNotificationExtensionInfoPlist ⇒ Object
- #setupProductName ⇒ Object
- #setupRunpathSearchPaths ⇒ Object
- #setupSwiftVersion ⇒ Object
Constructor Details
#initialize(application_code, project_file_path, app_group, main_target_name, cordova = false, swift_ver) ⇒ NotificationExtensionIntegrator
Returns a new instance of NotificationExtensionIntegrator.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mmine/notification_extension_integrator.rb', line 16 def initialize(application_code, project_file_path, app_group, main_target_name, cordova = false, swift_ver) @project_file_path = project_file_path @app_group = app_group @main_target_name = main_target_name @logger = nil @cordova = cordova @swift_version = swift_ver @application_code = application_code @project_dir = Pathname.new(@project_file_path).parent.to_s @project = Xcodeproj::Project.open(@project_file_path) @ne_target_name = 'MobileMessagingNotificationExtension' @framework_file_name = "MobileMessaging.framework" @extension_source_name_filepath = File.join(Mmine.root, 'resources','NotificationService.swift') @extension_dir_name = 'NotificationExtension' @extension_destination_dir = File.join(@project_dir, @extension_dir_name) @extension_code_destination_filepath = File.join(@extension_destination_dir, 'NotificationService.swift') @extension_group_name = 'NotificationExtensionGroup' @plist_name = 'MobileMessagingNotificationServiceExtension.plist' @plist_source_filepath = File.join(Mmine.root, 'resources', @plist_name) @extension_info_plist_path = File.join(@project_dir, @extension_dir_name, @plist_name) @main_target = @project.native_targets().select { |target| target.name == @main_target_name }.first @main_target_build_settings_debug = @main_target.build_configurations.select { |config| config.type == :debug }.first.build_settings @main_target_build_settings_release = @main_target.build_configurations.select { |config| config.type == :release }.first.build_settings @main_target_debug_plist = resolveAbsolutePath(@main_target_build_settings_debug["INFOPLIST_FILE"]) @main_target_release_plist = resolveAbsolutePath(@main_target_build_settings_release["INFOPLIST_FILE"]) end |
Instance Method Details
#addNotificationExtensionSourceCode ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/mmine/notification_extension_integrator.rb', line 114 def addNotificationExtensionSourceCode unless File.exist?(@extension_code_destination_filepath) @logger.info("Copying notification extension source code to path: #{@extension_code_destination_filepath}") FileUtils.cp(@extension_source_name_filepath, @extension_code_destination_filepath) filereference = getNotificationExtensionGroupReference().new_reference(@extension_code_destination_filepath) @ne_target.add_file_references([filereference]) else @logger.info("Notification extension source code already exists on path: #{@extension_code_destination_filepath}") end putApplicationCodeInSourceCode() end |
#createAppGroupEntitlements(_entitlements_name) ⇒ Object
401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'lib/mmine/notification_extension_integrator.rb', line 401 def createAppGroupEntitlements(_entitlements_name) entitlements_destination_filepath = File.join(@project_dir, _entitlements_name) entitlements_source_filepath = File.join(Mmine.root, 'resources', "MobileMessagingNotificationExtension.entitlements") unless File.exist?(entitlements_destination_filepath) @logger.info("\tCopying entitlemenst file to path: #{entitlements_destination_filepath}") FileUtils.cp(entitlements_source_filepath, entitlements_destination_filepath) ref = @project.main_group.new_reference(entitlements_destination_filepath) ref.last_known_file_type = "text.xml" else @logger.info("\tEntitlements file already exists on path: #{entitlements_destination_filepath}") end putAppGroupEntitlement(entitlements_destination_filepath) return entitlements_destination_filepath end |
#createNotificationExtensionDir ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/mmine/notification_extension_integrator.rb', line 105 def createNotificationExtensionDir unless File.directory?(@extension_destination_dir) @logger.info("Creating directory: #{@extension_destination_dir}") FileUtils.mkdir_p(@extension_destination_dir) else @logger.info("Notification extension directory already exists: #{@extension_destination_dir}") end end |
#createNotificationExtensionTarget ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/mmine/notification_extension_integrator.rb', line 85 def createNotificationExtensionTarget @ne_target = @project.native_targets().select { |target| target.name == @ne_target_name }.first if @ne_target == nil @logger.info("Creating notification extension target with name #{@ne_target_name}") @ne_target = @project.new_target(:app_extension, @ne_target_name, ':ios') else @logger.info("Notification extension target already exists, reusing...") end @extension_build_settings_debug = @ne_target.build_configurations.select { |config| config.name == 'Debug' }.first.build_settings @extension_build_settings_release = @ne_target.build_configurations.select { |config| config.name == 'Release' }.first.build_settings @ne_target.frameworks_build_phase.files_references.each { |ref| @ne_target.frameworks_build_phase.remove_file_reference(ref) } @logger.info("Notification extension target debug build settings:\n#{JSON.pretty_generate(@extension_build_settings_debug)}") @logger.info("Notification extension target release build settings:\n#{JSON.pretty_generate(@extension_build_settings_release)}") end |
#getNotificationExtensionGroupReference ⇒ Object
393 394 395 396 397 398 399 |
# File 'lib/mmine/notification_extension_integrator.rb', line 393 def getNotificationExtensionGroupReference group_reference = @project.groups().select { |group| group.name == @extension_group_name }.first if group_reference == nil group_reference = @project.new_group(@extension_group_name, @extension_destination_dir) end return group_reference end |
#getXMLStringValue(key, plist_path) ⇒ Object
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/mmine/notification_extension_integrator.rb', line 437 def getXMLStringValue(key, plist_path) plist_path = resolveAbsolutePath(plist_path) doc = Nokogiri::XML(IO.read(plist_path)) key_node = doc.search("//dict//key[text() = '#{key}']").first if key_node == nil return nil else existing_string_value_node = key_node.xpath("following-sibling::*").first if existing_string_value_node.name == 'string' return existing_string_value_node.content else return nil end end end |
#logger ⇒ Object
49 50 51 |
# File 'lib/mmine/notification_extension_integrator.rb', line 49 def logger return @logger end |
#logger=(_logger) ⇒ Object
46 47 48 |
# File 'lib/mmine/notification_extension_integrator.rb', line 46 def logger=(_logger) @logger = _logger end |
#putAppGroupEntitlement(filepath) ⇒ Object
524 525 526 |
# File 'lib/mmine/notification_extension_integrator.rb', line 524 def putAppGroupEntitlement(filepath) putKeyArrayElement("com.apple.security.application-groups", @app_group, filepath) end |
#putApplicationCodeInSourceCode ⇒ Object
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/mmine/notification_extension_integrator.rb', line 126 def putApplicationCodeInSourceCode source_code = File.read(@extension_code_destination_filepath) modified_source_code = source_code.gsub(/<# put your Application Code here #>/, "\"#{@application_code}\"") unless source_code == modified_source_code File.open(@extension_code_destination_filepath, "w") do |file| @logger.info("\tWriting application code to source code at #{@extension_code_destination_filepath}") file.puts modified_source_code end end end |
#putKeyArrayElement(key, value, filepath) ⇒ Object
check if it appends to existing array
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/mmine/notification_extension_integrator.rb', line 485 def putKeyArrayElement(key, value, filepath) # check if it appends to existing array doc = Nokogiri::XML(IO.read(filepath)) key_node = doc.search("//dict//key[text() = '#{key}']").first string_app_group_value = Nokogiri::XML::Node.new("string",doc) string_app_group_value.content = value if key_node == nil @logger.info("\tAdding 'key' node with content #{key}") key_node = Nokogiri::XML::Node.new("key",doc) key_node.content = key array_node = Nokogiri::XML::Node.new("array",doc) array_node.add_child(string_app_group_value) doc.xpath("//dict").first.add_child(key_node) key_node.add_next_sibling(array_node) else @logger.info("\t'Key' node with content #{key} already extists.") array_node = key_node.xpath("following-sibling::*").first if array_node.name == 'array' @logger.info("\tFollowing array sibling already exists") unless array_node.xpath("//string[text() = '#{value}']").first @logger.info("\tAdding child string element with content #{value}") array_node.add_child(string_app_group_value) else @logger.info("\tArray string element with content #{value} already exists") end else @logger.info("\tFollowing array sibling is missing. Adding array node containing a string element.") array_node = Nokogiri::XML::Node.new("array",doc) array_node.add_child(string_app_group_value) key_node.add_next_sibling(array_node) end end File.open(filepath,'w') do |file| @logger.info("\tWriting changes to entitlements: #{filepath}") file.puts Nokogiri::XML(doc.to_xml) { |x| x.noblanks } end end |
#putStringValueIntoXML(key, value, plist_path) ⇒ Object
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/mmine/notification_extension_integrator.rb', line 453 def putStringValueIntoXML(key, value, plist_path) plist_path = resolveAbsolutePath(plist_path) @logger.info("\tConfiguring plist on path: #{plist_path}") doc = Nokogiri::XML(IO.read(plist_path)) key_node = doc.search("//dict//key[text() = '#{key}']").first string_value_node = Nokogiri::XML::Node.new("string",doc) string_value_node.content = value if key_node == nil @logger.info("\tAdding 'key' node with content #{key}") key_node = Nokogiri::XML::Node.new("key",doc) key_node.content = key doc.xpath("//dict").first.add_child(key_node) @logger.info("\tAdding next string sibling with content #{string_value_node}") key_node.add_next_sibling(string_value_node) else @logger.info("\t'Key' node with content #{key} already extists.") existing_string_value_node = key_node.xpath("following-sibling::*").first if existing_string_value_node.name == 'string' @logger.info("\tUpdating following string sibling value with #{value}") existing_string_value_node.content = value else @logger.info("\tAdding next string sibling with content #{string_value_node}") key_node.add_next_sibling(string_value_node) end end File.open(plist_path,'w') do |file| @logger.info("\tWriting changes to plist: #{plist_path}") file.puts Nokogiri::XML(doc.to_xml) { |x| x.noblanks } end end |
#removeEmbedFrameworkPhase ⇒ Object
367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/mmine/notification_extension_integrator.rb', line 367 def removeEmbedFrameworkPhase @logger.info("Setting up embed framework script") emb_fs = @main_target.copy_files_build_phases .select { |phase| phase.dst_subfolder_spec == '10' }.each { |phase| phase.files.select { |file| file.display_name == @framework_file_name }.each { |file| @logger.info("\tRemoving embeddin #{@framework_file_name} from phase #{phase.display_name}") phase.remove_build_file(file) } } end |
#resolveAbsolutePath(path) ⇒ Object
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/mmine/notification_extension_integrator.rb', line 416 def resolveAbsolutePath(path) ret = path ["$(PROJECT_DIR)", "$PROJECT_DIR"].each do |proj_dir| ret = ret.sub(proj_dir, @project_dir) end if ret.include?("$") puts "Could not resolve absolute path for #{path}. The only supported variable are $(PROJECT_DIR) and $PROJECT_DIR. Make sure you don't misuse Xcode paths variables, consider using $(PROJECT_DIR) instead or contact Infobip Mobile Messaging support via email [email protected]" exit end if ret == path && !ret.include?("$") # no aliases found/replaced, no aliases left in path if path.start_with? "/" return path # it's already an absolute path else return File.join(@project_dir, path) # it's a relative project path end end return ret end |
#resolveXcodePath(path) ⇒ Object
382 383 384 |
# File 'lib/mmine/notification_extension_integrator.rb', line 382 def resolveXcodePath(path) return path.sub(@project_dir, '$(PROJECT_DIR)') end |
#setNotificationExtensionBuildSettings(key, debug_value, release_value = nil) ⇒ Object
386 387 388 389 390 391 |
# File 'lib/mmine/notification_extension_integrator.rb', line 386 def setNotificationExtensionBuildSettings(key, debug_value, release_value=nil) release_value = release_value != nil ? release_value : debug_value @logger.info("\tSetting extension build settings:\n\t\tdebug: \t#{key}\t#{debug_value}\n\t\trelease:\t#{key}\t#{release_value}") @extension_build_settings_debug[key] = debug_value @extension_build_settings_release[key] = release_value end |
#setupAppGroupPlistValue ⇒ Object
191 192 193 194 |
# File 'lib/mmine/notification_extension_integrator.rb', line 191 def setupAppGroupPlistValue putStringValueIntoXML("com.mobilemessaging.app_group", @app_group, @main_target_debug_plist) putStringValueIntoXML("com.mobilemessaging.app_group", @app_group, @main_target_release_plist) end |
#setupBackgroundModesPlistValue ⇒ Object
196 197 198 199 |
# File 'lib/mmine/notification_extension_integrator.rb', line 196 def setupBackgroundModesPlistValue putKeyArrayElement("UIBackgroundModes", "remote-notification", @main_target_debug_plist) putKeyArrayElement("UIBackgroundModes", "remote-notification", @main_target_release_plist) end |
#setupBuildNumber ⇒ Object
234 235 236 237 238 239 240 241 |
# File 'lib/mmine/notification_extension_integrator.rb', line 234 def setupBuildNumber version_key = "CFBundleShortVersionString" build_key = "CFBundleVersion" main_version = getXMLStringValue(version_key, @main_target_release_plist) main_build = getXMLStringValue(build_key, @main_target_release_plist) putStringValueIntoXML(version_key, main_version, @extension_info_plist_path) putStringValueIntoXML(build_key, main_build, @extension_info_plist_path) end |
#setupCopyFrameworkScript ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/mmine/notification_extension_integrator.rb', line 258 def setupCopyFrameworkScript phase_name = "Copy Frameworks" shell_script = "/usr/local/bin/carthage copy-frameworks" input_path = "$SRCROOT/$PROJECT/Plugins/com-infobip-plugins-mobilemessaging/#{@framework_file_name}" output_path = "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/#{@framework_file_name}" existing_phase = @main_target.shell_script_build_phases.select { |phase| phase.shell_script.include? shell_script }.first unless existing_phase @logger.info("Setting up #{phase_name} shell script for main target") new_phase = @main_target.new_shell_script_build_phase(phase_name) new_phase.shell_path = "/bin/sh" new_phase.shell_script = shell_script new_phase.input_paths << input_path new_phase.output_paths << output_path else existing_phase.input_paths |= [input_path] existing_phase.output_paths |= [output_path] @logger.info("Main target already has #{phase_name} shell script set up") end removeEmbedFrameworkPhase() end |
#setupDeploymentTarget ⇒ Object
141 142 143 |
# File 'lib/mmine/notification_extension_integrator.rb', line 141 def setupDeploymentTarget setNotificationExtensionBuildSettings('IPHONEOS_DEPLOYMENT_TARGET', "10.0") end |
#setupDevelopmentTeam ⇒ Object
137 138 139 |
# File 'lib/mmine/notification_extension_integrator.rb', line 137 def setupDevelopmentTeam setNotificationExtensionBuildSettings('DEVELOPMENT_TEAM', @main_target_build_settings_debug['DEVELOPMENT_TEAM'], @main_target_build_settings_release['DEVELOPMENT_TEAM']) end |
#setupEmbedExtensionAction ⇒ Object
201 202 203 204 205 206 207 208 209 |
# File 'lib/mmine/notification_extension_integrator.rb', line 201 def setupEmbedExtensionAction phase_name = 'Embed App Extensions' unless @main_target.copy_files_build_phases.select { |phase| phase.name == phase_name }.first @logger.info("Adding copy files build phase: #{phase_name}") new_phase = @main_target.new_copy_files_build_phase(phase_name) new_phase.dst_subfolder_spec = '13' new_phase.add_file_reference(@ne_target.product_reference) end end |
#setupEntitlements(_build_settings_debug, _build_settings_release, target_name) ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/mmine/notification_extension_integrator.rb', line 281 def setupEntitlements(_build_settings_debug, _build_settings_release, target_name) entitlements_debug_filepath = _build_settings_debug['CODE_SIGN_ENTITLEMENTS'] != nil ? resolveAbsolutePath(_build_settings_debug['CODE_SIGN_ENTITLEMENTS']) : nil entitlements_release_filepath = _build_settings_release['CODE_SIGN_ENTITLEMENTS'] != nil ? resolveAbsolutePath(_build_settings_release['CODE_SIGN_ENTITLEMENTS']) : nil key = 'CODE_SIGN_ENTITLEMENTS' if entitlements_debug_filepath == nil and entitlements_release_filepath == nil @logger.info("\tEntitlements are not set for both release and debug schemes, setting up...") entitlements_destination_filepath = createAppGroupEntitlements("#{target_name}.entitlements") entitlements_destination_filepath = resolveXcodePath(entitlements_destination_filepath) @logger.info("\tSetting build settings:\n\t\tdebug: \t#{key}\t#{entitlements_destination_filepath}\n\t\trelease:\t#{key}\t#{entitlements_destination_filepath}") _build_settings_debug[key] = entitlements_destination_filepath _build_settings_release[key] = entitlements_destination_filepath else if entitlements_debug_filepath == entitlements_release_filepath @logger.info("\tEntitlements settings are equal for debug and release schemes.") putAppGroupEntitlement(entitlements_debug_filepath) else if entitlements_debug_filepath != nil @logger.info("\tEntitlements debug settings already set, updating settings...") putAppGroupEntitlement(entitlements_debug_filepath) else @logger.info("\tEntitlements debug settings are not set, setting up...") entitlements_destination_filepath = createAppGroupEntitlements("#{target_name}_debug.entitlements") entitlements_destination_filepath = resolveXcodePath(entitlements_destination_filepath) @logger.info("\tSetting build settings:\n\tdebug:\t#{key}\t#{entitlements_destination_filepath}") _build_settings_debug[key] = entitlements_destination_filepath end if entitlements_release_filepath != nil @logger.info("\tEntitlements release settings already set, updating settings...") putAppGroupEntitlement(entitlements_release_filepath) else @logger.info("\tEntitlements release settings are not set, setting up...") entitlements_destination_filepath = createAppGroupEntitlements("#{target_name}_release.entitlements") entitlements_destination_filepath = resolveXcodePath(entitlements_destination_filepath) @logger.info("\tSetting build settings:\n\trelease:\t#{key}\t#{entitlements_destination_filepath}") _build_settings_release[key] = entitlements_destination_filepath end end end end |
#setupExtensionTargetCapabilities ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/mmine/notification_extension_integrator.rb', line 326 def setupExtensionTargetCapabilities unless @project.root_object.attributes["TargetAttributes"] @project.root_object.attributes["TargetAttributes"] = Hash.new end exitsting_capabilities = @project.root_object.attributes["TargetAttributes"][@ne_target.uuid] mobilemessaging_capabilities = { "SystemCapabilities" => { "com.apple.ApplicationGroups.iOS" => { "enabled" => 1 } } } if exitsting_capabilities == nil @logger.info("\tSetting TargetAttributes #{mobilemessaging_capabilities} for extension") @project.root_object.attributes["TargetAttributes"][@ne_target.uuid] = mobilemessaging_capabilities else @logger.info("\tMerging TargetAttributes #{mobilemessaging_capabilities} for extension") @project.root_object.attributes["TargetAttributes"][@ne_target.uuid] = exitsting_capabilities.merge(mobilemessaging_capabilities) end end |
#setupFrameworkSearchPaths ⇒ Object
218 219 220 |
# File 'lib/mmine/notification_extension_integrator.rb', line 218 def setupFrameworkSearchPaths setNotificationExtensionBuildSettings('FRAMEWORK_SEARCH_PATHS', '$SRCROOT/$PROJECT/Plugins/com-infobip-plugins-mobilemessaging') end |
#setupLibCordovaLink ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/mmine/notification_extension_integrator.rb', line 243 def setupLibCordovaLink lib_cordova_name = 'libCordova.a' unless @ne_target.frameworks_build_phase.files_references.select { |ref| ref.path == lib_cordova_name }.first @logger.info("Adding libCordova.a to Notification Extension target...") ref = @main_target.frameworks_build_phase.files_references.select { |ref| ref.path == lib_cordova_name }.first if ref @ne_target.frameworks_build_phase.add_file_reference(ref) else @logger.error("Main target has no libCordova.a as a linked library. Unable to add libCordova.a to Notification Extension target!") end else @logger.info("Notification Extension target already has libCordova.a linked.") end end |
#setupMainTargetCapabilities ⇒ Object
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/mmine/notification_extension_integrator.rb', line 345 def setupMainTargetCapabilities unless @project.root_object.attributes["TargetAttributes"] @project.root_object.attributes["TargetAttributes"] = Hash.new end exitsting_capabilities = @project.root_object.attributes["TargetAttributes"][@main_target.uuid] mobilemessaging_capabilities = { "SystemCapabilities" => { "com.apple.ApplicationGroups.iOS" => { "enabled" => 1 }, "com.apple.Push" => { "enabled" => 1 }, "com.apple.BackgroundModes" => { "enabled" => 1 } } } if exitsting_capabilities == nil @logger.info("\tSetting TargetAttributes #{mobilemessaging_capabilities} for main target") @project.root_object.attributes["TargetAttributes"][@main_target.uuid] = mobilemessaging_capabilities else @logger.info("\tMerging TargetAttributes #{mobilemessaging_capabilities} for main target") @project.root_object.attributes["TargetAttributes"][@main_target.uuid] = exitsting_capabilities.merge(mobilemessaging_capabilities) end end |
#setupMainTargetDependency ⇒ Object
211 212 213 214 215 216 |
# File 'lib/mmine/notification_extension_integrator.rb', line 211 def setupMainTargetDependency unless @main_target.dependency_for_target(@ne_target) @logger.info("Adding extension target dependency for main target") @main_target.add_dependency(@ne_target) end end |
#setupMainTargetEntitlements ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/mmine/notification_extension_integrator.rb', line 172 def setupMainTargetEntitlements @logger.info("Setting up main target entitlements...") setupEntitlements(@main_target_build_settings_debug, @main_target_build_settings_release, @main_target_name) entitlements_path_debug = @main_target_build_settings_debug['CODE_SIGN_ENTITLEMENTS'] entitlements_path_release = @main_target_build_settings_release['CODE_SIGN_ENTITLEMENTS'] if entitlements_path_debug = entitlements_path_release putStringValueIntoXML("aps-environment", "development", entitlements_path_debug) else putStringValueIntoXML("aps-environment", "development", entitlements_path_debug) putStringValueIntoXML("aps-environment", "production", entitlements_path_release) end end |
#setupNotificationExtension ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/mmine/notification_extension_integrator.rb', line 53 def setupNotificationExtension puts "🏎 Integration starting... ver. #{Mmine::VERSION}" createNotificationExtensionTarget() createNotificationExtensionDir() addNotificationExtensionSourceCode() setupDevelopmentTeam() setupDeploymentTarget() setupNotificationExtensionInfoPlist() setupNotificationExtensionBundleId() setupNotificationExtensionEntitlements() setupMainTargetEntitlements() setupAppGroupPlistValue() setupBackgroundModesPlistValue() setupExtensionTargetCapabilities() setupMainTargetCapabilities() setupEmbedExtensionAction() setupMainTargetDependency() setupSwiftVersion() setupProductName() setupBuildNumber() if @cordova setupFrameworkSearchPaths() setupRunpathSearchPaths() setupLibCordovaLink() setupCopyFrameworkScript() end @project.save() puts "🏁 Integration has been finished successfully!" end |
#setupNotificationExtensionBundleId ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/mmine/notification_extension_integrator.rb', line 156 def setupNotificationExtensionBundleId suffix = "notification-extension" debug_id = @main_target_build_settings_debug['PRODUCT_BUNDLE_IDENTIFIER'] release_id = @main_target_build_settings_release['PRODUCT_BUNDLE_IDENTIFIER'] if debug_id and release_id @logger.info("Composing extension bundle id from main target build settings: debug #{debug_id}, release #{release_id}") setNotificationExtensionBuildSettings('PRODUCT_BUNDLE_IDENTIFIER', "#{debug_id}.#{suffix}", "#{release_id}.#{suffix}") else key = "CFBundleIdentifier" main_bundle_id = getXMLStringValue(key, @main_target_release_plist) extension_bundle_id = "#{main_bundle_id}.#{suffix}" @logger.info("Composing extension bundle id from main target info plist: #{main_bundle_id}.") setNotificationExtensionBuildSettings('PRODUCT_BUNDLE_IDENTIFIER', extension_bundle_id) end end |
#setupNotificationExtensionEntitlements ⇒ Object
186 187 188 189 |
# File 'lib/mmine/notification_extension_integrator.rb', line 186 def setupNotificationExtensionEntitlements @logger.info("Setting up extension entitlements...") setupEntitlements(@extension_build_settings_debug, @extension_build_settings_release, @ne_target_name) end |
#setupNotificationExtensionInfoPlist ⇒ Object
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/mmine/notification_extension_integrator.rb', line 145 def setupNotificationExtensionInfoPlist unless File.exist?(@extension_info_plist_path) @logger.info("Copying extension plist file to path: #{@extension_info_plist_path}") FileUtils.cp(@plist_source_filepath, @extension_info_plist_path) getNotificationExtensionGroupReference().new_reference(@extension_info_plist_path) #check if additional plist manipulations needed (target membership?) else @logger.info("Notification extension info plist already exists on path: #{@extension_info_plist_path}") end setNotificationExtensionBuildSettings('INFOPLIST_FILE', resolveXcodePath(@extension_info_plist_path)) end |
#setupProductName ⇒ Object
230 231 232 |
# File 'lib/mmine/notification_extension_integrator.rb', line 230 def setupProductName setNotificationExtensionBuildSettings('PRODUCT_NAME', @ne_target_name) end |
#setupRunpathSearchPaths ⇒ Object
222 223 224 |
# File 'lib/mmine/notification_extension_integrator.rb', line 222 def setupRunpathSearchPaths setNotificationExtensionBuildSettings('LD_RUNPATH_SEARCH_PATHS', '@executable_path/../../Frameworks') end |
#setupSwiftVersion ⇒ Object
226 227 228 |
# File 'lib/mmine/notification_extension_integrator.rb', line 226 def setupSwiftVersion setNotificationExtensionBuildSettings('SWIFT_VERSION', @swift_version) end |