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_target_subprojects ⇒ Object
- #pod_targets ⇒ Object
- #podfile ⇒ Object
- #pods_project ⇒ Object
- #projects_to_integrate ⇒ Object
- #run ⇒ Object
- #sandbox ⇒ Object
- #user_build_configurations ⇒ Object
Methods included from Config::SPMConfigMixin
#local_macro_pod?, #local_macro_pod_dir, #macro_pods, #spm_config
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
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 55 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
45 46 47 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 45 def config Config.instance end |
#perform_settings_update(update_targets: nil, update_pod_targets: nil, update_aggregate_targets: nil) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 66 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_target_subprojects ⇒ Object
33 34 35 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 33 def pod_target_subprojects @context.pod_target_subprojects 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
49 50 51 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 49 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 |
#projects_to_integrate ⇒ Object
37 38 39 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 37 def projects_to_integrate [pods_project] + pod_target_subprojects end |
#run ⇒ Object
53 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 53 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
41 42 43 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 41 def user_build_configurations @user_build_configurations ||= (pod_targets + aggregate_targets)[0].user_build_configurations end |