cocoapods-amimono 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a607ef5c8f40f9e3573b195af6e60a5e0467054
4
- data.tar.gz: 8da7473fed96d2e25e069b70c6228a1c6fc3ac05
3
+ metadata.gz: 55367906ce81e287ef9418f45edf5b4d88d5ce00
4
+ data.tar.gz: 1e56ba267843312e80b12c4d8a7b6d6c9f76faa3
5
5
  SHA512:
6
- metadata.gz: 93182f0c82f6a5cf9ab1f587f3ca5fceeaa90f58a3b76c78939bc95d685f5d0d0e92e89dc6c281ae37588a4a573e61f8767491ede509a7f3b269c43aad0bb65f
7
- data.tar.gz: 13feccb0c3b83750b6a05c63f6fa2858f1f8de236b9ededca0e305523a16e187ba7a0480e2b64ab1c9fd79ab1b8a5c000b9dc66777665956ea174f6738d7c953
6
+ metadata.gz: 58247c18d5c9274e759bc45582b60ba9d41a4b2b7f36e282079cc63d951dcda9a3fca4f1b26d40b7365ce0b3fae631eefa9938ea4683a751d1323ca73763e1e7
7
+ data.tar.gz: 72d9dd1ec10d12a11c7ba68fca3c953f67cbba5c06271f895b57ba0f01af8b3434656ebdbd4a246f4b530f0d99175a72acf019d8cc68e70193210a27fe51dbd8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-amimono (0.0.2)
4
+ cocoapods-amimono (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -51,7 +51,7 @@ Add the following to your `post_install` hook:
51
51
  ```ruby
52
52
  post_install do |installer|
53
53
  require 'cocoapods-amimono/patcher'
54
- Amimono::Patcher.patch_copy_resources_script(installer: installer)
54
+ Amimono::Patcher.patch!(installer: installer)
55
55
  ...
56
56
  ```
57
57
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsAmimono
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,25 +2,20 @@ module Amimono
2
2
  class Integrator
3
3
 
4
4
  FILELIST_SCRIPT = <<-SCRIPT.strip_heredoc
5
- #!/usr/bin/ruby
6
- intermediates_directory = ENV['OBJROOT']
7
- configuration = ENV['CONFIGURATION']
8
- platform = ENV['EFFECTIVE_PLATFORM_NAME']
9
- archs = ENV['ARCHS']
10
- target_name = ENV['TARGET_NAME']
11
-
12
- archs.split(" ").each do |architecture|
13
- Dir.chdir("\#{intermediates_directory}/Pods.build") do
14
- filelist = ""
15
- %s.each do |dependency|
16
- Dir.glob("\#{configuration}\#{platform}/\#{dependency}.build/Objects-normal/\#{architecture}/*.o") do |object_file|
17
- next if ["Pods-\#{target_name}-dummy", "Pods_\#{target_name}_vers"].any? { |dummy_object| object_file.include? dummy_object }
18
- filelist += File.absolute_path(object_file) + "\\n"
19
- end
20
- end
21
- File.write("\#{configuration}\#{platform}-\#{architecture}.objects.filelist", filelist)
22
- end
23
- end
5
+ IFS=" " read -r -a SPLIT <<< "$ARCHS"
6
+ for ARCH in "${SPLIT[@]}"; do
7
+ cd "$OBJROOT/Pods.build"
8
+ filelist=""
9
+ for dependency in "${DEPENDENCIES[@]}"; do
10
+ path="${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}/${dependency}.build/Objects-normal/${ARCH}/*.o"
11
+ for obj_file in $path; do
12
+ filelist+="${OBJROOT}/Pods.build/${obj_file}"
13
+ filelist+=$'\\n'
14
+ done
15
+ done
16
+ filelist=${filelist\%$'\\n'}
17
+ echo "$filelist" > "${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}-${ARCH}.objects.filelist"
18
+ done
24
19
  SCRIPT
25
20
 
26
21
  AMIMONO_FILELIST_BUILD_PHASE = '[Amimono] Create filelist per architecture'
@@ -43,36 +38,43 @@ module Amimono
43
38
  end
44
39
  end
45
40
 
46
- def update_build_phases(aggregated_target:)
47
- user_project = aggregated_target.user_project
48
- application_target = user_project.targets.find { |target| target.product_type.end_with? 'application' }
49
- # Remove the `Embed Pods Frameworks` build phase
50
- remove_embed_pods_frameworks(application_target: application_target)
51
- # Create or update [Amimono] build phase
52
- create_or_update_amimono_phase(application_target: application_target, phase_name: AMIMONO_FILELIST_BUILD_PHASE, script: generate_filelist_script(aggregated_target: aggregated_target))
41
+ def update_build_phases(aggregated_targets:)
42
+ # All user projects should be the same I hope
43
+ user_project = aggregated_targets.first.user_project
44
+ aggregated_targets.each do |aggregated_target|
45
+ # This pick is probably wrong, but works for most of the simple cases
46
+ user_target = aggregated_target.user_targets.first
47
+ # Remove the `Embed Pods Frameworks` build phase
48
+ remove_embed_pods_frameworks(user_target: user_target)
49
+ # Create or update [Amimono] build phase
50
+ create_or_update_amimono_phase(user_target: user_target, phase_name: AMIMONO_FILELIST_BUILD_PHASE, script: generate_filelist_script(aggregated_target: aggregated_target))
51
+ puts "[Amimono] Build phases updated for target #{aggregated_target.cocoapods_target_label}"
52
+ end
53
53
  user_project.save
54
54
  end
55
55
 
56
56
  private
57
57
 
58
- def remove_embed_pods_frameworks(application_target:)
59
- embed_pods_frameworks_build_phase = application_target.build_phases.find { |build_phase| build_phase.display_name.include? 'Embed Pods Frameworks' }
58
+ def remove_embed_pods_frameworks(user_target:)
59
+ embed_pods_frameworks_build_phase = user_target.build_phases.find { |build_phase| build_phase.display_name.include? 'Embed Pods Frameworks' }
60
60
  return if embed_pods_frameworks_build_phase.nil?
61
61
  embed_pods_frameworks_build_phase.remove_from_project
62
62
  end
63
63
 
64
- def create_or_update_amimono_phase(application_target:, phase_name:, script:)
65
- amimono_filelist_build_phase = application_target.build_phases.find { |build_phase| build_phase.display_name.include? phase_name } || application_target.new_shell_script_build_phase(phase_name)
66
- amimono_filelist_build_phase.shell_path = '/usr/bin/ruby'
64
+ def create_or_update_amimono_phase(user_target:, phase_name:, script:)
65
+ amimono_filelist_build_phase = user_target.build_phases.find { |build_phase| build_phase.display_name.include? phase_name } || user_target.new_shell_script_build_phase(phase_name)
66
+ amimono_filelist_build_phase.shell_path = '/bin/bash'
67
67
  amimono_filelist_build_phase.shell_script = script
68
- application_target.build_phases.insert(1, amimono_filelist_build_phase)
69
- application_target.build_phases.uniq!
68
+ user_target.build_phases.insert(1, amimono_filelist_build_phase)
69
+ user_target.build_phases.uniq!
70
70
  end
71
71
 
72
72
  def generate_filelist_script(aggregated_target:)
73
73
  dependencies = aggregated_target.specs.map(&:name).reject { |dependency| dependency.include? '/'}
74
74
  puts "[Amimono] #{dependencies.count} dependencies found"
75
- FILELIST_SCRIPT % dependencies.to_s
75
+ bash_array = dependencies.map { |dependency| "'#{dependency}'" }.join ' '
76
+ declare_statement = "declare -a DEPENDENCIES=(%s);\n" % bash_array
77
+ declare_statement + FILELIST_SCRIPT
76
78
  end
77
79
  end
78
80
  end
@@ -2,18 +2,52 @@ module Amimono
2
2
  # This class will patch your project's copy resources script to match the one that would be
3
3
  # generated as if the `use_frameworks!` flag wouldn't be there
4
4
  class Patcher
5
- def self.patch_copy_resources_script(installer:)!
6
- aggregated_target = installer.aggregate_targets.first
7
- project = installer.sandbox.project
8
- path = aggregated_target.copy_resources_script_path
9
- resources = resources_by_config(aggregated_target: aggregated_target, project: project)
10
- generator = Pod::Generator::CopyResourcesScript.new(resources, aggregated_target.platform)
11
- generator.save_as(path)
12
- puts "[Amimono] Copy resources script patched"
5
+
6
+ def self.patch!(installer:)
7
+ patch_copy_resources_script(installer: installer)
8
+ patch_vendored_build_settings(installer: installer)
13
9
  end
14
10
 
15
11
  private
16
12
 
13
+ def self.patch_vendored_build_settings(installer:)
14
+ aggregated_targets = installer.aggregate_targets.reject { |target| target.label.include? 'Test' }
15
+ aggregated_targets.each do |aggregated_target|
16
+ path = installer.sandbox.target_support_files_dir aggregated_target.label
17
+ Dir.entries(path).select { |entry| entry.end_with? 'xcconfig' }.each do |entry|
18
+ full_path = path + entry
19
+ xcconfig = Xcodeproj::Config.new full_path
20
+ # Another option would be to inspect installer.analysis_result.result.target_inspections
21
+ # But this also works and it's simpler
22
+ configuration = entry.split('.')[-2]
23
+ pod_targets = aggregated_target.pod_targets_for_build_configuration configuration
24
+ generate_vendored_build_settings(pod_targets: pod_targets, xcconfig: xcconfig)
25
+ xcconfig.save_as full_path
26
+ end
27
+ puts "[Amimono] Vendored build settings patched for target #{aggregated_target.label}"
28
+ end
29
+ end
30
+
31
+ def self.patch_copy_resources_script(installer:)
32
+ project = installer.sandbox.project
33
+ aggregated_targets = installer.aggregate_targets.reject { |target| target.label.include? 'Test' }
34
+ aggregated_targets.each do |aggregated_target|
35
+ path = aggregated_target.copy_resources_script_path
36
+ resources = resources_by_config(aggregated_target: aggregated_target, project: project)
37
+ generator = Pod::Generator::CopyResourcesScript.new(resources, aggregated_target.platform)
38
+ generator.save_as(path)
39
+ puts "[Amimono] Copy resources script patched for target #{aggregated_target.label}"
40
+ end
41
+ end
42
+
43
+ # Copied over from https://github.com/CocoaPods/CocoaPods/blob/e5afc825eeafa60933a1299f52eb764c267cc9b2/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb#L152-L158
44
+ # with some modifications to this particular use case
45
+ def self.generate_vendored_build_settings(pod_targets:, xcconfig:)
46
+ pod_targets.each do |pod_target|
47
+ Pod::Generator::XCConfig::XCConfigHelper.add_settings_for_file_accessors_of_target(pod_target, xcconfig)
48
+ end
49
+ end
50
+
17
51
  # Copied over from https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb#L115-L131
18
52
  # with some modifications to this particular use case
19
53
  def self.resources_by_config(aggregated_target:, project:)
@@ -2,20 +2,19 @@ require 'cocoapods-amimono/command'
2
2
  require 'cocoapods-amimono/integrator'
3
3
 
4
4
  Pod::HooksManager.register('cocoapods-amimono', :post_install) do |installer_context|
5
- # Find the aggregated target
6
- # This is probably wrong, all agregated targets are prefixed by 'Pods-'
7
- # but this works for now because find will return the first one
8
- # which is usually the app target
9
- pods_target = installer_context.umbrella_targets.find do |target|
10
- target.cocoapods_target_label.include? 'Pods'
5
+ # We exclude all targets that contain `Test`, which might not work for some test targets
6
+ # that doesn't include that word
7
+ pods_targets = installer_context.umbrella_targets.reject { |target| target.cocoapods_target_label.include? 'Test' }
8
+ target_info = Hash.new
9
+ pods_targets.each do |pods_target|
10
+ puts "[Amimono] Pods target found: #{pods_target.cocoapods_target_label}"
11
+ target_info[pods_target] = installer_context.sandbox.target_support_files_dir pods_target.cocoapods_target_label
11
12
  end
12
- puts "[Amimono] Pods target found: #{pods_target.cocoapods_target_label}"
13
-
14
- path = installer_context.sandbox.target_support_files_dir pods_target.cocoapods_target_label
15
13
 
16
14
  integrator = Amimono::Integrator.new
17
- integrator.update_xcconfigs(aggregated_target_sandbox_path: path)
18
- puts "[Amimono] xcconfigs updated with filelist"
19
- integrator.update_build_phases(aggregated_target: pods_target)
20
- puts "[Amimono] Build phases updated"
15
+ target_info.each do |pods_target, path|
16
+ integrator.update_xcconfigs(aggregated_target_sandbox_path: path)
17
+ puts "[Amimono] xcconfigs updated with filelist for target #{pods_target.cocoapods_target_label}"
18
+ end
19
+ integrator.update_build_phases(aggregated_targets: target_info.keys)
21
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-amimono
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renzo Crisostomo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-07 00:00:00.000000000 Z
11
+ date: 2016-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler