cocoapods 0.37.2 → 0.38.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +136 -1
  3. data/lib/cocoapods.rb +0 -5
  4. data/lib/cocoapods/command.rb +3 -0
  5. data/lib/cocoapods/command/cache.rb +28 -0
  6. data/lib/cocoapods/command/cache/clean.rb +90 -0
  7. data/lib/cocoapods/command/cache/list.rb +69 -0
  8. data/lib/cocoapods/command/lib.rb +11 -4
  9. data/lib/cocoapods/command/list.rb +4 -4
  10. data/lib/cocoapods/command/outdated.rb +1 -10
  11. data/lib/cocoapods/command/project.rb +3 -2
  12. data/lib/cocoapods/command/spec.rb +0 -17
  13. data/lib/cocoapods/command/spec/cat.rb +1 -1
  14. data/lib/cocoapods/command/spec/create.rb +1 -0
  15. data/lib/cocoapods/command/spec/edit.rb +1 -1
  16. data/lib/cocoapods/command/spec/lint.rb +10 -4
  17. data/lib/cocoapods/config.rb +6 -0
  18. data/lib/cocoapods/downloader/cache.rb +48 -1
  19. data/lib/cocoapods/executable.rb +27 -6
  20. data/lib/cocoapods/gem_version.rb +1 -1
  21. data/lib/cocoapods/generator/copy_resources_script.rb +1 -0
  22. data/lib/cocoapods/generator/embed_frameworks_script.rb +23 -28
  23. data/lib/cocoapods/generator/header.rb +5 -1
  24. data/lib/cocoapods/generator/umbrella_header.rb +1 -1
  25. data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +139 -33
  26. data/lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb +2 -2
  27. data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +3 -3
  28. data/lib/cocoapods/installer.rb +64 -109
  29. data/lib/cocoapods/installer/analyzer.rb +167 -336
  30. data/lib/cocoapods/installer/analyzer/analysis_result.rb +46 -0
  31. data/lib/cocoapods/installer/analyzer/specs_state.rb +76 -0
  32. data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +41 -0
  33. data/lib/cocoapods/installer/analyzer/target_inspector.rb +203 -0
  34. data/lib/cocoapods/installer/file_references_installer.rb +48 -13
  35. data/lib/cocoapods/installer/podfile_validator.rb +86 -0
  36. data/lib/cocoapods/installer/{hooks_context.rb → post_install_hooks_context.rb} +3 -3
  37. data/lib/cocoapods/installer/pre_install_hooks_context.rb +41 -0
  38. data/lib/cocoapods/installer/target_installer.rb +1 -7
  39. data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +15 -17
  40. data/lib/cocoapods/installer/target_installer/pod_target_installer.rb +4 -4
  41. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +16 -16
  42. data/lib/cocoapods/sandbox/file_accessor.rb +20 -2
  43. data/lib/cocoapods/sandbox/path_list.rb +15 -13
  44. data/lib/cocoapods/sandbox/podspec_finder.rb +1 -0
  45. data/lib/cocoapods/sources_manager.rb +2 -0
  46. data/lib/cocoapods/target.rb +7 -37
  47. data/lib/cocoapods/target/aggregate_target.rb +25 -1
  48. data/lib/cocoapods/target/pod_target.rb +106 -10
  49. data/lib/cocoapods/user_interface.rb +26 -0
  50. data/lib/cocoapods/user_interface/error_report.rb +6 -0
  51. data/lib/cocoapods/validator.rb +22 -0
  52. metadata +21 -16
  53. data/lib/cocoapods/generator/target_environment_header.rb +0 -171
  54. data/lib/cocoapods/hooks/installer_representation.rb +0 -133
  55. data/lib/cocoapods/hooks/library_representation.rb +0 -93
  56. data/lib/cocoapods/hooks/pod_representation.rb +0 -70
@@ -1,171 +0,0 @@
1
- require 'active_support/core_ext/string/strip'
2
-
3
- module Pod
4
- module Generator
5
- # Generates a header which allows to inspect at compile time the installed
6
- # pods and the installed specifications of a pod.
7
- #
8
- # Example output:
9
- #
10
- # #define COCOAPODS_POD_AVAILABLE_ObjectiveSugar 1
11
- # #define COCOAPODS_VERSION_MAJOR_ObjectiveSugar 0
12
- # #define COCOAPODS_VERSION_MINOR_ObjectiveSugar 6
13
- # #define COCOAPODS_VERSION_PATCH_ObjectiveSugar 2
14
- #
15
- # Example usage:
16
- #
17
- # #ifdef COCOAPODS
18
- # #ifdef COCOAPODS_POD_AVAILABLE_ObjectiveSugar
19
- # #import "ObjectiveSugar.h"
20
- # #endif
21
- # #else
22
- # // Non CocoaPods code
23
- # #endif
24
- #
25
- class TargetEnvironmentHeader
26
- # @return [Hash{String => LocalPod}] the specifications installed for
27
- # the target by build configuration name.
28
- #
29
- attr_reader :specs_by_configuration
30
-
31
- # @param [Array<Specification>] pods @see pods
32
- #
33
- def initialize(specs_by_configuration)
34
- @specs_by_configuration = specs_by_configuration
35
- end
36
-
37
- # Generates the file contents.
38
- #
39
- # @return [void]
40
- #
41
- def generate
42
- result = "\n#{notice}\n\n"
43
- common_specs = common_specs(specs_by_configuration)
44
- common_specs.each { |spec| result << spec_defines(spec) }
45
-
46
- c99ext_identifier_method = Target.new.method(:c99ext_identifier)
47
-
48
- specs_by_config = specs_scoped_by_configuration(common_specs, specs_by_configuration)
49
- specs_by_config.each do |config, specs|
50
- result << "// #{config} build configuration\n"
51
- result << "#ifdef #{c99ext_identifier_method[config].upcase}\n\n"
52
- specs.each { |spec| result << spec_defines(spec, 1) }
53
- result << "#endif\n"
54
- end
55
- result
56
- end
57
-
58
- def save_as(path)
59
- path.open('w') { |header| header.write(generate) }
60
- end
61
-
62
- private
63
-
64
- # !@group Private Helpers
65
- #-----------------------------------------------------------------------#
66
-
67
- # @return [Array<Specification>] The list of the specifications present
68
- # in all build configurations sorted by name.
69
- #
70
- # @param [Hash{String => Array<Specification>}] specs_by_configuration
71
- # The specs grouped by build configuration.
72
- #
73
- def common_specs(specs_by_configuration)
74
- result = specs_by_configuration.values.flatten.uniq
75
- specs_by_configuration.values.each do |configuration_specs|
76
- result &= configuration_specs
77
- end
78
- result.sort_by(&:name)
79
- end
80
-
81
- # @return [Hash{String => Array<Specification>}] The list of the
82
- # specifications not present in all build configurations sorted
83
- # by name and grouped by build configuration name.
84
- #
85
- # @param [Hash{String => Array<Specification>}] specs_by_configuration
86
- # The specs grouped by build configuration.
87
- #
88
- def specs_scoped_by_configuration(common_specs, specs_by_configuration)
89
- result = {}
90
- specs_by_configuration.each do |configuration, all_specs|
91
- specs = all_specs.sort_by(&:name) - common_specs
92
- result[configuration] = specs unless specs.empty?
93
- end
94
- result
95
- end
96
-
97
- # @return The sanitized name of a specification to make it suitable to be
98
- # used as part of an identifier of a define statement.
99
- #
100
- # @param [String] spec_name
101
- # The name of the spec.
102
- #
103
- def safe_spec_name(spec_name)
104
- spec_name.gsub(/[^\w]/, '_')
105
- end
106
-
107
- # @return [String]
108
- #
109
- def notice
110
- <<-DOC.strip_heredoc
111
- // To check if a library is compiled with CocoaPods you
112
- // can use the `COCOAPODS` macro definition which is
113
- // defined in the xcconfigs so it is available in
114
- // headers also when they are imported in the client
115
- // project.
116
- DOC
117
- end
118
-
119
- # @return [String]
120
- #
121
- def spec_defines(spec, indent_count = 0)
122
- spec_name = safe_spec_name(spec.name)
123
- result = "// #{spec.name}\n"
124
- result << "#define COCOAPODS_POD_AVAILABLE_#{spec_name}\n"
125
- if spec.version.semantic?
126
- result << semantic_version_defines(spec)
127
- else
128
- result << non_semantic_version_notice(spec)
129
- end
130
- result << "\n"
131
- indent(result, indent_count)
132
- end
133
-
134
- def indent(string, indent_count)
135
- indent = ' ' * (indent_count * 2)
136
- lines = string.lines.map do |line|
137
- if line == "\n"
138
- line
139
- else
140
- "#{indent}#{line}"
141
- end
142
- end
143
- lines.join
144
- end
145
-
146
- # @return [String]
147
- #
148
- def semantic_version_defines(spec)
149
- spec_name = safe_spec_name(spec.name)
150
- <<-DOC.strip_heredoc
151
- #define COCOAPODS_VERSION_MAJOR_#{spec_name} #{spec.version.major}
152
- #define COCOAPODS_VERSION_MINOR_#{spec_name} #{spec.version.minor}
153
- #define COCOAPODS_VERSION_PATCH_#{spec_name} #{spec.version.patch}
154
- DOC
155
- end
156
-
157
- # @return [String]
158
- #
159
- def non_semantic_version_notice(spec)
160
- <<-DOC.strip_heredoc
161
- // This library does not follow semantic-versioning,
162
- // so we were not able to define version macros.
163
- // Please contact the author.
164
- // Version: #{spec.version}.
165
- DOC
166
- end
167
-
168
- #-----------------------------------------------------------------------#
169
- end
170
- end
171
- end
@@ -1,133 +0,0 @@
1
- module Pod
2
- # @todo: Remove by CocoaPods 1.0
3
- #
4
- class Podfile
5
- def config
6
- UI.warn 'Podfile#config is deprecated. The config is accessible from ' \
7
- 'the parameter passed to the hooks'
8
- Config.instance
9
- end
10
-
11
- class TargetDefinition
12
- def copy_resources_script_name
13
- UI.warn 'TargetDefinition#copy_resources_script_name is deprecated. ' \
14
- 'The value is accessible directly from the representation of the ' \
15
- 'library using the #copy_resources_script_path method.'
16
- Config.instance.sandbox.root + "#{label}-resources.sh"
17
- end
18
- end
19
- end
20
-
21
- module Hooks
22
- # The installer representation to pass to the hooks.
23
- #
24
- class InstallerRepresentation
25
- public
26
-
27
- # @!group Public Hooks API
28
-
29
- # @return [Pathname] The root of the sandbox.
30
- #
31
- def sandbox_root
32
- installer.sandbox.root
33
- end
34
-
35
- # @return [Pod::Project] the `Pods/Pods.xcodeproj` project.
36
- #
37
- # @note This value is not yet set in the pre install callbacks.
38
- #
39
- def project
40
- installer.pods_project
41
- end
42
-
43
- # @return [Array<PodRepresentation>] The representation of the Pods.
44
- #
45
- def pods
46
- installer.pod_reps
47
- end
48
-
49
- # @return [Array<LibraryRepresentation>] The representation of the
50
- # libraries.
51
- #
52
- def libraries
53
- installer.library_reps
54
- end
55
-
56
- # @return [Hash{LibraryRepresentation => Array<Specification>}] The
57
- # specifications grouped by target definition.
58
- #
59
- def specs_by_lib
60
- result = {}
61
- installer.aggregate_targets.each do |aggregate_target|
62
- result[installer.library_rep(aggregate_target)] = aggregate_target.specs
63
- end
64
- result
65
- end
66
-
67
- # @return [Hash{LibraryRepresentation => Array<PodRepresentation>}] The
68
- # local pod instances grouped by target.
69
- #
70
- def pods_by_lib
71
- result = {}
72
- installer.aggregate_targets.map(&:pod_targets).flatten.each do |lib|
73
- pod_names = [lib.root_spec.name]
74
- pod_reps = pods.select { |rep| pod_names.include?(rep.name) }
75
- result[lib.target_definition] = pod_reps
76
- end
77
- result
78
- end
79
-
80
- #-----------------------------------------------------------------------#
81
-
82
- public
83
-
84
- # @!group Compatibility
85
- #
86
- # The following aliases provides compatibility with CP < 0.17
87
-
88
- alias_method :target_installers, :libraries
89
- alias_method :specs_by_target, :specs_by_lib
90
- alias_method :local_pods_by_target, :pods_by_lib
91
-
92
- #-----------------------------------------------------------------------#
93
-
94
- public
95
-
96
- # @!group Unsafe Hooks API
97
- #
98
- # The interface of the following objects might change at any time.
99
- # If there some information which is needed, please open an issue.
100
-
101
- # @return [Sandbox] sandbox the sandbox where the support files should
102
- # be generated.
103
- #
104
- def sandbox
105
- installer.sandbox
106
- end
107
-
108
- # @return [Config] The config singleton used for the installation.
109
- #
110
- def config
111
- Config.instance
112
- end
113
-
114
- # @return [Installer] The installer described by this instance.
115
- #
116
- attr_reader :installer
117
-
118
- #-----------------------------------------------------------------------#
119
-
120
- # @!group Private implementation
121
-
122
- # Initialize a new instance
123
- #
124
- # @param [Installer] installer @see installer
125
- #
126
- def initialize(installer)
127
- @installer = installer
128
- end
129
-
130
- #-----------------------------------------------------------------------#
131
- end
132
- end
133
- end
@@ -1,93 +0,0 @@
1
- module Pod
2
- module Hooks
3
- class LibraryRepresentation
4
- # Stores the information of the target installer
5
-
6
- #-----------------------------------------------------------------------#
7
-
8
- # @return [String] The name of the Pods library.
9
- #
10
- def name
11
- library.name
12
- end
13
-
14
- # @return [Array<Dependency>] The dependencies of this library.
15
- #
16
- def dependencies
17
- target_definition.dependencies
18
- end
19
-
20
- # @return [Pathname] The path of the Pods dir.
21
- #
22
- def sandbox_dir
23
- sandbox.root
24
- end
25
-
26
- # @return [Pathname] The path of the prefix_header
27
- #
28
- def prefix_header_path
29
- UI.warn 'LibraryRepresentation#prefix_header_path is deprecated. ' \
30
- 'Use the specification `prefix_header_contents` attribute.'
31
- library.prefix_header_path
32
- end
33
- alias_method :prefix_header_filename, :prefix_header_path
34
-
35
- # @return [Pathname] The path of the script used to copy the resources.
36
- #
37
- def copy_resources_script_path
38
- library.copy_resources_script_path
39
- end
40
-
41
- # @return [Project] The Pods project of the sandbox.
42
- #
43
- def project
44
- sandbox.project
45
- end
46
-
47
- # @return [TargetDefinition] The target definition of the library.
48
- #
49
- def target_definition
50
- library.target_definition
51
- end
52
-
53
- #-----------------------------------------------------------------------#
54
-
55
- public
56
-
57
- # @!group Unsafe Hooks API
58
-
59
- # @return [Sandbox] sandbox the sandbox where the support files should
60
- # be generated.
61
- #
62
- attr_reader :sandbox
63
-
64
- # @return [Target] The library whose target needs to be generated.
65
- #
66
- attr_reader :library
67
-
68
- # @return [PBXNativeTarget] The target generated by the installation
69
- # process.
70
- #
71
- def target
72
- library.native_target
73
- end
74
-
75
- #-----------------------------------------------------------------------#
76
-
77
- # @!group Private implementation
78
-
79
- # Initialize a new instance
80
- #
81
- # @param [Sandbox] sandbox @see sandbox
82
- # @param [Target] library @see library
83
- #
84
- def initialize(sandbox, library)
85
- @sandbox = sandbox
86
- @library = library
87
- raise '[BUG]' unless library.is_a?(AggregateTarget)
88
- end
89
-
90
- #-----------------------------------------------------------------------#
91
- end
92
- end
93
- end
@@ -1,70 +0,0 @@
1
- module Pod
2
- class Specification
3
- def config
4
- UI.warn "[#{name}] Specification#config is deprecated. The config is accessible from " \
5
- 'the parameter passed to the hooks'
6
- Config.instance
7
- end
8
- end
9
-
10
- module Hooks
11
- # Stores the information of the Installer for the hooks
12
- #
13
- class PodRepresentation
14
- # @return [String] the name of the pod
15
- #
16
- attr_accessor :name
17
-
18
- # @return [Version] the version
19
- #
20
- def version
21
- root_spec.version
22
- end
23
-
24
- # @return [Specification] the root spec
25
- #
26
- def root_spec
27
- file_accessors.first.spec.root
28
- end
29
-
30
- # @return [Array<Specification>] the specs
31
- #
32
- def specs
33
- file_accessors.map(&:spec).uniq
34
- end
35
-
36
- # @return [Pathname] the root path
37
- #
38
- def root
39
- file_accessors.first.path_list.root
40
- end
41
-
42
- # @return [Array<Pathname>] the source files
43
- #
44
- def source_files
45
- file_accessors.map(&:source_files).flatten.uniq
46
- end
47
-
48
- #-----------------------------------------------------------------------#
49
-
50
- # @!group Private implementation
51
-
52
- # @param [Installer] installer @see installer
53
- #
54
- def initialize(name, file_accessors)
55
- @name = name
56
- @file_accessors = file_accessors
57
- end
58
-
59
- def to_s
60
- root_spec.to_s
61
- end
62
-
63
- private
64
-
65
- attr_reader :file_accessors
66
-
67
- #-----------------------------------------------------------------------#
68
- end
69
- end
70
- end