Class: Pod::SPM::Hook
- Inherits:
-
Object
- Object
- Pod::SPM::Hook
- Includes:
- Config::Mixin
- Defined in:
- lib/cocoapods-spm/hooks/base.rb,
lib/cocoapods-spm/hooks/post_integrate/1.add_spm_pkgs.rb,
lib/cocoapods-spm/hooks/post_integrate/5.update_settings.rb,
lib/cocoapods-spm/hooks/post_integrate/7.update_copy_resources_script.rb,
lib/cocoapods-spm/hooks/post_integrate/6.update_embed_frameworks_script.rb
Direct Known Subclasses
AddSpmPkgs, UpdateCopyResourcesScript, UpdateEmbedFrameworksScript, UpdateSettings
Defined Under Namespace
Classes: AddSpmPkgs, UpdateCopyResourcesScript, UpdateEmbedFrameworksScript, UpdateSettings
Class Method Summary collapse
Instance Method Summary collapse
- #aggregate_targets ⇒ Object
- #config ⇒ Object
-
#initialize(context, options = {}) ⇒ Hook
constructor
A new instance of Hook.
- #perform_settings_update(update_targets: nil, update_pod_targets: nil, update_aggregate_targets: nil) ⇒ Object
- #pod_targets ⇒ Object
- #podfile ⇒ Object
- #pods_project ⇒ Object
- #run ⇒ Object
- #sandbox ⇒ Object
- #user_build_configurations ⇒ Object
Methods included from Config::SPMConfigMixin
Methods included from Config::PodConfigMixin
Methods included from Config::ProjectConfigMixin
Constructor Details
#initialize(context, options = {}) ⇒ Hook
Returns a new instance of Hook.
10 11 12 13 14 15 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 10 def initialize(context, = {}) @context = context @options = @spm_resolver = [:spm_resolver] @analysis_result = [:analysis_result] end |
Class Method Details
.run_hooks(phase, context, options) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 47 def self.run_hooks(phase, context, ) Dir["#{__dir__}/#{phase}/*.rb"].sort.each do |f| require f id = File.basename(f, ".*").split(".").last cls_name = "Pod::SPM::Hook::#{id.camelize}" UI. "- Running hook: #{cls_name}" do cls_name.constantize.new(context, ).run end end end |
Instance Method Details
#aggregate_targets ⇒ Object
29 30 31 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 29 def aggregate_targets @analysis_result.targets end |
#config ⇒ Object
37 38 39 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 37 def config Config.instance end |
#perform_settings_update(update_targets: nil, update_pod_targets: nil, update_aggregate_targets: nil) ⇒ Object
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 84 85 86 87 88 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 58 def perform_settings_update( update_targets: nil, update_pod_targets: nil, update_aggregate_targets: nil ) proc = lambda do |update, target, setting, config| return if update.nil? hash = update.call(target, setting, config) setting.xcconfig.merge!(hash) setting.generate.merge!(hash) Installer::Xcode::PodsProjectGenerator::TargetInstallerHelper.update_changed_file( setting, target.xcconfig_path(config) ) end pod_targets.each do |target| target.build_settings.each do |config, setting| proc.call(update_targets, target, setting, config) proc.call(update_pod_targets, target, setting, config) end end aggregate_targets.each do |target| target.user_build_configurations.each_key do |config| setting = target.build_settings(config) proc.call(update_targets, target, setting, config) proc.call(update_aggregate_targets, target, setting, config) end end end |
#pod_targets ⇒ Object
25 26 27 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 25 def pod_targets @analysis_result.pod_targets end |
#podfile ⇒ Object
41 42 43 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 41 def podfile pod_config.podfile end |
#pods_project ⇒ Object
21 22 23 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 21 def pods_project @context.pods_project end |
#run ⇒ Object
45 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 45 def run; end |
#sandbox ⇒ Object
17 18 19 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 17 def sandbox @context.sandbox end |
#user_build_configurations ⇒ Object
33 34 35 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 33 def user_build_configurations @user_build_configurations ||= (pod_targets + aggregate_targets)[0].user_build_configurations end |