cocoapods 0.15.2 → 0.16.0.rc1

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.
@@ -1,6 +1,16 @@
1
1
  ## Master
2
2
 
3
- [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.15.1...master) • [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.3.4...master)
3
+ [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.0.rc1...master) • [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.0.rc1...master)
4
+
5
+ ## 0.16.0.rc1
6
+
7
+ [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.15.2...0.16.0.rc1) • [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.3.5...0.4.0.rc1)
8
+
9
+ - Xcodeproj partial rewrite.
10
+ [#565](https://github.com/CocoaPods/CocoaPods/pull/565)
11
+ [#561](https://github.com/CocoaPods/CocoaPods/pull/561)
12
+ - Performance improvements in the `Generating support files` phase.
13
+ - Better support for editing existing projects and sorting groups.
4
14
 
5
15
  ## 0.15.2
6
16
 
@@ -12,7 +12,7 @@ unless Gem::Version::Requirement.new('>= 1.4.0').satisfied_by?(Gem::Version.new(
12
12
  end
13
13
 
14
14
  module Pod
15
- VERSION = '0.15.2'
15
+ VERSION = '0.16.0.rc1'
16
16
 
17
17
  class PlainInformative < StandardError
18
18
  end
@@ -19,18 +19,8 @@ module Pod
19
19
  return @project if @project
20
20
  @project = Pod::Project.new
21
21
  @project.user_build_configurations = @podfile.user_build_configurations
22
- pods.each do |pod|
23
- # Add all source files to the project grouped by pod
24
- pod.relative_source_files_by_spec.each do |spec, paths|
25
- parent_group = pod.local? ? @project.local_pods : @project.pods
26
- group = @project.add_spec_group(spec.name, parent_group)
27
- paths.each do |path|
28
- group.files.new('path' => path.to_s)
29
- end
30
- end
31
- end
32
- # Add a group to hold all the target support files
33
- @project.main_group.groups.new('name' => 'Targets Support Files')
22
+ pods.each { |p| p.add_file_references_to_project(@project) }
23
+ pods.each { |p| p.link_headers }
34
24
  @project
35
25
  end
36
26
 
@@ -188,10 +178,8 @@ module Pod
188
178
  pathname = Pathname.new(sandbox.root + filename)
189
179
  dummy_source.save_as(pathname)
190
180
 
191
- project_file = project.files.new('path' => filename)
192
- project.group("Targets Support Files") << project_file
193
-
194
- target_installer.target.source_build_phases.first << project_file
181
+ file = project.new_file(filename, "Targets Support Files")
182
+ target_installer.target.source_build_phase.add_file_reference(file)
195
183
  end
196
184
 
197
185
  def specs_by_target
@@ -1,25 +1,93 @@
1
1
  module Pod
2
2
  class Installer
3
+
4
+ # This class is reponsible of creating and configuring the static library
5
+ # target in Pods project. Every target is generated from a target
6
+ # definition of the Podfile.
7
+ #
3
8
  class TargetInstaller
4
9
  include Config::Mixin
5
10
 
6
- attr_reader :podfile, :project, :target_definition, :target
7
- attr_accessor :requires_arc
11
+ # @return [Podfile]
12
+ #
13
+ # TODO: is really needed to pass the podfile?
14
+ #
15
+ attr_reader :podfile
16
+
17
+ # @return [Project] The Pods project.
18
+ #
19
+ attr_reader :project
20
+
21
+ # @return [TargetDefinition] The target definition whoose target needs to
22
+ # be generated.
23
+ #
24
+ attr_reader :target_definition
8
25
 
9
26
  def initialize(podfile, project, target_definition)
10
- @podfile, @project, @target_definition = podfile, project, target_definition
27
+ @podfile = podfile
28
+ @project = project
29
+ @target_definition = target_definition
30
+ end
31
+
32
+ # @return [void] Creates the target in the Pods project and its support
33
+ # files.
34
+ #
35
+ # @param [Array<LocalPod>] pods The pods are required by the target
36
+ # definition of this installer.
37
+ #
38
+ # @param [Sandbox] sandbox The sanbox where the support files
39
+ # should be generated.
40
+ #
41
+ def install!(pods, sandbox)
42
+ self.requires_arc = pods.any? { |pod| pod.requires_arc? }
43
+
44
+ @target = @project.add_pod_target(@target_definition.label, @target_definition.platform)
45
+
46
+ source_file_descriptions = []
47
+ pods.each { |p| p.add_build_files_to_target(@target) }
48
+
49
+ support_files_group = @project.support_files_group.new_group(@target_definition.label)
50
+ target_support_files.each { |path| support_files_group.new_file(path) }
51
+
52
+ xcconfig_file = support_files_group.files.find { |f| f.path == @target_definition.xcconfig_name }
53
+ configure_build_configurations(xcconfig_file, sandbox)
54
+ create_files(pods, sandbox)
11
55
  end
12
56
 
13
- def xcconfig
14
- @xcconfig ||= Xcodeproj::Config.new({
15
- # In a workspace this is where the static library headers should be found.
16
- 'PODS_ROOT' => @target_definition.relative_pods_root,
17
- 'PODS_HEADERS_SEARCH_PATHS' => '${PODS_PUBLIC_HEADERS_SEARCH_PATHS}',
18
- 'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
19
- 'OTHER_LDFLAGS' => default_ld_flags
57
+ # @return [PBXNativeTarget] The target generated by the installation
58
+ # process.
59
+ #
60
+ attr_reader :target
61
+
62
+
63
+ # @return [Boold] Wether the any of the pods requires arc.
64
+ #
65
+ # TODO: This should not be an attribute reader.
66
+ #
67
+ attr_accessor :requires_arc
68
+
69
+ attr_reader :xcconfig
70
+
71
+ # In a workspace this is where the static library headers should be found.
72
+ #
73
+ def generate_xcconfig(pods, sandbox)
74
+ xcconfig = Xcodeproj::Config.new({
75
+ 'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
76
+ 'OTHER_LDFLAGS' => default_ld_flags,
77
+ 'HEADER_SEARCH_PATHS' => '${PODS_HEADERS_SEARCH_PATHS}',
78
+ # CocoaPods global keys
79
+ 'PODS_ROOT' => @target_definition.relative_pods_root,
80
+ 'PODS_BUILD_HEADERS_SEARCH_PATHS' => quoted(sandbox.build_headers.search_paths).join(" "),
81
+ 'PODS_PUBLIC_HEADERS_SEARCH_PATHS' => quoted(sandbox.public_headers.search_paths).join(" "),
82
+ # Pods project specific keys
83
+ 'PODS_HEADERS_SEARCH_PATHS' => '${PODS_PUBLIC_HEADERS_SEARCH_PATHS}'
20
84
  })
85
+ pods.each { |pod| xcconfig.merge!(pod.xcconfig) }
86
+ @xcconfig = xcconfig
21
87
  end
22
88
 
89
+ #
90
+ #
23
91
  def copy_resources_script_for(pods)
24
92
  @copy_resources_script ||= Generator::CopyResourcesScript.new(pods.map { |p| p.relative_resource_files }.flatten)
25
93
  end
@@ -57,37 +125,9 @@ module Pod
57
125
  [:copy_resources_script_name, :prefix_header_name, :xcconfig_name].map { |file| @target_definition.send(file) }
58
126
  end
59
127
 
60
- # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
61
- def install!(pods, sandbox)
62
- self.requires_arc = pods.any? { |pod| pod.requires_arc? }
63
-
64
- @target = @project.add_pod_target(@target_definition.label, @target_definition.platform)
65
-
66
- source_file_descriptions = []
67
- pods.each do |pod|
68
- xcconfig.merge!(pod.xcconfig)
69
- source_file_descriptions += pod.source_file_descriptions
70
-
71
- # TODO: this doesn't need to be done here, it has nothing to do with the target
72
- pod.link_headers
73
- end
74
- @target.add_source_files(source_file_descriptions)
75
-
76
- xcconfig.merge!('HEADER_SEARCH_PATHS' => '${PODS_HEADERS_SEARCH_PATHS}')
77
- xcconfig.merge!('PODS_BUILD_HEADERS_SEARCH_PATHS' => quoted(sandbox.build_headers.search_paths).join(" "))
78
- xcconfig.merge!('PODS_PUBLIC_HEADERS_SEARCH_PATHS' => quoted(sandbox.public_headers.search_paths).join(" "))
79
-
80
- support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label)
81
- support_files_group.create_files(target_support_files)
82
-
83
- xcconfig_file = support_files_group.files.where(:path => @target_definition.xcconfig_name)
84
- configure_build_configurations(xcconfig_file, sandbox)
85
- create_files(pods, sandbox)
86
- end
87
-
88
128
  def configure_build_configurations(xcconfig_file, sandbox)
89
129
  @target.build_configurations.each do |config|
90
- config.base_configuration = xcconfig_file
130
+ config.base_configuration_reference = xcconfig_file
91
131
  config.build_settings['OTHER_LDFLAGS'] = ''
92
132
  config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name
93
133
  config.build_settings['PODS_ROOT'] = '${SRCROOT}'
@@ -96,6 +136,8 @@ module Pod
96
136
  end
97
137
  end
98
138
 
139
+ #
140
+ #
99
141
  def create_files(pods, sandbox)
100
142
  bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name
101
143
  UI.message "- Generating BridgeSupport metadata file at #{UI.path bridge_support_metadata_path}" do
@@ -104,6 +146,7 @@ module Pod
104
146
  end if @podfile.generate_bridge_support?
105
147
 
106
148
  UI.message "- Generating xcconfig file at #{UI.path(sandbox.root + @target_definition.xcconfig_name)}" do
149
+ generate_xcconfig(pods, sandbox)
107
150
  xcconfig.save_as(sandbox.root + @target_definition.xcconfig_name)
108
151
  @target_definition.xcconfig = xcconfig
109
152
  end
@@ -137,20 +137,18 @@ module Pod
137
137
  # Default to the first, which in a simple project is probably an app target.
138
138
  [user_project.targets.first]
139
139
  end.reject do |target|
140
- # Reject any target that already has this Pods library in one of its frameworks build phases
141
- target.frameworks_build_phases.any? do |phase|
142
- phase.files.any? { |file| file.name == @target_definition.lib_name }
143
- end
144
- end
140
+ # Reject any target that already has this Pods library in one of its frameworks build phases
141
+ target.frameworks_build_phase.files.any? { |build_file| build_file.file_ref.name == @target_definition.lib_name }
145
142
  end
143
+ end
146
144
  end
147
145
 
148
146
  def add_xcconfig_base_configuration
149
- xcconfig = user_project.files.new('path' => @target_definition.xcconfig_relative_path)
147
+ xcconfig = user_project.new_file(@target_definition.xcconfig_relative_path)
150
148
  targets.each do |target|
151
149
  config_build_names_by_overriden_key = {}
152
150
  target.build_configurations.each do |config|
153
- config_name = config.attributes["name"]
151
+ config_name = config.name
154
152
  if @target_definition.xcconfig
155
153
  @target_definition.xcconfig.attributes.each do |key, value|
156
154
  target_value = config.build_settings[key]
@@ -161,11 +159,11 @@ module Pod
161
159
  end
162
160
  end
163
161
 
164
- config.base_configuration = xcconfig
162
+ config.base_configuration_reference = xcconfig
165
163
  end
166
164
 
167
165
  config_build_names_by_overriden_key.each do |key, config_build_names|
168
- name = "#{target.attributes["name"]} [#{config_build_names.join(' - ')}]"
166
+ name = "#{target.name} [#{config_build_names.join(' - ')}]"
169
167
  actions = [ "Use the `$(inherited)' flag, or", "Remove the build settings from the target." ]
170
168
  UI.warn("The target `#{name}' overrides the `#{key}' build setting defined in `#{@target_definition.xcconfig_relative_path}'.", actions)
171
169
  end
@@ -173,23 +171,20 @@ module Pod
173
171
  end
174
172
 
175
173
  def add_pods_library
176
- group = user_project.group("Frameworks") || user_project.main_group
177
- pods_library = group.files.new_static_library(@target_definition.label)
174
+ frameworks = user_project.frameworks_group
175
+ pods_library = frameworks.new_static_library(@target_definition.label)
178
176
  targets.each do |target|
179
- target.frameworks_build_phases.each { |build_phase| build_phase << pods_library }
177
+ target.frameworks_build_phase.add_file_reference(pods_library)
180
178
  end
181
179
  end
182
180
 
183
181
  def add_copy_resources_script_phase
184
182
  targets.each do |target|
185
- phase = target.shell_script_build_phases.new
186
- phase.name = 'Copy Pods Resources'
183
+ phase = target.new_shell_script_build_phase('Copy Pods Resources')
187
184
  phase.shell_script = %{"#{@target_definition.copy_resources_script_relative_path}"\n}
188
185
  end
189
186
  end
190
187
  end
191
-
192
188
  end
193
-
194
189
  end
195
190
  end
@@ -387,7 +387,53 @@ module Pod
387
387
  result
388
388
  end
389
389
 
390
- # @!group Target integration
390
+ # @!group Xcodeproj integration
391
+
392
+ # Adds the file references, to the given `Pods.xcodeproj` project, for the
393
+ # source files of the pod. The file references are grouped by specification
394
+ # and stored in {#file_references_by_spec}.
395
+ #
396
+ # @note If the pod is locally sourced the file references are stored in the
397
+ # `Local Pods` group otherwise they are stored in the `Pods` group.
398
+ #
399
+ # @return [void]
400
+ #
401
+ def add_file_references_to_project(project)
402
+ @file_references_by_spec = {}
403
+ parent_group = local? ? project.local_pods : project.pods
404
+
405
+ relative_source_files_by_spec.each do |spec, paths|
406
+ group = project.add_spec_group(spec.name, parent_group)
407
+ file_references = []
408
+ paths.each do |path|
409
+ file_references << group.new_file(path)
410
+ end
411
+ @file_references_by_spec[spec] = file_references
412
+ end
413
+ end
414
+
415
+ # @return [Hash{Specification => Array<PBXFileReference>}] The file
416
+ # references of the pod in the `Pods.xcodeproj` project.
417
+ #
418
+ attr_reader :file_references_by_spec
419
+
420
+ # Adds a build file for each file reference to a given target taking into
421
+ # account the compiler flags of the corresponding specification.
422
+ #
423
+ # @raise If the {#add_file_references_to_project} was not called before of
424
+ # calling this method.
425
+ #
426
+ # @return [void]
427
+ #
428
+ def add_build_files_to_target(target)
429
+ unless file_references_by_spec
430
+ raise Informative, "Local Pod needs to add the file references to the " \
431
+ "project before adding the build files to the target."
432
+ end
433
+ file_references_by_spec.each do |spec, file_reference|
434
+ target.add_file_references(file_reference, spec.compiler_flags.strip)
435
+ end
436
+ end
391
437
 
392
438
  # @return [void] Copies the pods headers to the sandbox.
393
439
  #
@@ -404,26 +450,10 @@ module Pod
404
450
  end
405
451
  end
406
452
 
407
- # @param [Xcodeproj::Project::Object::PBXNativeTarget] target
408
- # The target to integrate.
409
- #
410
- # @return [void] Adds the pods source files to a given target.
411
- #
412
- def source_file_descriptions
413
- result = []
414
- source_files_by_spec.each do | spec, files |
415
- compiler_flags = spec.compiler_flags.strip
416
- files.each do |file|
417
- file = relativize_from_sandbox(file)
418
- desc = Xcodeproj::Project::PBXNativeTarget::SourceFileDescription.new(file, compiler_flags, nil)
419
- result << desc
420
- end
421
- end
422
- result
423
- end
424
-
425
453
  # @return Whether the pod requires ARC.
426
454
  #
455
+ # TODO: this should be not used anymore.
456
+ #
427
457
  def requires_arc?
428
458
  top_specification.requires_arc
429
459
  end
@@ -530,15 +560,27 @@ module Pod
530
560
  "\t Options: #{options.inspect}"
531
561
  end
532
562
 
533
- patterns = [ patterns ] if patterns.is_a? String
534
- patterns.map do |pattern|
535
- pattern = root + pattern
563
+ return [] if patterns.empty?
564
+ patterns = [ patterns ] if patterns.is_a?(String)
565
+ file_lists = patterns.select { |p| p.is_a?(FileList) }
566
+ glob_patterns = patterns - file_lists
567
+
568
+ result = []
536
569
 
570
+ result << file_lists.map do |file_list|
571
+ file_list.prepend_patterns(root)
572
+ file_list.glob
573
+ end
574
+
575
+ result << glob_patterns.map do |pattern|
576
+ pattern = root + pattern
537
577
  if pattern.directory? && options[:glob]
538
578
  pattern += options[:glob]
539
579
  end
540
580
  Pathname.glob(pattern, File::FNM_CASEFOLD)
541
581
  end.flatten
582
+
583
+ result.flatten.compact.uniq
542
584
  end
543
585
 
544
586
  # A {LocalSourcedPod} is a {LocalPod} that interacts with the files of
@@ -1,20 +1,23 @@
1
1
  require 'xcodeproj/project'
2
- require 'xcodeproj/project/object/build_phase'
3
2
 
4
- Xcodeproj::Project::Object::PBXCopyFilesBuildPhase.instance_eval do
5
- def self.new_pod_dir(project, pod_name, path)
6
- new(project, nil, {
7
- "dstPath" => "Pods/#{path}",
8
- "name" => "Copy #{pod_name} Public Headers",
9
- })
10
- end
11
- end
3
+ # Xcodeproj::Project::Object::PBXCopyFilesBuildPhase.instance_eval do
4
+ # def self.new_pod_dir(project, pod_name, path)
5
+ # new(project, nil, {
6
+ # "dstPath" => "Pods/#{path}",
7
+ # "name" => "Copy #{pod_name} Public Headers",
8
+ # })
9
+ # end
10
+ # end
12
11
 
13
12
  module Pod
14
13
  class Project < Xcodeproj::Project
14
+
15
+ attr_reader :support_files_group
16
+
15
17
  def initialize(*)
16
18
  super
17
- main_group << groups.new('name' => 'Pods')
19
+ new_group('Pods')
20
+ @support_files_group = new_group('Targets Support Files')
18
21
  @user_build_configurations = []
19
22
  end
20
23
 
@@ -24,40 +27,44 @@ module Pod
24
27
  # any build settings themselves, that's left to `add_pod_target`.
25
28
  user_build_configurations.each do |name, _|
26
29
  unless build_configurations.map(&:name).include?(name)
27
- build_configurations.new('name' => name)
30
+ bc = new(XCBuildConfiguration)
31
+ bc.name = name
32
+ build_configurations << bc
28
33
  end
29
34
  end
30
35
  end
31
36
 
32
37
  # Shortcut access to the `Pods' PBXGroup.
33
38
  def pods
34
- @pods ||= groups.where(:name => 'Pods') || groups.new('name' => 'Pods')
39
+ @pods ||= self['Pods'] || new_group('Pods')
35
40
  end
36
41
 
37
42
  # Shortcut access to the `Local Pods' PBXGroup.
38
43
  def local_pods
39
- @local_pods ||= groups.where(:name => 'Local Pods') || groups.new('name' => 'Local Pods')
44
+ @local_pods ||= self['Local Pods'] || new_group('Local Pods')
40
45
  end
41
46
 
42
47
  # Adds a group as child to the `Pods' group namespacing subspecs.
43
48
  def add_spec_group(name, parent_group)
44
- groups = parent_group.groups
49
+ current_group = parent_group
45
50
  group = nil
46
51
  name.split('/').each do |name|
47
- group = groups.where(:name => name) || groups.new('name' => name)
48
- groups = group.groups
52
+ group = current_group[name] || current_group.new_group(name)
53
+ current_group = group
49
54
  end
50
55
  group
51
56
  end
52
57
 
53
58
  def add_pod_target(name, platform)
54
- target = targets.new_static_library(platform.name, name)
59
+ target = new_target(:static_library, name, platform.name)
55
60
 
56
61
  settings = {}
57
62
  if platform.requires_legacy_ios_archs?
58
63
  settings['ARCHS'] = "armv6 armv7"
59
64
  end
65
+
60
66
  if platform == :ios && platform.deployment_target
67
+ # TODO: add for osx as well
61
68
  settings['IPHONEOS_DEPLOYMENT_TARGET'] = platform.deployment_target.to_s
62
69
  end
63
70
 
@@ -66,9 +73,11 @@ module Pod
66
73
 
67
74
  @user_build_configurations.each do |name, type|
68
75
  unless target.build_configurations.map(&:name).include?(name)
69
- config = target.build_configurations.new('name' => name)
76
+ bc = new(XCBuildConfiguration)
77
+ bc.name = name
78
+ target.build_configurations << bc
70
79
  # Copy the settings from either the Debug or the Release configuration.
71
- config.build_settings = target.build_settings(type.to_s.capitalize).merge(settings)
80
+ bc.build_settings = target.build_settings(type.to_s.capitalize).merge(settings)
72
81
  end
73
82
  end
74
83
 
@@ -438,11 +438,12 @@ module Pod
438
438
  # this to, for instance, to run any build script:
439
439
  #
440
440
  # Pod::Spec.new do |s|
441
- # def pre_install(pod, target_definition)
441
+ # def s.pre_install(pod, target_definition)
442
442
  # Dir.chdir(pod.root){ `sh make.sh` }
443
443
  # end
444
444
  # end
445
445
  def pre_install(pod, target_definition)
446
+ FALSE
446
447
  end
447
448
 
448
449
  # This is a convenience method which gets called after all pods have been
@@ -460,6 +461,7 @@ module Pod
460
461
  # end
461
462
  # end
462
463
  def post_install(target_installer)
464
+ FALSE
463
465
  end
464
466
 
465
467
  def podfile?
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
5
- prerelease:
4
+ version: 0.16.0.rc1
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Eloy Duran
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-19 00:00:00.000000000 Z
13
+ date: 2012-10-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: xcodeproj
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.3.5
22
+ version: 0.4.0.rc1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- version: 0.3.5
30
+ version: 0.4.0.rc1
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: faraday
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -256,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  segments:
258
258
  - 0
259
- hash: -1344889839066477359
259
+ hash: -3426650805670667619
260
260
  required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  none: false
262
262
  requirements: