Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make project integration optional #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/cocoapods_acknowledgements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ module CocoaPodsAcknowledgements
require 'cocoapods_acknowledgements/plist_generator'
require 'cocoapods_acknowledgements/settings_plist_generator'

def self.save_metadata(metadata, plist_path, project, sandbox, user_target_uuid)
def self.write_metadata(metadata, plist_path)
if defined? Xcodeproj::Plist.write_to_path
Xcodeproj::Plist.write_to_path(metadata, plist_path)
else
Xcodeproj.write_plist(metadata, plist_path)
end
end

def self.add_to_target(metadata, plist_path, project, sandbox, user_target_uuid)
# Find a root folder in the users Xcode Project called Pods, or make one
cocoapods_group = project.main_group["Pods"]
unless cocoapods_group
Expand Down Expand Up @@ -58,7 +60,7 @@ def self.settings_bundle_in_project(project)
sandbox ||= Pod::Sandbox.new(context.sandbox_root)

context.umbrella_targets.each do |umbrella_target|
project = Xcodeproj::Project.open(umbrella_target.user_project_path)
project = Xcodeproj::Project.open(umbrella_target.user_project_path) if umbrella_target.user_project

# Generate a plist representing all of the podspecs
metadata = PlistGenerator.generate(umbrella_target, sandbox, excluded_pods)
Expand All @@ -67,7 +69,7 @@ def self.settings_bundle_in_project(project)
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)
settings_bundle = settings_bundle_in_project(project) unless project.nil?
if settings_bundle == nil
Pod::UI.warn "Could not find a Settings.bundle to add the Pod Settings Plist to."
else
Expand All @@ -79,6 +81,12 @@ def self.settings_bundle_in_project(project)

plist_path = sandbox.root + "#{umbrella_target.cocoapods_target_label}-metadata.plist"

write_metadata(metadata, plist_path)
write_metadata(settings_metadata, settings_plist_path) if settings_metadata && settings_plist_path

# Skip target integration when we don't have a project
next unless project

user_target_uuids = if targets.empty?
umbrella_target.user_target_uuids
else
Expand All @@ -88,10 +96,10 @@ def self.settings_bundle_in_project(project)
end

user_target_uuids.each do |user_target_uuid|
save_metadata(metadata, plist_path, project, sandbox, user_target_uuid)
add_to_target(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)
add_to_target(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"]
Expand Down