zerg_xcode 0.2.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.3. Implemented addtarget.
2
+
1
3
  v0.2.1. Implemented lstargets.
2
4
 
3
5
  v0.2. Implemented import.
data/Manifest CHANGED
@@ -6,6 +6,7 @@ lib/zerg_xcode/file_format/lexer.rb
6
6
  lib/zerg_xcode/file_format/parser.rb
7
7
  lib/zerg_xcode/file_format/paths.rb
8
8
  lib/zerg_xcode/objects/pbx_build_file.rb
9
+ lib/zerg_xcode/objects/pbx_build_phase.rb
9
10
  lib/zerg_xcode/objects/pbx_container_item_proxy.rb
10
11
  lib/zerg_xcode/objects/pbx_group.rb
11
12
  lib/zerg_xcode/objects/pbx_native_target.rb
@@ -13,6 +14,7 @@ lib/zerg_xcode/objects/pbx_project.rb
13
14
  lib/zerg_xcode/objects/pbx_target_dependency.rb
14
15
  lib/zerg_xcode/objects/xc_configuration_list.rb
15
16
  lib/zerg_xcode/objects/xcode_object.rb
17
+ lib/zerg_xcode/plugins/addlibrary.rb
16
18
  lib/zerg_xcode/plugins/core/core.rb
17
19
  lib/zerg_xcode/plugins/help.rb
18
20
  lib/zerg_xcode/plugins/import.rb
@@ -33,6 +35,7 @@ test/file_format/lexer_test.rb
33
35
  test/file_format/parser_test.rb
34
36
  test/file_format/path_test.rb
35
37
  test/objects/pbx_build_file_test.rb
38
+ test/objects/pbx_build_phase_test.rb
36
39
  test/objects/pbx_container_item_proxy_test.rb
37
40
  test/objects/pbx_group_test.rb
38
41
  test/objects/pbx_native_target_test.rb
@@ -24,4 +24,14 @@ class ZergXcode::Objects::PBXBuildFile < ZergXcode::XcodeObject
24
24
  return 'PBXResourcesBuildPhase'
25
25
  end
26
26
  end
27
+
28
+ # Creates a build file for the given file reference.
29
+ def self.for(file_ref)
30
+ self.new 'fileRef' => file_ref
31
+ end
32
+
33
+ # :nodoc: override xref_name to borrow the referenced object's name
34
+ def xref_name
35
+ self['fileRef'].xref_name
36
+ end
27
37
  end
@@ -0,0 +1,12 @@
1
+ # Superclass for all the Xcode build phases.
2
+ #
3
+ # Subclasses include PBXHeadersBuildPhase, PBXSourcesBuildPhase,
4
+ # PBXFrameworksBuildPhase, and PBXResourcesBuildPhase.
5
+ class ZergXcode::Objects::PBXBuildPhase < ZergXcode::XcodeObject
6
+ # Creates a new build phase with the given isa type.
7
+ def self.new_phase(isa_type)
8
+ self.new 'isa' => isa_type.to_s, 'dependencies' => [], 'files' => [],
9
+ 'buildActionMask' => '2147483647',
10
+ 'runOnlyForDeploymentPostprocessing' => '0'
11
+ end
12
+ end
@@ -7,4 +7,17 @@ class ZergXcode::Objects::PBXContainerItemProxy < ZergXcode::XcodeObject
7
7
  def target
8
8
  self['remoteGlobalIDString']
9
9
  end
10
+
11
+ # Creates a proxy for an object in the same graph, using the given container.
12
+ #
13
+ # Usually, the container is the project.
14
+ def self.for(object, container)
15
+ self.new 'proxyType' => '1', 'containerPortal' => container,
16
+ 'remoteInfo' => object.xref_name, 'remoteGlobalIDString' => object
17
+ end
18
+
19
+ # :nodoc: override xref_name because Xcode gives us a name in remoteInfo
20
+ def xref_name
21
+ self['remoteInfo']
22
+ end
10
23
  end
@@ -27,6 +27,11 @@ class ZergXcode::Objects::PBXProject < ZergXcode::XcodeObject
27
27
  FileVisitor.visit self['mainGroup'], project_root, files
28
28
  files
29
29
  end
30
+
31
+ # :nodoc: override xref_name because PBXProject is a singleton
32
+ def xref_name
33
+ isa.to_s
34
+ end
30
35
 
31
36
  # Container for the visitor that lists all files in a project.
32
37
  module FileVisitor
@@ -1,7 +1,20 @@
1
1
  # Expresses a target's dependency on another target.
2
2
  class ZergXcode::Objects::PBXTargetDependency < ZergXcode::XcodeObject
3
+ PBXContainerItemProxy = ZergXcode::Objects::PBXContainerItemProxy
4
+
3
5
  # The target that this target depends on.
4
6
  def target
5
7
  self['target']
6
8
  end
9
+
10
+ # Creates a new dependency on the given target
11
+ def self.for(target, project)
12
+ self.new 'target' => target,
13
+ 'targetProxy' => PBXContainerItemProxy.for(target, project)
14
+ end
15
+
16
+ # :nodoc: override xref_name to use the name of the target in the dependency
17
+ def xref_name
18
+ target.xref_name
19
+ end
7
20
  end
@@ -1,3 +1,7 @@
1
1
  # The configurations associated with an object.
2
2
  class ZergXcode::Objects::XCConfigurationList < ZergXcode::XcodeObject
3
+ # :nodoc: override xref_name because there's always a single list in a context
4
+ def xref_name
5
+ isa.to_s
6
+ end
3
7
  end
@@ -116,6 +116,33 @@ class ZergXcode::XcodeObject
116
116
  end
117
117
  value
118
118
  end
119
+
120
+ # Graph navigating and cross-referencing.
121
+
122
+ # Key used for cross-referencing objects in different graphs. If two objects
123
+ # in different graphs have the same key, it is very likely that they represent
124
+ # the same entity.
125
+ def xref_key
126
+ # If the object doesn't have a merge name, use its (unique) object_id.
127
+ [isa, xref_name || object_id]
128
+ end
129
+
130
+ # Name used in referencing an object.
131
+ #
132
+ # An object's name should be unique among objects in the same context. For
133
+ # instance, objects in the same array (e.g. 'children' in a PBXGroup) should
134
+ # have distinct names.
135
+ def xref_name
136
+ # Do not use this to override xref_name for specific objects. Only use
137
+ # it for object families.
138
+ case isa.to_s
139
+ when /BuildPhase$/
140
+ isa.to_s
141
+ else
142
+ self['name'] || self['explicitPath'] || self['path']
143
+ end
144
+ end
145
+
119
146
 
120
147
  # Deep copy
121
148
  def self.from(object_or_hash)
@@ -153,6 +180,6 @@ class ZergXcode::XcodeObject
153
180
 
154
181
  def copy_metadata(source)
155
182
  self.archive_id, self.version = source.archive_id, source.version
156
- end
183
+ end
157
184
  end
158
185
 
@@ -0,0 +1,121 @@
1
+ class ZergXcode::Plugins::Addlibrary
2
+ include ZergXcode::Objects
3
+
4
+ def help
5
+ {:short => 'adds a library to a target',
6
+ :long => <<"END" }
7
+ Usage: addlibrary library_target target [path]
8
+
9
+ Adds a library as a dependency to a target, in the project at the given path.
10
+ If no path is given, looks for a project in the current directory.
11
+
12
+ library_target should be a static library. If library_target contains ObjectiveC
13
+ files, the "-ObjC" option is added to the target linker options.
14
+ END
15
+ end
16
+
17
+ def run(args)
18
+ lib_target_name = args.shift
19
+ target_name = args.shift
20
+ project = ZergXcode.load(args.shift || '.')
21
+
22
+ ad = "'zerg-xcode lstargets' can list project targets."
23
+ unless lib_target = find_target(lib_target_name, project)
24
+ print "#{lib_target_name} not found. #{ad}"
25
+ return
26
+ end
27
+ unless target = find_target(target_name, project)
28
+ print "#{lib_target_name} not found. #{ad}"
29
+ return
30
+ end
31
+
32
+ add_library! lib_target, target, project
33
+ project.save!
34
+ end
35
+
36
+ def find_target(name, project)
37
+ project['targets'].find { |target| target['name'] == name }
38
+ end
39
+
40
+ # Adds a library to a project.
41
+ def add_library!(library_target, target, project)
42
+ add_target_dependency! library_target, target, project
43
+ add_target_to_build_phases! library_target, target
44
+
45
+ add_linker_option! '-ObjC', target if has_objc_files? target
46
+ end
47
+
48
+ # Adds a target as a dependency of another target.
49
+ def add_target_dependency!(dependency, dependent, project)
50
+ return if has_target_dependency? dependency, dependent
51
+ dependent['dependencies'] << PBXTargetDependency.for(dependency, project)
52
+ end
53
+
54
+ # True if the given target is dependent on the other given target.
55
+ def has_target_dependency?(dependency, target)
56
+ target['dependencies'].any? do |dep|
57
+ dep.kind_of?(PBXTargetDependency) && dep.target == dependency
58
+ end
59
+ end
60
+
61
+ # Adds a target to the build phases of another target.
62
+ def add_target_to_build_phases!(dependency, dependent)
63
+ return if has_target_in_build_phases? dependency, dependent
64
+
65
+ # find or create the frameworks build phase
66
+ frameworks_phase = dependent['buildPhases'].find do |phase|
67
+ phase['isa'] == 'PBXFrameworksBuildPhase'
68
+ end
69
+ unless frameworks_phase
70
+ frameworks_phase = PBXBuildPhase.new_phase 'PBXFrameworksBuildPhase'
71
+ target['buildPhases'] << frameworks_phase
72
+ end
73
+
74
+ dep_file = dependency['productReference']
75
+ frameworks_phase['files'] << PBXBuildFile.for(dep_file)
76
+ end
77
+
78
+ def has_target_in_build_phases?(dependency, dependent)
79
+ frameworks_phase = dependent['buildPhases'].find do |phase|
80
+ phase['isa'] == 'PBXFrameworksBuildPhase'
81
+ end
82
+ return false unless frameworks_phase
83
+
84
+ frameworks_phase['files'].any? do |file|
85
+ file['fileRef'] == dependency['productReference']
86
+ end
87
+ end
88
+
89
+ # True if the target builds any objective C files.
90
+ def has_objc_files?(target)
91
+ target.all_files.any? do |file|
92
+ file[:build_object].file_type == 'sourcecode.c.objc'
93
+ end
94
+ end
95
+
96
+ # Adds a linker option to the given project.
97
+ def add_linker_option!(option, target)
98
+ key = 'OTHER_LDFLAGS'
99
+ target['buildConfigurationList']['buildConfigurations'].each do |config|
100
+ config['buildSettings'] ||= {}
101
+ settings = config['buildSettings']
102
+ if settings[key]
103
+ settings[key] = [settings[key]] if settings[key].kind_of? String
104
+ settings[key] << option unless settings[key].include? option
105
+ else
106
+ settings[key] = option
107
+ end
108
+ end
109
+ end
110
+
111
+ # True if a target has the given linker option.
112
+ def has_linker_option?(option, target)
113
+ key = 'OTHER_LDFLAGS'
114
+ target['buildConfigurationList']['buildConfigurations'].all? do |config|
115
+ next false unless settings = config['buildSettings']
116
+ setting = settings[key]
117
+ setting && (setting == option ||
118
+ (setting.kind_of?(Enumerable) && setting.include?(option)))
119
+ end
120
+ end
121
+ end
@@ -274,51 +274,3 @@ END
274
274
  end
275
275
  private :cross_reference_enumerables
276
276
  end
277
-
278
- class ZergXcode::XcodeObject
279
- def xref_key
280
- # If the object doesn't have a merge name, use its (unique) object_id.
281
- [isa, xref_name || object_id]
282
- end
283
-
284
- def xref_name
285
- # Do not use this to override xref_name for specific objects. Only use
286
- # it for object families.
287
- case isa.to_s
288
- when /BuildPhase$/
289
- isa.to_s
290
- else
291
- self['name'] || self['explicitPath'] || self['path']
292
- end
293
- end
294
- end
295
-
296
- class ZergXcode::Objects::PBXBuildFile
297
- def xref_name
298
- self['fileRef'].xref_name
299
- end
300
- end
301
-
302
- class ZergXcode::Objects::PBXProject
303
- def xref_name
304
- isa.to_s
305
- end
306
- end
307
-
308
- class ZergXcode::Objects::XCConfigurationList
309
- def xref_name
310
- isa.to_s
311
- end
312
- end
313
-
314
- class ZergXcode::Objects::PBXContainerItemProxy
315
- def xref_name
316
- self['remoteInfo']
317
- end
318
- end
319
-
320
- class ZergXcode::Objects::PBXTargetDependency
321
- def xref_name
322
- target.xref_name
323
- end
324
- end
@@ -1,6 +1,5 @@
1
1
  class ZergXcode::Plugins::Retarget
2
2
  include ZergXcode::Objects
3
- XcodeObject = ZergXcode::XcodeObject
4
3
 
5
4
  def help
6
5
  {:short => 'reassign files to a target or set of targets',
@@ -77,10 +76,7 @@ END
77
76
  phase_type = file_phases[file]
78
77
  phase = target['buildPhases'].find { |p| p['isa'] == phase_type }
79
78
  unless phase
80
- phase = XcodeObject.new 'isa' => phase_type, 'dependencies' => [],
81
- 'files' => [],
82
- 'buildActionMask' => '2147483647',
83
- 'runOnlyForDeploymentPostprocessing' => '0'
79
+ phase = PBXBuildPhase.new_phase phase_type
84
80
  target['buildPhases'] << phase
85
81
  end
86
82
  phase['files'] << build_files[file]
data/lib/zerg_xcode.rb CHANGED
@@ -10,6 +10,7 @@ require 'zerg_xcode/file_format/paths.rb'
10
10
 
11
11
  require 'zerg_xcode/objects/xcode_object.rb'
12
12
  require 'zerg_xcode/objects/pbx_build_file.rb'
13
+ require 'zerg_xcode/objects/pbx_build_phase.rb'
13
14
  require 'zerg_xcode/objects/pbx_container_item_proxy.rb'
14
15
  require 'zerg_xcode/objects/pbx_group.rb'
15
16
  require 'zerg_xcode/objects/pbx_native_target.rb'
@@ -7,14 +7,14 @@ class PBXBuildFileTest < Test::Unit::TestCase
7
7
 
8
8
  def setup
9
9
  @target = ZergXcode.load('testdata/project.pbxproj')['targets'].first
10
+ @sources_phase = @target['buildPhases'][1]
11
+ @build_file = @sources_phase['files'].first
10
12
  end
11
13
 
12
14
  def test_attributes
13
- sources_phase = @target['buildPhases'][1]
14
- build_file = sources_phase['files'].first
15
- assert_equal PBXBuildFile, build_file.class
16
- assert_equal 'main.m', build_file.filename
17
- assert_equal 'sourcecode.c.objc', build_file.file_type
15
+ assert_equal PBXBuildFile, @build_file.class
16
+ assert_equal 'main.m', @build_file.filename
17
+ assert_equal 'sourcecode.c.objc', @build_file.file_type
18
18
 
19
19
  big_project = ZergXcode.load('testdata/ZergSupport')
20
20
  big_project['targets'].map { |t| t.all_files }.flatten.each do |file|
@@ -35,4 +35,13 @@ class PBXBuildFileTest < Test::Unit::TestCase
35
35
  end
36
36
  end
37
37
  end
38
+
39
+ def test_xref_name
40
+ assert_equal 'main.m', @build_file.xref_name
41
+ end
42
+
43
+ def test_for
44
+ new_build_file = PBXBuildFile.for @build_file['fileRef']
45
+ assert_equal @build_file._attr_hash, new_build_file._attr_hash
46
+ end
38
47
  end
@@ -0,0 +1,20 @@
1
+ require 'test/unit'
2
+
3
+ require 'zerg_xcode'
4
+
5
+ class PBXBuildPhaseTest < Test::Unit::TestCase
6
+ PBXBuildPhase = ZergXcode::Objects::PBXBuildPhase
7
+
8
+ def setup
9
+ @target = ZergXcode.load('testdata/project.pbxproj')['targets'].first
10
+ @sources_phase = @target['buildPhases'][1]
11
+ end
12
+
13
+ def test_new_phase
14
+ gold_attrs = @sources_phase._attr_hash.reject { |k, v|
15
+ ['files', 'dependencies'].include? k
16
+ }.merge 'files' => [], 'dependencies' => []
17
+ new_phase = PBXBuildPhase.new_phase('PBXSourcesBuildPhase')
18
+ assert_equal gold_attrs, new_phase._attr_hash
19
+ end
20
+ end
@@ -5,10 +5,23 @@ require 'zerg_xcode'
5
5
  class PBXContainerItemProxyTest < Test::Unit::TestCase
6
6
  PBXContainerItemProxy = ZergXcode::Objects::PBXContainerItemProxy
7
7
 
8
+ def setup
9
+ @project = ZergXcode.load 'testdata/ZergSupport.xcodeproj/project.pbxproj'
10
+ @proxy = @project['targets'][2]['dependencies'].first['targetProxy']
11
+ @target = @project['targets'][1]
12
+ end
13
+
8
14
  def test_target
9
- proj = ZergXcode.load 'testdata/ZergSupport.xcodeproj/project.pbxproj'
10
- proxy = proj['targets'][2]['dependencies'].first['targetProxy']
11
- assert_equal PBXContainerItemProxy, proxy.class
12
- assert_equal proj['targets'][1], proxy.target
15
+ assert_equal PBXContainerItemProxy, @proxy.class
16
+ assert_equal @target, @proxy.target
17
+ end
18
+
19
+ def test_xref_name
20
+ assert_equal 'ZergTestSupport', @proxy.xref_name
21
+ end
22
+
23
+ def test_for
24
+ new_proxy = PBXContainerItemProxy.for @target, @project
25
+ assert_equal @proxy._attr_hash, new_proxy._attr_hash
13
26
  end
14
27
  end
@@ -71,4 +71,9 @@ class PBXProjectTest < Test::Unit::TestCase
71
71
 
72
72
  assert_equal project.source_filename, clone.source_filename
73
73
  end
74
+
75
+ def test_xref_name
76
+ project = ZergXcode.load('testdata/project.pbxproj')
77
+ assert_equal 'PBXProject', project.xref_name
78
+ end
74
79
  end
@@ -5,10 +5,26 @@ require 'zerg_xcode'
5
5
  class PBXTargetDependencyTest < Test::Unit::TestCase
6
6
  PBXTargetDependency = ZergXcode::Objects::PBXTargetDependency
7
7
 
8
+ def setup
9
+ @project = ZergXcode.load 'testdata/ZergSupport.xcodeproj/project.pbxproj'
10
+ @dependency = @project['targets'][2]['dependencies'].first
11
+ @target = @project['targets'][1]
12
+ end
13
+
8
14
  def test_target
9
- proj = ZergXcode.load 'testdata/ZergSupport.xcodeproj/project.pbxproj'
10
- dependency = proj['targets'][2]['dependencies'].first
11
- assert_equal PBXTargetDependency, dependency.class
12
- assert_equal proj['targets'][1], dependency.target
15
+ assert_equal PBXTargetDependency, @dependency.class
16
+ assert_equal @target, @dependency.target
17
+ end
18
+
19
+ def test_xref_name
20
+ assert_equal 'ZergTestSupport', @dependency.xref_name
21
+ end
22
+
23
+ def test_for
24
+ new_dependency = PBXTargetDependency.for @target, @project
25
+ assert_equal @dependency._attr_hash.reject { |k, v| k == 'targetProxy' },
26
+ new_dependency._attr_hash.reject { |k, v| k == 'targetProxy' }
27
+ assert_equal @dependency['targetProxy']._attr_hash,
28
+ new_dependency['targetProxy']._attr_hash
13
29
  end
14
30
  end
@@ -5,8 +5,10 @@ require 'zerg_xcode'
5
5
  class XCConfigurationListTest < Test::Unit::TestCase
6
6
  XCConfigurationList = ZergXcode::Objects::XCConfigurationList
7
7
 
8
- def test_instantiation
8
+ def test_xref_name
9
9
  proj = ZergXcode.load 'testdata/project.pbxproj'
10
- assert_equal XCConfigurationList, proj['buildConfigurationList'].class
10
+ list = proj['buildConfigurationList']
11
+ assert_equal XCConfigurationList, list.class
12
+ assert_equal 'XCConfigurationList', list.xref_name
11
13
  end
12
14
  end
@@ -113,6 +113,23 @@ class ObjectTest < Test::Unit::TestCase
113
113
  assert_equal @sub1[:string], 'ss'
114
114
  end
115
115
 
116
+ def test_xref_name_and_key
117
+ @obj1 = XcodeObject.from 'isa' => 'Alien', 'name' => 'Name',
118
+ 'path' => 'Path'
119
+ @obj2 = XcodeObject.from 'isa' => 'Alien', 'name' => 'Name',
120
+ 'path' => 'Path', 'explicitPath' => 'XPath'
121
+ @obj3 = XcodeObject.from 'isa' => 'Alien', 'path' => 'Path'
122
+ @obj4 = XcodeObject.from 'isa' => 'Alien',
123
+ 'path' => 'Path', 'explicitPath' => 'XPath'
124
+
125
+ assert_equal 'Name', @obj1.xref_name
126
+ assert_equal 'Name', @obj2.xref_name
127
+ assert_equal 'Path', @obj3.xref_name
128
+ assert_equal 'XPath', @obj4.xref_name
129
+
130
+ assert_equal [:Alien, 'Name'], @obj1.xref_key
131
+ end
132
+
116
133
  def test_deep_copy
117
134
  root = XcodeObject.from @root
118
135
  assert_equal root[:sub2][:sub1], root[:sub1], 'Deep copy tracks objects'
@@ -0,0 +1,98 @@
1
+ require 'test/unit'
2
+ require 'test/plugins/test_helper.rb'
3
+
4
+ require 'zerg_xcode'
5
+
6
+ require 'rubygems'
7
+
8
+ module Plugins; end
9
+
10
+ class Plugins::AddlibraryTest < Test::Unit::TestCase
11
+ include Plugins::TestHelper
12
+
13
+ def setup
14
+ super
15
+ @plugin = ZergXcode.plugin 'addlibrary'
16
+ @project = ZergXcode.load 'testdata/ZergSupport'
17
+
18
+ @lib, @test_lib, @test_app = *@project['targets']
19
+ end
20
+
21
+ def test_find_target
22
+ assert_equal @test_lib, @plugin.find_target('ZergTestSupport', @project)
23
+ assert_nil @plugin.find_target('Zergness', @project)
24
+ end
25
+
26
+ def test_has_target_dependency
27
+ [[true, @test_lib, @lib], [false, @lib, @test_lib],
28
+ [true, @test_app, @test_lib], [false, @test_lib, @test_app],
29
+ [false, @test_app, @lib]
30
+ ].each do |scenario|
31
+ assert_equal scenario[0],
32
+ @plugin.has_target_dependency?(scenario[2], scenario[1]),
33
+ "Failed #{scenario[1]['name']} depends on " +
34
+ scenario[2]['name']
35
+ end
36
+ end
37
+
38
+ def test_add_target_dependency
39
+ @plugin.add_target_dependency! @test_lib, @lib, @project
40
+ assert @plugin.has_target_dependency?(@test_lib, @lib),
41
+ "Add failed"
42
+ @plugin.add_target_dependency! @test_app, @lib, @project
43
+ assert @plugin.has_target_dependency?(@test_app, @lib),
44
+ "Add failed"
45
+ end
46
+
47
+ def test_has_target_in_build_phases
48
+ [[true, @test_lib, @lib], [false, @lib, @test_lib],
49
+ [true, @test_app, @test_lib], [false, @test_lib, @test_app],
50
+ [false, @test_app, @lib]
51
+ ].each do |scenario|
52
+ assert_equal scenario[0],
53
+ @plugin.has_target_in_build_phases?(scenario[2],
54
+ scenario[1]),
55
+ "Failed #{scenario[1]['name']} has " +
56
+ scenario[2]['name'] + " in build phases"
57
+ end
58
+ end
59
+
60
+ def test_add_target_to_build_phases
61
+ @plugin.add_target_to_build_phases! @test_lib, @lib
62
+ assert @plugin.has_target_in_build_phases?(@test_lib, @lib),
63
+ "Add failed"
64
+ @plugin.add_target_to_build_phases! @test_app, @lib
65
+ assert @plugin.has_target_in_build_phases?(@test_app, @lib),
66
+ "Add failed"
67
+ end
68
+
69
+ def test_has_objc_files
70
+ assert_equal true, @plugin.has_objc_files?(@lib),
71
+ "ZergSupport has ObjC files"
72
+
73
+ ZergXcode.plugin('retarget').retarget! @project, /\.m$/, []
74
+ assert_equal false, @plugin.has_objc_files?(@lib),
75
+ "ZergSupport doesn't have ObjC files after retargeting"
76
+ end
77
+
78
+ def test_has_linker_option
79
+ assert_equal false, @plugin.has_linker_option?('-ObjC', @lib)
80
+ assert_equal true, @plugin.has_linker_option?('-ObjC', @test_app)
81
+ end
82
+
83
+ def test_add_linker_option
84
+ @plugin.add_linker_option! '-ObjC', @lib
85
+ assert_equal true, @plugin.has_linker_option?('-ObjC', @lib)
86
+ end
87
+
88
+ def test_add_library
89
+ @plugin.add_library! @test_app, @lib, @project
90
+
91
+ assert @plugin.has_target_dependency?(@test_app, @lib),
92
+ "Not on dependency list"
93
+ assert @plugin.has_target_in_build_phases?(@test_app, @lib),
94
+ "Not in build phases"
95
+ assert_equal true, @plugin.has_linker_option?('-ObjC', @lib),
96
+ "Linker option unset"
97
+ end
98
+ end
data/zerg_xcode.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{zerg_xcode}
5
- s.version = "0.2.1"
5
+ s.version = "0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Victor Costan"]
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.description = %q{Automated modifications for Xcode project files}
12
12
  s.email = %q{victor@zergling.net}
13
13
  s.executables = ["zerg-xcode"]
14
- s.extra_rdoc_files = ["bin/zerg-xcode", "CHANGELOG", "lib/zerg_xcode/file_format/archiver.rb", "lib/zerg_xcode/file_format/encoder.rb", "lib/zerg_xcode/file_format/lexer.rb", "lib/zerg_xcode/file_format/parser.rb", "lib/zerg_xcode/file_format/paths.rb", "lib/zerg_xcode/objects/pbx_build_file.rb", "lib/zerg_xcode/objects/pbx_container_item_proxy.rb", "lib/zerg_xcode/objects/pbx_group.rb", "lib/zerg_xcode/objects/pbx_native_target.rb", "lib/zerg_xcode/objects/pbx_project.rb", "lib/zerg_xcode/objects/pbx_target_dependency.rb", "lib/zerg_xcode/objects/xc_configuration_list.rb", "lib/zerg_xcode/objects/xcode_object.rb", "lib/zerg_xcode/plugins/core/core.rb", "lib/zerg_xcode/plugins/help.rb", "lib/zerg_xcode/plugins/import.rb", "lib/zerg_xcode/plugins/irb.rb", "lib/zerg_xcode/plugins/ls.rb", "lib/zerg_xcode/plugins/lstargets.rb", "lib/zerg_xcode/plugins/retarget.rb", "lib/zerg_xcode/shortcuts.rb", "lib/zerg_xcode.rb", "LICENSE", "README.textile"]
15
- s.files = ["bin/zerg-xcode", "CHANGELOG", "lib/zerg_xcode/file_format/archiver.rb", "lib/zerg_xcode/file_format/encoder.rb", "lib/zerg_xcode/file_format/lexer.rb", "lib/zerg_xcode/file_format/parser.rb", "lib/zerg_xcode/file_format/paths.rb", "lib/zerg_xcode/objects/pbx_build_file.rb", "lib/zerg_xcode/objects/pbx_container_item_proxy.rb", "lib/zerg_xcode/objects/pbx_group.rb", "lib/zerg_xcode/objects/pbx_native_target.rb", "lib/zerg_xcode/objects/pbx_project.rb", "lib/zerg_xcode/objects/pbx_target_dependency.rb", "lib/zerg_xcode/objects/xc_configuration_list.rb", "lib/zerg_xcode/objects/xcode_object.rb", "lib/zerg_xcode/plugins/core/core.rb", "lib/zerg_xcode/plugins/help.rb", "lib/zerg_xcode/plugins/import.rb", "lib/zerg_xcode/plugins/irb.rb", "lib/zerg_xcode/plugins/ls.rb", "lib/zerg_xcode/plugins/lstargets.rb", "lib/zerg_xcode/plugins/retarget.rb", "lib/zerg_xcode/shortcuts.rb", "lib/zerg_xcode.rb", "LICENSE", "Manifest", "Rakefile", "README.textile", "RUBYFORGE", "test/file_format/archiver_test.rb", "test/file_format/encoder_test.rb", "test/file_format/lexer_test.rb", "test/file_format/parser_test.rb", "test/file_format/path_test.rb", "test/objects/pbx_build_file_test.rb", "test/objects/pbx_container_item_proxy_test.rb", "test/objects/pbx_group_test.rb", "test/objects/pbx_native_target_test.rb", "test/objects/pbx_project_test.rb", "test/objects/pbx_target_dependency_test.rb", "test/objects/xc_configuration_list_test.rb", "test/objects/xcode_object_test.rb", "test/plugins/core/core_test.rb", "test/plugins/import_test.rb", "test/plugins/irb_test.rb", "test/plugins/ls_test.rb", "test/plugins/lstargets_test.rb", "test/plugins/retarget_test.rb", "test/plugins/test_helper.rb", "test/shortcuts_test.rb", "testdata/FlatTestApp/FlatTestApp.xcodeproj/project.pbxproj", "testdata/project.pbxproj", "testdata/project.pbxproj.compat", "testdata/TestApp/TestApp.xcodeproj/project.pbxproj", "testdata/ZergSupport.xcodeproj/project.pbxproj", "zerg_xcode.gemspec"]
14
+ s.extra_rdoc_files = ["bin/zerg-xcode", "CHANGELOG", "lib/zerg_xcode/file_format/archiver.rb", "lib/zerg_xcode/file_format/encoder.rb", "lib/zerg_xcode/file_format/lexer.rb", "lib/zerg_xcode/file_format/parser.rb", "lib/zerg_xcode/file_format/paths.rb", "lib/zerg_xcode/objects/pbx_build_file.rb", "lib/zerg_xcode/objects/pbx_build_phase.rb", "lib/zerg_xcode/objects/pbx_container_item_proxy.rb", "lib/zerg_xcode/objects/pbx_group.rb", "lib/zerg_xcode/objects/pbx_native_target.rb", "lib/zerg_xcode/objects/pbx_project.rb", "lib/zerg_xcode/objects/pbx_target_dependency.rb", "lib/zerg_xcode/objects/xc_configuration_list.rb", "lib/zerg_xcode/objects/xcode_object.rb", "lib/zerg_xcode/plugins/addlibrary.rb", "lib/zerg_xcode/plugins/core/core.rb", "lib/zerg_xcode/plugins/help.rb", "lib/zerg_xcode/plugins/import.rb", "lib/zerg_xcode/plugins/irb.rb", "lib/zerg_xcode/plugins/ls.rb", "lib/zerg_xcode/plugins/lstargets.rb", "lib/zerg_xcode/plugins/retarget.rb", "lib/zerg_xcode/shortcuts.rb", "lib/zerg_xcode.rb", "LICENSE", "README.textile"]
15
+ s.files = ["bin/zerg-xcode", "CHANGELOG", "lib/zerg_xcode/file_format/archiver.rb", "lib/zerg_xcode/file_format/encoder.rb", "lib/zerg_xcode/file_format/lexer.rb", "lib/zerg_xcode/file_format/parser.rb", "lib/zerg_xcode/file_format/paths.rb", "lib/zerg_xcode/objects/pbx_build_file.rb", "lib/zerg_xcode/objects/pbx_build_phase.rb", "lib/zerg_xcode/objects/pbx_container_item_proxy.rb", "lib/zerg_xcode/objects/pbx_group.rb", "lib/zerg_xcode/objects/pbx_native_target.rb", "lib/zerg_xcode/objects/pbx_project.rb", "lib/zerg_xcode/objects/pbx_target_dependency.rb", "lib/zerg_xcode/objects/xc_configuration_list.rb", "lib/zerg_xcode/objects/xcode_object.rb", "lib/zerg_xcode/plugins/addlibrary.rb", "lib/zerg_xcode/plugins/core/core.rb", "lib/zerg_xcode/plugins/help.rb", "lib/zerg_xcode/plugins/import.rb", "lib/zerg_xcode/plugins/irb.rb", "lib/zerg_xcode/plugins/ls.rb", "lib/zerg_xcode/plugins/lstargets.rb", "lib/zerg_xcode/plugins/retarget.rb", "lib/zerg_xcode/shortcuts.rb", "lib/zerg_xcode.rb", "LICENSE", "Manifest", "Rakefile", "README.textile", "RUBYFORGE", "test/file_format/archiver_test.rb", "test/file_format/encoder_test.rb", "test/file_format/lexer_test.rb", "test/file_format/parser_test.rb", "test/file_format/path_test.rb", "test/objects/pbx_build_file_test.rb", "test/objects/pbx_build_phase_test.rb", "test/objects/pbx_container_item_proxy_test.rb", "test/objects/pbx_group_test.rb", "test/objects/pbx_native_target_test.rb", "test/objects/pbx_project_test.rb", "test/objects/pbx_target_dependency_test.rb", "test/objects/xc_configuration_list_test.rb", "test/objects/xcode_object_test.rb", "test/plugins/core/core_test.rb", "test/plugins/import_test.rb", "test/plugins/irb_test.rb", "test/plugins/ls_test.rb", "test/plugins/lstargets_test.rb", "test/plugins/retarget_test.rb", "test/plugins/test_helper.rb", "test/shortcuts_test.rb", "testdata/FlatTestApp/FlatTestApp.xcodeproj/project.pbxproj", "testdata/project.pbxproj", "testdata/project.pbxproj.compat", "testdata/TestApp/TestApp.xcodeproj/project.pbxproj", "testdata/ZergSupport.xcodeproj/project.pbxproj", "zerg_xcode.gemspec", "test/plugins/addlibrary_test.rb"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://www.zergling.net/}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Zerg_xcode", "--main", "README.textile"]
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.rubyforge_project = %q{zerglings}
21
21
  s.rubygems_version = %q{1.3.1}
22
22
  s.summary = %q{Automated modifications for Xcode project files}
23
- s.test_files = ["test/file_format/archiver_test.rb", "test/file_format/encoder_test.rb", "test/file_format/lexer_test.rb", "test/file_format/parser_test.rb", "test/file_format/path_test.rb", "test/objects/pbx_build_file_test.rb", "test/objects/pbx_container_item_proxy_test.rb", "test/objects/pbx_group_test.rb", "test/objects/pbx_native_target_test.rb", "test/objects/pbx_project_test.rb", "test/objects/pbx_target_dependency_test.rb", "test/objects/xc_configuration_list_test.rb", "test/objects/xcode_object_test.rb", "test/plugins/core/core_test.rb", "test/plugins/import_test.rb", "test/plugins/irb_test.rb", "test/plugins/ls_test.rb", "test/plugins/lstargets_test.rb", "test/plugins/retarget_test.rb", "test/plugins/test_helper.rb", "test/shortcuts_test.rb"]
23
+ s.test_files = ["test/file_format/archiver_test.rb", "test/file_format/encoder_test.rb", "test/file_format/lexer_test.rb", "test/file_format/parser_test.rb", "test/file_format/path_test.rb", "test/objects/pbx_build_file_test.rb", "test/objects/pbx_build_phase_test.rb", "test/objects/pbx_container_item_proxy_test.rb", "test/objects/pbx_group_test.rb", "test/objects/pbx_native_target_test.rb", "test/objects/pbx_project_test.rb", "test/objects/pbx_target_dependency_test.rb", "test/objects/xc_configuration_list_test.rb", "test/objects/xcode_object_test.rb", "test/plugins/addlibrary_test.rb", "test/plugins/core/core_test.rb", "test/plugins/import_test.rb", "test/plugins/irb_test.rb", "test/plugins/ls_test.rb", "test/plugins/lstargets_test.rb", "test/plugins/retarget_test.rb", "test/plugins/test_helper.rb", "test/shortcuts_test.rb"]
24
24
 
25
25
  if s.respond_to? :specification_version then
26
26
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zerg_xcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
@@ -28,6 +28,7 @@ extra_rdoc_files:
28
28
  - lib/zerg_xcode/file_format/parser.rb
29
29
  - lib/zerg_xcode/file_format/paths.rb
30
30
  - lib/zerg_xcode/objects/pbx_build_file.rb
31
+ - lib/zerg_xcode/objects/pbx_build_phase.rb
31
32
  - lib/zerg_xcode/objects/pbx_container_item_proxy.rb
32
33
  - lib/zerg_xcode/objects/pbx_group.rb
33
34
  - lib/zerg_xcode/objects/pbx_native_target.rb
@@ -35,6 +36,7 @@ extra_rdoc_files:
35
36
  - lib/zerg_xcode/objects/pbx_target_dependency.rb
36
37
  - lib/zerg_xcode/objects/xc_configuration_list.rb
37
38
  - lib/zerg_xcode/objects/xcode_object.rb
39
+ - lib/zerg_xcode/plugins/addlibrary.rb
38
40
  - lib/zerg_xcode/plugins/core/core.rb
39
41
  - lib/zerg_xcode/plugins/help.rb
40
42
  - lib/zerg_xcode/plugins/import.rb
@@ -55,6 +57,7 @@ files:
55
57
  - lib/zerg_xcode/file_format/parser.rb
56
58
  - lib/zerg_xcode/file_format/paths.rb
57
59
  - lib/zerg_xcode/objects/pbx_build_file.rb
60
+ - lib/zerg_xcode/objects/pbx_build_phase.rb
58
61
  - lib/zerg_xcode/objects/pbx_container_item_proxy.rb
59
62
  - lib/zerg_xcode/objects/pbx_group.rb
60
63
  - lib/zerg_xcode/objects/pbx_native_target.rb
@@ -62,6 +65,7 @@ files:
62
65
  - lib/zerg_xcode/objects/pbx_target_dependency.rb
63
66
  - lib/zerg_xcode/objects/xc_configuration_list.rb
64
67
  - lib/zerg_xcode/objects/xcode_object.rb
68
+ - lib/zerg_xcode/plugins/addlibrary.rb
65
69
  - lib/zerg_xcode/plugins/core/core.rb
66
70
  - lib/zerg_xcode/plugins/help.rb
67
71
  - lib/zerg_xcode/plugins/import.rb
@@ -82,6 +86,7 @@ files:
82
86
  - test/file_format/parser_test.rb
83
87
  - test/file_format/path_test.rb
84
88
  - test/objects/pbx_build_file_test.rb
89
+ - test/objects/pbx_build_phase_test.rb
85
90
  - test/objects/pbx_container_item_proxy_test.rb
86
91
  - test/objects/pbx_group_test.rb
87
92
  - test/objects/pbx_native_target_test.rb
@@ -141,6 +146,7 @@ test_files:
141
146
  - test/file_format/parser_test.rb
142
147
  - test/file_format/path_test.rb
143
148
  - test/objects/pbx_build_file_test.rb
149
+ - test/objects/pbx_build_phase_test.rb
144
150
  - test/objects/pbx_container_item_proxy_test.rb
145
151
  - test/objects/pbx_group_test.rb
146
152
  - test/objects/pbx_native_target_test.rb
@@ -148,6 +154,7 @@ test_files:
148
154
  - test/objects/pbx_target_dependency_test.rb
149
155
  - test/objects/xc_configuration_list_test.rb
150
156
  - test/objects/xcode_object_test.rb
157
+ - test/plugins/addlibrary_test.rb
151
158
  - test/plugins/core/core_test.rb
152
159
  - test/plugins/import_test.rb
153
160
  - test/plugins/irb_test.rb