lib/cocoapods_acknowledgements.rb in cocoapods-acknowledgements-1.1.3 vs lib/cocoapods_acknowledgements.rb in cocoapods-acknowledgements-1.2.0

- old
+ new

@@ -27,11 +27,10 @@ unless target.resources_build_phase.files_references.include?(file_ref) target.add_resources([file_ref]) end project.save - end def self.settings_bundle_in_project(project) file = project.files.find { |f| f.path =~ /Settings\.bundle$/ } file.real_path.to_path unless file.nil? @@ -49,55 +48,58 @@ normalized_hash end Pod::UI.section 'Adding Acknowledgements' do - should_include_settings = user_options["settings_bundle"] != nil + should_include_settings = user_options["settings_bundle"] excluded_pods = Set.new(user_options["exclude"]) + targets = Set.new(user_options["targets"]) sandbox = context.sandbox if defined? context.sandbox sandbox ||= Pod::Sandbox.new(context.sandbox_root) context.umbrella_targets.each do |umbrella_target| project = Xcodeproj::Project.open(umbrella_target.user_project_path) - umbrella_target.user_target_uuids.each do |user_target_uuid| + # Generate a plist representing all of the podspecs + metadata = PlistGenerator.generate(umbrella_target, sandbox, excluded_pods) + next unless metadata - # Generate a plist representing all of the podspecs - metadata = PlistGenerator.generate(umbrella_target, sandbox, excluded_pods) - - next unless metadata - - plist_path = sandbox.root + "#{umbrella_target.cocoapods_target_label}-metadata.plist" - save_metadata(metadata, plist_path, project, sandbox, user_target_uuid) - - if should_include_settings + if should_include_settings + # We need to look for a Settings.bundle + # and add this to the root of the bundle + settings_bundle = settings_bundle_in_project(project) + if settings_bundle == nil + Pod::UI.warn "Could not find a Settings.bundle to add the Pod Settings Plist to." + else # Generate a plist in Settings format settings_metadata = SettingsPlistGenerator.generate(umbrella_target, sandbox, excluded_pods) + settings_plist_path = settings_bundle + "/#{umbrella_target.cocoapods_target_label}-settings-metadata.plist" + end + end - # We need to look for a Settings.bundle - # and add this to the root of the bundle + plist_path = sandbox.root + "#{umbrella_target.cocoapods_target_label}-metadata.plist" - settings_bundle = settings_bundle_in_project(project) - if settings_bundle == nil - Pod::UI.warn "Could not find a Settings.bundle to add the Pod Settings Plist to." - else - settings_plist_path = settings_bundle + "/#{umbrella_target.cocoapods_target_label}-settings-metadata.plist" - save_metadata(settings_metadata, settings_plist_path, project, sandbox, user_target_uuid) - Pod::UI.info "Added Pod info to Settings.bundle for target #{umbrella_target.cocoapods_target_label}" + user_target_uuids = if targets.empty? + umbrella_target.user_target_uuids + else + umbrella_target.user_targets.select do |target| + targets.include?(target.name) + end.map(&:uuid) + end - # Support a callback for the key :settings_post_process - if user_options["settings_post_process"] - user_options["settings_post_process"].call(settings_plist_path, umbrella_target, excluded_pods) - end + user_target_uuids.each do |user_target_uuid| + save_metadata(metadata, plist_path, project, sandbox, user_target_uuid) + if settings_metadata && settings_plist_path + save_metadata(settings_metadata, settings_plist_path, project, sandbox, user_target_uuid) + Pod::UI.info "Added Pod info to Settings.bundle for target #{umbrella_target.cocoapods_target_label}" + # Support a callback for the key :settings_post_process + if user_options["settings_post_process"] + user_options["settings_post_process"].call(settings_plist_path, umbrella_target, excluded_pods) end end - end - end - end - end end