Updated Podfile postinstall script
Showing
... | @@ -47,6 +47,15 @@ def application_pods | ... | @@ -47,6 +47,15 @@ def application_pods |
end | end | ||
#-------Targets------- | #-------Targets------- | ||
#Analytics | |||
target 'OneWeatherAnalytics' do | |||
project 'OneWeatherAnalytics/OneWeatherAnalytics.project' | |||
shared_pods | |||
analytics_pods | |||
end | |||
#Application | |||
target '1Weather' do | target '1Weather' do | ||
shared_pods | shared_pods | ||
core_pods | core_pods | ||
... | @@ -92,81 +101,53 @@ target 'WDTWeatherSource' do | ... | @@ -92,81 +101,53 @@ target 'WDTWeatherSource' do |
shared_pods | shared_pods | ||
end | end | ||
#Analytics | |||
target 'OneWeatherAnalytics' do | |||
project 'OneWeatherAnalytics/OneWeatherAnalytics.project' | |||
shared_pods | |||
analytics_pods | |||
end | |||
target 'OneWeatherNotificationServiceExtension' do | target 'OneWeatherNotificationServiceExtension' do | ||
use_frameworks! | use_frameworks! | ||
pod 'MORichNotification' | pod 'MORichNotification' | ||
end | end | ||
post_install do |installer| | post_install do |installer| | ||
auto_process_target(['1Weather'], 'OneWeatherAnalytics', installer) | applicationTargets = [ | ||
end | 'Pods-OneWeatherAnalytics' | ||
] | |||
def auto_process_target(app_target_names, embedded_target_name, installer) | libraryTargets = [ | ||
words = find_words_at_embedded_target('Pods-' + embedded_target_name, | 'Pods-1Weather' | ||
installer) | ] | ||
handle_app_targets(app_target_names.map{ |str| 'Pods-' + str }, | |||
words, | embedded_targets = installer.aggregate_targets.select { |aggregate_target| | ||
installer) | libraryTargets.include? aggregate_target.name | ||
end | } | ||
embedded_pod_targets = embedded_targets.flat_map { |embedded_target| embedded_target.pod_targets } | |||
def find_line_with_start(str, start) | host_targets = installer.aggregate_targets.select { |aggregate_target| | ||
str.each_line do |line| | applicationTargets.include? aggregate_target.name | ||
if line.start_with?(start) | } | ||
return line | |||
end | # We only want to remove pods from Application targets, not libraries | ||
end | host_targets.each do |host_target| | ||
return nil | host_target.xcconfigs.each do |config_name, config_file| | ||
end | host_target.pod_targets.each do |pod_target| | ||
if embedded_pod_targets.include? pod_target | |||
def remove_words(str, words) | pod_target.specs.each do |spec| | ||
new_str = str | if spec.attributes_hash['ios'] != nil | ||
words.each do |word| | frameworkPaths = spec.attributes_hash['ios']['vendored_frameworks'] | ||
new_str = new_str.sub(word, '') | else | ||
end | frameworkPaths = spec.attributes_hash['vendored_frameworks'] | ||
return new_str | end | ||
end | if frameworkPaths != nil | ||
frameworkNames = Array(frameworkPaths).map(&:to_s).map do |filename| | |||
def find_words_at_embedded_target(target_name, installer) | extension = File.extname filename | ||
target = installer.pods_project.targets.find { |target| target.name == target_name } | File.basename filename, extension | ||
target.build_configurations.each do |config| | end | ||
xcconfig_path = config.base_configuration_reference.real_path | frameworkNames.each do |name| | ||
xcconfig = File.read(xcconfig_path) | puts "Removing #{name} from OTHER_LDFLAGS of target #{host_target.name}" | ||
old_line = find_line_with_start(xcconfig, "OTHER_LDFLAGS") | config_file.frameworks.delete(name) | ||
end | |||
if old_line == nil | end | ||
next | end | ||
end | end | ||
words = old_line.split(' ').select{ |str| str.start_with?("-l") }.map{ |str| ' ' + str } | |||
return words | |||
end | |||
end | |||
def handle_app_targets(names, words, installer) | |||
installer.pods_project.targets.each do |target| | |||
if names.index(target.name) == nil | |||
next | |||
end | |||
puts "Updating #{target.name} OTHER_LDFLAGS" | |||
target.build_configurations.each do |config| | |||
xcconfig_path = config.base_configuration_reference.real_path | |||
xcconfig = File.read(xcconfig_path) | |||
old_line = find_line_with_start(xcconfig, "OTHER_LDFLAGS") | |||
if old_line == nil | |||
next | |||
end | end | ||
new_line = remove_words(old_line, words) | xcconfig_path = host_target.xcconfig_path(config_name) | ||
config_file.save_as(xcconfig_path) | |||
new_xcconfig = xcconfig.sub(old_line, new_line) | |||
File.open(xcconfig_path, "w") { |file| file << new_xcconfig } | |||
end | end | ||
end | end | ||
end | end |
This source diff could not be displayed because it is too large.
You can
view the blob
instead.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to comment