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/add_spm_pkgs.rb,
lib/cocoapods-spm/hooks/pre_integrate/update_settings.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AddSpmPkgs, 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
- #pods_project ⇒ Object
- #run ⇒ Object
- #sandbox ⇒ Object
- #user_build_configurations ⇒ Object
Methods included from Config::Mixin
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 = @spm_analyzer = [:spm_analyzer] @analysis_result = [:analysis_result] end |
Class Method Details
.run_hooks(phase, context, options) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 43 def self.run_hooks(phase, context, ) Dir["#{__dir__}/#{phase}/*.rb"].sort.each do |f| require f id = File.basename(f, ".*") cls_name = "Pod::SPM::Hook::#{id.camelize}" UI. "Running hook: #{cls_name}" cls_name.constantize.new(context, ).run 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
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 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 53 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) 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 |
#pods_project ⇒ Object
21 22 23 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 21 def pods_project @context.pods_project end |
#run ⇒ Object
41 |
# File 'lib/cocoapods-spm/hooks/base.rb', line 41 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 |