xcodeproj 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/bin/xcodeproj +5 -5
  3. data/lib/xcodeproj.rb +0 -2
  4. data/lib/xcodeproj/command.rb +26 -17
  5. data/lib/xcodeproj/command/project_diff.rb +8 -11
  6. data/lib/xcodeproj/command/show.rb +8 -10
  7. data/lib/xcodeproj/command/sort.rb +4 -7
  8. data/lib/xcodeproj/command/target_diff.rb +4 -5
  9. data/lib/xcodeproj/config.rb +64 -57
  10. data/lib/xcodeproj/config/other_linker_flags_parser.rb +62 -0
  11. data/lib/xcodeproj/constants.rb +31 -30
  12. data/lib/xcodeproj/differ.rb +5 -9
  13. data/lib/xcodeproj/gem_version.rb +1 -2
  14. data/lib/xcodeproj/helper.rb +5 -4
  15. data/lib/xcodeproj/plist_helper.rb +46 -11
  16. data/lib/xcodeproj/project.rb +16 -20
  17. data/lib/xcodeproj/project/case_converter.rb +59 -0
  18. data/lib/xcodeproj/project/object.rb +40 -30
  19. data/lib/xcodeproj/project/object/build_configuration.rb +1 -5
  20. data/lib/xcodeproj/project/object/build_file.rb +1 -4
  21. data/lib/xcodeproj/project/object/build_phase.rb +2 -13
  22. data/lib/xcodeproj/project/object/build_rule.rb +0 -3
  23. data/lib/xcodeproj/project/object/configuration_list.rb +0 -4
  24. data/lib/xcodeproj/project/object/container_item_proxy.rb +2 -4
  25. data/lib/xcodeproj/project/object/file_reference.rb +3 -6
  26. data/lib/xcodeproj/project/object/group.rb +6 -14
  27. data/lib/xcodeproj/project/object/helpers/file_references_factory.rb +64 -13
  28. data/lib/xcodeproj/project/object/helpers/groupable_helper.rb +4 -6
  29. data/lib/xcodeproj/project/object/native_target.rb +18 -29
  30. data/lib/xcodeproj/project/object/reference_proxy.rb +0 -4
  31. data/lib/xcodeproj/project/object/root_object.rb +4 -8
  32. data/lib/xcodeproj/project/object/target_dependency.rb +1 -4
  33. data/lib/xcodeproj/project/object_attributes.rb +76 -33
  34. data/lib/xcodeproj/project/object_dictionary.rb +76 -63
  35. data/lib/xcodeproj/project/object_list.rb +5 -9
  36. data/lib/xcodeproj/project/project_helper.rb +2 -7
  37. data/lib/xcodeproj/project/xcproj_helper.rb +0 -2
  38. data/lib/xcodeproj/scheme.rb +12 -15
  39. data/lib/xcodeproj/user_interface.rb +0 -4
  40. data/lib/xcodeproj/workspace.rb +36 -23
  41. data/lib/xcodeproj/workspace/file_reference.rb +3 -3
  42. data/lib/xcodeproj/xcodebuild_helper.rb +0 -6
  43. metadata +20 -18
@@ -1,6 +1,5 @@
1
1
  module Xcodeproj
2
2
  class Project
3
-
4
3
  # This class represents an ordered relationship to many objects.
5
4
  #
6
5
  # It works in conjunction with the {AbstractObject} class to ensure that
@@ -16,7 +15,6 @@ module Xcodeproj
16
15
  # @todo Cover all the mutations methods of the {Array} class.
17
16
  #
18
17
  class ObjectList < Array
19
-
20
18
  # {Xcodeproj} clients are not expected to create instances of
21
19
  # {ObjectList}, it is always initialized empty and automatically by the
22
20
  # synthesized methods generated by {AbstractObject.has_many}.
@@ -38,7 +36,7 @@ module Xcodeproj
38
36
  # the UUIDs of all the objects referenced by this list.
39
37
  #
40
38
  def uuids
41
- map { |obj| obj.uuid }
39
+ map(&:uuid)
42
40
  end
43
41
 
44
42
  # @return [Array<AbstractObject>]
@@ -48,7 +46,6 @@ module Xcodeproj
48
46
  to_a
49
47
  end
50
48
 
51
-
52
49
  public
53
50
 
54
51
  # @!group Notification enabled methods
@@ -63,8 +60,8 @@ module Xcodeproj
63
60
  #
64
61
  # @return [void]
65
62
  #
66
- def +(objects)
67
- perform_additions_operations(objects)
63
+ def +(other)
64
+ perform_additions_operations(other)
68
65
  super
69
66
  end
70
67
 
@@ -157,7 +154,7 @@ module Xcodeproj
157
154
  if obj = delete(object)
158
155
  insert(new_index, obj)
159
156
  else
160
- raise "Attempt to move object `#{object}` not present in the list `#{self.inspect}`"
157
+ raise "Attempt to move object `#{object}` not present in the list `#{inspect}`"
161
158
  end
162
159
  end
163
160
 
@@ -175,11 +172,10 @@ module Xcodeproj
175
172
  if obj = delete_at(current_index)
176
173
  insert(new_index, obj)
177
174
  else
178
- raise "Attempt to move object from index `#{current_index}` which is beyond bounds of the list `#{self.inspect}`"
175
+ raise "Attempt to move object from index `#{current_index}` which is beyond bounds of the list `#{inspect}`"
179
176
  end
180
177
  end
181
178
 
182
-
183
179
  private
184
180
 
185
181
  # @!group Notification Methods
@@ -1,7 +1,6 @@
1
1
  module Xcodeproj
2
2
  class Project
3
3
  module ProjectHelper
4
-
5
4
  include Object
6
5
 
7
6
  # @!group Targets
@@ -36,7 +35,6 @@ module Xcodeproj
36
35
  # @return [PBXNativeTarget] the target.
37
36
  #
38
37
  def self.new_target(project, type, name, platform, deployment_target, product_group)
39
-
40
38
  # Target
41
39
  target = project.new(PBXNativeTarget)
42
40
  project.targets << target
@@ -55,7 +53,7 @@ module Xcodeproj
55
53
 
56
54
  # Frameworks
57
55
  framework_name = (platform == :ios) ? 'Foundation' : 'Cocoa'
58
- framework_ref = target.add_system_framework(framework_name)
56
+ target.add_system_framework(framework_name)
59
57
 
60
58
  target
61
59
  end
@@ -100,7 +98,6 @@ module Xcodeproj
100
98
  debug_conf.build_settings = build_settings
101
99
  cl.build_configurations << release_conf
102
100
  cl.build_configurations << debug_conf
103
- cl
104
101
  target.build_configuration_list = cl
105
102
 
106
103
  # Product
@@ -115,7 +112,6 @@ module Xcodeproj
115
112
  target
116
113
  end
117
114
 
118
-
119
115
  # @!group Private Helpers
120
116
 
121
117
  #-----------------------------------------------------------------------#
@@ -172,7 +168,7 @@ module Xcodeproj
172
168
  build_settings = {
173
169
  'PRODUCT_NAME' => '$(TARGET_NAME)',
174
170
  'WRAPPER_EXTENSION' => 'bundle',
175
- 'SKIP_INSTALL' => 'YES'
171
+ 'SKIP_INSTALL' => 'YES',
176
172
  }
177
173
 
178
174
  if platform == :osx
@@ -222,7 +218,6 @@ module Xcodeproj
222
218
  end
223
219
 
224
220
  #-----------------------------------------------------------------------#
225
-
226
221
  end
227
222
  end
228
223
  end
@@ -2,7 +2,6 @@ module Xcodeproj
2
2
  class Project
3
3
  module XCProjHelper
4
4
  class << self
5
-
6
5
  # @return [Bool] Whether the xcproj tool is available.
7
6
  #
8
7
  def available?
@@ -47,7 +46,6 @@ module Xcodeproj
47
46
  end
48
47
 
49
48
  #---------------------------------------------------------------------#
50
-
51
49
  end
52
50
  end
53
51
  end
@@ -1,13 +1,11 @@
1
1
  require 'rexml/document'
2
2
 
3
3
  module Xcodeproj
4
-
5
4
  # This class represents a Scheme document represented by a ".xcscheme" file
6
5
  # usually stored in a xcuserdata or xcshareddata (for a shared scheme)
7
6
  # folder.
8
7
  #
9
8
  class XCScheme
10
-
11
9
  # @return [REXML::Document] the XML object that will be manipulated to save
12
10
  # the scheme file after.
13
11
  #
@@ -46,7 +44,7 @@ module Xcodeproj
46
44
  @launch_action.attributes['ignoresPersistentStateOnLaunch'] = 'NO'
47
45
  @launch_action.attributes['debugDocumentVersioning'] = 'YES'
48
46
  @launch_action.attributes['allowLocationSimulation'] = 'YES'
49
- additional_options = @launch_action.add_element 'AdditionalOptions'
47
+ @launch_action.add_element('AdditionalOptions')
50
48
 
51
49
  @profile_action = @scheme.add_element 'ProfileAction'
52
50
  @profile_action.attributes['shouldUseLaunchSchemeArgsEnv'] = 'YES'
@@ -76,7 +74,7 @@ module Xcodeproj
76
74
  # Whether to build this target in the launch action. Often false for test targets.
77
75
  #
78
76
  def add_build_target(build_target, build_for_running = true)
79
- if !@build_action_entries then
77
+ unless @build_action_entries
80
78
  @build_action_entries = @build_action.add_element 'BuildActionEntries'
81
79
  end
82
80
 
@@ -166,7 +164,7 @@ module Xcodeproj
166
164
  to_folder = shared_data_dir(project_path)
167
165
  to_folder.mkpath
168
166
  to = to_folder + "#{scheme_name}.xcscheme"
169
- from = self.user_data_dir(project_path, user) + "#{scheme_name}.xcscheme"
167
+ from = user_data_dir(project_path, user) + "#{scheme_name}.xcscheme"
170
168
  FileUtils.mv(from, to)
171
169
  end
172
170
 
@@ -199,7 +197,7 @@ module Xcodeproj
199
197
  # @return [String] the XML string value of the current state of the object.
200
198
  #
201
199
  def to_s
202
- formatter = XML_Formatter.new(2)
200
+ formatter = XMLFormatter.new(2)
203
201
  formatter.compact = false
204
202
  out = ''
205
203
  formatter.write(@doc, out)
@@ -242,29 +240,29 @@ module Xcodeproj
242
240
 
243
241
  # XML formatter which closely mimics the output generated by Xcode.
244
242
  #
245
- class XML_Formatter < REXML::Formatters::Pretty
243
+ class XMLFormatter < REXML::Formatters::Pretty
246
244
  def write_element(node, output)
247
245
  @indentation = 3
248
- output << ' '*@level
246
+ output << ' ' * @level
249
247
  output << "<#{node.expanded_name}"
250
248
 
251
249
  @level += @indentation
252
250
  node.attributes.each_attribute do |attr|
253
251
  output << "\n"
254
- output << ' '*@level
252
+ output << ' ' * @level
255
253
  output << attr.to_string.gsub(/=/, ' = ')
256
254
  end unless node.attributes.empty?
257
255
 
258
- output << ">"
256
+ output << '>'
259
257
 
260
258
  output << "\n"
261
- node.children.each { |child|
262
- next if child.kind_of?(REXML::Text) and child.to_s.strip.length == 0
259
+ node.children.each do |child|
260
+ next if child.is_a?(REXML::Text) && child.to_s.strip.length == 0
263
261
  write(child, output)
264
262
  output << "\n"
265
- }
263
+ end
266
264
  @level -= @indentation
267
- output << ' '*@level
265
+ output << ' ' * @level
268
266
  output << "</#{node.expanded_name}>"
269
267
  end
270
268
  end
@@ -304,6 +302,5 @@ module Xcodeproj
304
302
  end
305
303
 
306
304
  #-------------------------------------------------------------------------#
307
-
308
305
  end
309
306
  end
@@ -1,9 +1,7 @@
1
1
  module Xcodeproj
2
-
3
2
  # Manages the UI output so clients can customize it.
4
3
  #
5
4
  module UserInterface
6
-
7
5
  # Prints a message to standard output.
8
6
  #
9
7
  # @return [void]
@@ -19,8 +17,6 @@ module Xcodeproj
19
17
  def self.warn(message)
20
18
  STDERR.puts message
21
19
  end
22
-
23
20
  end
24
21
  UI = UserInterface
25
22
  end
26
-
@@ -3,12 +3,10 @@ require 'rexml/document'
3
3
  require 'xcodeproj/workspace/file_reference'
4
4
 
5
5
  module Xcodeproj
6
-
7
6
  # Provides support for generating, reading and serializing Xcode Workspace
8
7
  # documents.
9
8
  #
10
9
  class Workspace
11
-
12
10
  # @return [Array<String>] the paths of the projects contained in the
13
11
  # @return [Array<FileReference>] the paths of the projects contained in the
14
12
  # workspace.
@@ -33,11 +31,9 @@ module Xcodeproj
33
31
  # @return [Workspace] the generated workspace.
34
32
  #
35
33
  def self.new_from_xcworkspace(path)
36
- begin
37
- from_s(File.read(File.join(path, 'contents.xcworkspacedata')), File.expand_path(File.dirname(path)))
38
- rescue Errno::ENOENT
39
- new
40
- end
34
+ from_s(File.read(File.join(path, 'contents.xcworkspacedata')), File.expand_path(File.dirname(path)))
35
+ rescue Errno::ENOENT
36
+ new
41
37
  end
42
38
 
43
39
  #-------------------------------------------------------------------------#
@@ -50,9 +46,9 @@ module Xcodeproj
50
46
  #
51
47
  # @return [Workspace] the generated workspace.
52
48
  #
53
- def self.from_s(xml, workspace_path='')
49
+ def self.from_s(xml, workspace_path = '')
54
50
  document = REXML::Document.new(xml)
55
- file_references = document.get_elements("/Workspace/FileRef").map do |node|
51
+ file_references = document.get_elements('/Workspace/FileRef').map do |node|
56
52
  FileReference.from_node(node)
57
53
  end
58
54
  instance = new(file_references)
@@ -88,18 +84,11 @@ module Xcodeproj
88
84
  @file_references.include?(file_reference)
89
85
  end
90
86
 
91
- # The template to generate a workspace XML representation.
92
- #
93
- TEMPLATE = %q[<?xml version="1.0" encoding="UTF-8"?><Workspace version="1.0"></Workspace>]
94
-
95
87
  # @return [String] the XML representation of the workspace.
96
88
  #
97
89
  def to_s
98
- REXML::Document.new(TEMPLATE).tap do |document|
99
- @file_references.each do |file_reference|
100
- document.root << file_reference.to_node
101
- end
102
- end.to_s
90
+ contents = file_references.map { |reference| file_reference_xml(reference) }
91
+ root_xml(contents.join(''))
103
92
  end
104
93
 
105
94
  # Saves the workspace at the given `xcworkspace` path.
@@ -125,16 +114,15 @@ module Xcodeproj
125
114
  #
126
115
  # @return [void]
127
116
  #
128
- def load_schemes workspace_dir_path
117
+ def load_schemes(workspace_dir_path)
129
118
  @file_references.each do |file_reference|
130
119
  project_full_path = file_reference.absolute_path(workspace_dir_path)
131
120
  load_schemes_from_project(project_full_path)
132
121
  end
133
122
  end
134
123
 
135
- #-------------------------------------------------------------------------#
136
-
137
124
  private
125
+
138
126
  # Load all schemes from project
139
127
  #
140
128
  # @param [String] project_full_path
@@ -142,14 +130,39 @@ module Xcodeproj
142
130
  #
143
131
  # @return [void]
144
132
  #
145
- def load_schemes_from_project project_full_path
133
+ def load_schemes_from_project(project_full_path)
146
134
  schemes = Xcodeproj::Project.schemes project_full_path
147
135
  schemes.each do |scheme_name|
148
136
  @schemes[scheme_name] = project_full_path
149
137
  end
150
138
  end
151
139
 
152
- #-------------------------------------------------------------------------#
140
+ # @return [String] The template of the workspace XML as formated by Xcode.
141
+ #
142
+ # @param [String] contents The XML contents of the workspace.
143
+ #
144
+ def root_xml(contents)
145
+ <<-DOC
146
+ <?xml version="1.0" encoding="UTF-8"?>
147
+ <Workspace
148
+ version = "1.0">
149
+ #{contents.strip}
150
+ </Workspace>
151
+ DOC
152
+ end
153
+
154
+ # @return [String] The XML representation of a file reference.
155
+ #
156
+ # @param [FileReference] file_reference The file reference.
157
+ #
158
+ def file_reference_xml(file_reference)
159
+ <<-DOC
160
+ <FileRef
161
+ location = "#{file_reference.type}:#{file_reference.path}">
162
+ </FileRef>
163
+ DOC
164
+ end
153
165
 
166
+ #-------------------------------------------------------------------------#
154
167
  end
155
168
  end
@@ -20,7 +20,7 @@ module Xcodeproj
20
20
  # @param [#to_s] path @see path
21
21
  # @param [#to_s] type @see type
22
22
  #
23
- def initialize(path, type="group")
23
+ def initialize(path, type = 'group')
24
24
  @path = path.to_s
25
25
  @type = type.to_s
26
26
  end
@@ -53,7 +53,7 @@ module Xcodeproj
53
53
  # @return [REXML::Element] the XML representation of the file reference.
54
54
  #
55
55
  def to_node
56
- REXML::Element.new("FileRef").tap do |element|
56
+ REXML::Element.new('FileRef').tap do |element|
57
57
  element.attributes['location'] = "#{type}:#{path}"
58
58
  end
59
59
  end
@@ -76,7 +76,7 @@ module Xcodeproj
76
76
  when 'absolute'
77
77
  File.expand_path(path)
78
78
  when 'developer'
79
- raise "Developer workspace file reference type is not yet " \
79
+ raise 'Developer workspace file reference type is not yet ' \
80
80
  "#{self}"
81
81
  else
82
82
  raise "Unsupported workspace file reference type #{type}"
@@ -1,9 +1,7 @@
1
1
  module Xcodeproj
2
-
3
2
  # Helper class which returns information from xcodebuild.
4
3
  #
5
4
  class XcodebuildHelper
6
-
7
5
  def initialize
8
6
  @needs_to_parse_sdks = true
9
7
  end
@@ -75,8 +73,6 @@ module Xcodeproj
75
73
  `xcodebuild -showsdks 2>/dev/null`
76
74
  end
77
75
 
78
- public
79
-
80
76
  #-------------------------------------------------------------------------#
81
77
 
82
78
  # @!group Singleton
@@ -90,7 +86,5 @@ module Xcodeproj
90
86
  end
91
87
 
92
88
  #-------------------------------------------------------------------------#
93
-
94
89
  end
95
-
96
90
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: colored
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: CFPropertyList
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.2'
55
55
  description: Xcodeproj lets you create and modify Xcode projects from Ruby. Script
@@ -61,15 +61,14 @@ executables:
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
- - LICENSE
65
64
  - README.md
66
- - bin/xcodeproj
67
- - lib/xcodeproj.rb
68
- - lib/xcodeproj/command.rb
65
+ - LICENSE
69
66
  - lib/xcodeproj/command/project_diff.rb
70
67
  - lib/xcodeproj/command/show.rb
71
68
  - lib/xcodeproj/command/sort.rb
72
69
  - lib/xcodeproj/command/target_diff.rb
70
+ - lib/xcodeproj/command.rb
71
+ - lib/xcodeproj/config/other_linker_flags_parser.rb
73
72
  - lib/xcodeproj/config.rb
74
73
  - lib/xcodeproj/constants.rb
75
74
  - lib/xcodeproj/differ.rb
@@ -77,8 +76,7 @@ files:
77
76
  - lib/xcodeproj/gem_version.rb
78
77
  - lib/xcodeproj/helper.rb
79
78
  - lib/xcodeproj/plist_helper.rb
80
- - lib/xcodeproj/project.rb
81
- - lib/xcodeproj/project/object.rb
79
+ - lib/xcodeproj/project/case_converter.rb
82
80
  - lib/xcodeproj/project/object/build_configuration.rb
83
81
  - lib/xcodeproj/project/object/build_file.rb
84
82
  - lib/xcodeproj/project/object/build_phase.rb
@@ -93,16 +91,20 @@ files:
93
91
  - lib/xcodeproj/project/object/reference_proxy.rb
94
92
  - lib/xcodeproj/project/object/root_object.rb
95
93
  - lib/xcodeproj/project/object/target_dependency.rb
94
+ - lib/xcodeproj/project/object.rb
96
95
  - lib/xcodeproj/project/object_attributes.rb
97
96
  - lib/xcodeproj/project/object_dictionary.rb
98
97
  - lib/xcodeproj/project/object_list.rb
99
98
  - lib/xcodeproj/project/project_helper.rb
100
99
  - lib/xcodeproj/project/xcproj_helper.rb
100
+ - lib/xcodeproj/project.rb
101
101
  - lib/xcodeproj/scheme.rb
102
102
  - lib/xcodeproj/user_interface.rb
103
- - lib/xcodeproj/workspace.rb
104
103
  - lib/xcodeproj/workspace/file_reference.rb
104
+ - lib/xcodeproj/workspace.rb
105
105
  - lib/xcodeproj/xcodebuild_helper.rb
106
+ - lib/xcodeproj.rb
107
+ - bin/xcodeproj
106
108
  homepage: https://github.com/cocoapods/xcodeproj
107
109
  licenses:
108
110
  - MIT
@@ -113,17 +115,17 @@ require_paths:
113
115
  - lib
114
116
  required_ruby_version: !ruby/object:Gem::Requirement
115
117
  requirements:
116
- - - ">="
118
+ - - '>='
117
119
  - !ruby/object:Gem::Version
118
120
  version: '0'
119
121
  required_rubygems_version: !ruby/object:Gem::Requirement
120
122
  requirements:
121
- - - ">="
123
+ - - '>='
122
124
  - !ruby/object:Gem::Version
123
125
  version: '0'
124
126
  requirements: []
125
127
  rubyforge_project:
126
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.0.14
127
129
  signing_key:
128
130
  specification_version: 3
129
131
  summary: Create and modify Xcode projects from Ruby.