xcodeproject 0.1.1
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.
- data/.gitignore +32 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +14 -0
- data/lib/xcodeproject/build_phase_node.rb +87 -0
- data/lib/xcodeproject/data.rb +87 -0
- data/lib/xcodeproject/exceptions.rb +5 -0
- data/lib/xcodeproject/extend/array.rb +8 -0
- data/lib/xcodeproject/extend/hash.rb +11 -0
- data/lib/xcodeproject/extend/string.rb +7 -0
- data/lib/xcodeproject/file_node.rb +63 -0
- data/lib/xcodeproject/formatter.rb +23 -0
- data/lib/xcodeproject/node.rb +15 -0
- data/lib/xcodeproject/pbx_build_file.rb +37 -0
- data/lib/xcodeproject/pbx_file_reference.rb +53 -0
- data/lib/xcodeproject/pbx_group.rb +169 -0
- data/lib/xcodeproject/pbx_native_target.rb +70 -0
- data/lib/xcodeproject/pbx_project.rb +33 -0
- data/lib/xcodeproject/project.rb +70 -0
- data/lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.h +1 -0
- data/lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.m +1 -0
- data/lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.h +1 -0
- data/lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.m +1 -0
- data/lib/xcodeproject/resources/example/dir1b/dir2b/file3b.m +0 -0
- data/lib/xcodeproject/resources/example/dir1b/file2b.m +0 -0
- data/lib/xcodeproject/resources/example/dir1c/file2c.h +0 -0
- data/lib/xcodeproject/resources/example/dir1c/file2c.m +0 -0
- data/lib/xcodeproject/resources/example/example/AppDelegate.h +15 -0
- data/lib/xcodeproject/resources/example/example/AppDelegate.m +57 -0
- data/lib/xcodeproject/resources/example/example/en.lproj/InfoPlist.strings +2 -0
- data/lib/xcodeproject/resources/example/example/example-Info.plist +45 -0
- data/lib/xcodeproject/resources/example/example/example-Prefix.pch +14 -0
- data/lib/xcodeproject/resources/example/example/main.m +18 -0
- data/lib/xcodeproject/resources/example/example.xcodeproj/project.pbxproj +324 -0
- data/lib/xcodeproject/root_node.rb +117 -0
- data/lib/xcodeproject/spec/build_phase_node_spec.rb +95 -0
- data/lib/xcodeproject/spec/file_node_spec.rb +83 -0
- data/lib/xcodeproject/spec/pbx_build_file_spec.rb +25 -0
- data/lib/xcodeproject/spec/pbx_file_reference_spec.rb +34 -0
- data/lib/xcodeproject/spec/pbx_group_spec.rb +274 -0
- data/lib/xcodeproject/spec/pbx_native_target_spec.rb +58 -0
- data/lib/xcodeproject/spec/pbx_project_spec.rb +34 -0
- data/lib/xcodeproject/spec/project_spec.rb +79 -0
- data/lib/xcodeproject/spec/spec_helper.rb +45 -0
- data/lib/xcodeproject/spec/xc_configuration_list_spec.rb +20 -0
- data/lib/xcodeproject/uuid_generator.rb +13 -0
- data/lib/xcodeproject/version.rb +3 -0
- data/lib/xcodeproject/xc_build_configuration.rb +15 -0
- data/lib/xcodeproject/xc_configuration_list.rb +23 -0
- data/lib/xcodeproject.rb +3 -0
- data/rakefile +3 -0
- data/xcodeproject.gemspec +26 -0
- metadata +166 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe XCodeProject::PBXProject do
|
4
|
+
before(:each) { @data = prepare_example_project.read }
|
5
|
+
let(:obj) { @data.project }
|
6
|
+
|
7
|
+
describe "#targets" do
|
8
|
+
it "returns the array of target objects" do
|
9
|
+
targets = obj.targets
|
10
|
+
targets.should be_an_instance_of(Array)
|
11
|
+
targets.each {|obj| obj.should be_an_instance_of(XCodeProject::PBXNativeTarget) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#target" do
|
16
|
+
context "if the target exists" do
|
17
|
+
it "returns the object" do
|
18
|
+
obj.target('example').should be_an_instance_of(XCodeProject::PBXNativeTarget)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
context "if the target doesn't exist" do
|
22
|
+
it "returns nil" do
|
23
|
+
obj.target('ghost-target').should be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#main_group" do
|
29
|
+
it "returns the main group object" do
|
30
|
+
obj.main_group.should be_an_instance_of(XCodeProject::PBXGroup)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe XCodeProject::Project do
|
4
|
+
let(:proj) { prepare_example_project }
|
5
|
+
|
6
|
+
describe "#new" do
|
7
|
+
context "if the project file exists" do
|
8
|
+
it "constructs an project object" do
|
9
|
+
XCodeProject::Project.new(example_project_bundle_path).should be_an_instance_of(XCodeProject::Project)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "if the project file doesn't exist" do
|
14
|
+
let(:proj_ne) { "#{example_empty_sandbox_path}/ghost.xcodeproj" }
|
15
|
+
it "trows the exception" do
|
16
|
+
lambda { XCodeProject::Project.new(proj_ne) }.should raise_exception(XCodeProject::FilePathError)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#file_path" do
|
22
|
+
it "returns the project's file path" do
|
23
|
+
proj.file_path.should eql(example_project_file_path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#bundle_path" do
|
28
|
+
it "returns the project's bundle path" do
|
29
|
+
proj.bundle_path.should eql(example_project_bundle_path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#find_projs" do
|
34
|
+
context "if a path contains project files" do
|
35
|
+
it "returns an array of project objects" do
|
36
|
+
projs = XCodeProject::Project.find_projs(example_sandbox_path)
|
37
|
+
projs.size.should eql(1)
|
38
|
+
projs.first.bundle_path.should eql(proj.bundle_path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "if a path doesn't contain project files" do
|
43
|
+
it "returns an empty array" do
|
44
|
+
projs = XCodeProject::Project.find_projs(example_empty_sandbox_path)
|
45
|
+
projs.size.should eql(0)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#read" do
|
51
|
+
it "returns the data object" do
|
52
|
+
proj.read.should be_an_instance_of(XCodeProject::Data)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "reads the project file" do
|
56
|
+
mock.proxy(proj).file_path
|
57
|
+
proj.read
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#write" do
|
62
|
+
it "writes the project file" do
|
63
|
+
data = proj.read
|
64
|
+
|
65
|
+
mock.proxy(proj).file_path
|
66
|
+
proj.write(data)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#change" do
|
71
|
+
it "reads the file file and then writes it" do
|
72
|
+
proj_mock = mock.proxy(proj)
|
73
|
+
proj_mock.read
|
74
|
+
proj_mock.write(is_a(XCodeProject::Data))
|
75
|
+
proj.change {|data| }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Example proj file hierarhy
|
3
|
+
#
|
4
|
+
# main
|
5
|
+
# \--group1a
|
6
|
+
# |--group2a
|
7
|
+
# |--dir2c
|
8
|
+
# | \--dir3a
|
9
|
+
# | \--dir4a
|
10
|
+
# | |--file5a-a.m
|
11
|
+
# | |--file5a-a.h
|
12
|
+
# | |--file5a-r.m
|
13
|
+
# | \--file5a-r.h
|
14
|
+
# |
|
15
|
+
# |--file2c.m
|
16
|
+
# \--file2c.h
|
17
|
+
|
18
|
+
require 'xcodeproject/project'
|
19
|
+
require 'xcodeproject/exceptions'
|
20
|
+
require 'rr'
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.mock_with :rr
|
24
|
+
end
|
25
|
+
|
26
|
+
def prepare_sandbox
|
27
|
+
%x{ mkdir -p #{example_sandbox_path} } unless File.exist?(example_sandbox_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def prepare_example_project
|
31
|
+
prepare_sandbox
|
32
|
+
|
33
|
+
proj_source_dir = "#{File.dirname(__FILE__)}/../resources/example"
|
34
|
+
%x{ rm -vr #{example_project_dir} }
|
35
|
+
%x{ cp -vr #{proj_source_dir} #{example_sandbox_path} }
|
36
|
+
|
37
|
+
XCodeProject::Project.new(example_project_bundle_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def example_sandbox_path; Pathname.new('/tmp/example_sandbox') end
|
41
|
+
def example_empty_sandbox_path; Pathname.new('/tmp/example_sandbox_empty') end
|
42
|
+
def example_project_dir; example_sandbox_path.join('example') end
|
43
|
+
def example_project_bundle_path; example_project_dir.join('example.xcodeproj') end
|
44
|
+
def example_project_file_path; example_project_bundle_path.join('project.pbxproj') end
|
45
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe XCodeProject::XCConfigurationList do
|
4
|
+
before(:each) { @data = prepare_example_project.read }
|
5
|
+
let(:obj) { obj = @data.target('example').build_configurations_list }
|
6
|
+
|
7
|
+
describe "#build_configuration" do
|
8
|
+
let(:name) { 'Release' }
|
9
|
+
|
10
|
+
it "returns build configuration object" do
|
11
|
+
obj.build_configuration(name).should be_an_instance_of(XCodeProject::XCBuildConfiguration)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#build_configurations" do
|
16
|
+
it "returns an array of build configuration objects" do
|
17
|
+
obj.build_configurations.should be_an_instance_of(Array)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'xcodeproject/node'
|
2
|
+
|
3
|
+
module XCodeProject
|
4
|
+
class XCBuildConfiguration < Node
|
5
|
+
attr_reader :name
|
6
|
+
attr_accessor :build_settings
|
7
|
+
|
8
|
+
def initialize (root, uuid, data)
|
9
|
+
super(root, uuid, data)
|
10
|
+
|
11
|
+
@name = data['name']
|
12
|
+
@build_settings = data['buildSettings']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'xcodeproject/node'
|
2
|
+
|
3
|
+
module XCodeProject
|
4
|
+
class XCConfigurationList < Node
|
5
|
+
attr_reader :default_configuration_name
|
6
|
+
attr_reader :default_configuration_is_visible
|
7
|
+
|
8
|
+
def initialize (root, uuid, data)
|
9
|
+
super(root, uuid, data)
|
10
|
+
|
11
|
+
@default_configuration_name = data['defaultConfigurationName']
|
12
|
+
@default_configuration_is_visible = data['defaultConfigurationIsVisible']
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_configuration (name)
|
16
|
+
build_configurations.select {|obj| obj.name == name }.first
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_configurations
|
20
|
+
data['buildConfigurations'].map {|uuid| root.object!(uuid) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/xcodeproject.rb
ADDED
data/rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/xcodeproject/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'xcodeproject'
|
6
|
+
gem.version = Xcodeproject::VERSION
|
7
|
+
gem.summary = 'Read, write and build xcode projects'
|
8
|
+
gem.description = 'XCodeProject is Ruby API for working with Xcode project files'
|
9
|
+
gem.author = 'Andrey Nesterov'
|
10
|
+
gem.email = 'ae.nesterov@gmail.com'
|
11
|
+
gem.homepage = 'https://github.com/manifest/xcodeproject'
|
12
|
+
gem.rubyforge_project = 'xcodeproject'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.required_ruby_version = '>= 1.8.7'
|
21
|
+
gem.add_runtime_dependency 'json', '~> 1.7'
|
22
|
+
gem.add_runtime_dependency 'uuid', '~> 2.3'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.10'
|
24
|
+
gem.add_development_dependency 'rr', '~> 1.0'
|
25
|
+
end
|
26
|
+
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xcodeproject
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Andrey Nesterov
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-06-13 00:00:00 +04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: json
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 7
|
30
|
+
version: "1.7"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: uuid
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 2
|
42
|
+
- 3
|
43
|
+
version: "2.3"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 2
|
55
|
+
- 10
|
56
|
+
version: "2.10"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rr
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 1
|
68
|
+
- 0
|
69
|
+
version: "1.0"
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id004
|
72
|
+
description: XCodeProject is Ruby API for working with Xcode project files
|
73
|
+
email: ae.nesterov@gmail.com
|
74
|
+
executables: []
|
75
|
+
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files: []
|
79
|
+
|
80
|
+
files:
|
81
|
+
- .gitignore
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- lib/xcodeproject.rb
|
86
|
+
- lib/xcodeproject/build_phase_node.rb
|
87
|
+
- lib/xcodeproject/data.rb
|
88
|
+
- lib/xcodeproject/exceptions.rb
|
89
|
+
- lib/xcodeproject/extend/array.rb
|
90
|
+
- lib/xcodeproject/extend/hash.rb
|
91
|
+
- lib/xcodeproject/extend/string.rb
|
92
|
+
- lib/xcodeproject/file_node.rb
|
93
|
+
- lib/xcodeproject/formatter.rb
|
94
|
+
- lib/xcodeproject/node.rb
|
95
|
+
- lib/xcodeproject/pbx_build_file.rb
|
96
|
+
- lib/xcodeproject/pbx_file_reference.rb
|
97
|
+
- lib/xcodeproject/pbx_group.rb
|
98
|
+
- lib/xcodeproject/pbx_native_target.rb
|
99
|
+
- lib/xcodeproject/pbx_project.rb
|
100
|
+
- lib/xcodeproject/project.rb
|
101
|
+
- lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.h
|
102
|
+
- lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-a.m
|
103
|
+
- lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.h
|
104
|
+
- lib/xcodeproject/resources/example/dir1a/dir2a/dir3a/dir4a/file5a-r.m
|
105
|
+
- lib/xcodeproject/resources/example/dir1b/dir2b/file3b.m
|
106
|
+
- lib/xcodeproject/resources/example/dir1b/file2b.m
|
107
|
+
- lib/xcodeproject/resources/example/dir1c/file2c.h
|
108
|
+
- lib/xcodeproject/resources/example/dir1c/file2c.m
|
109
|
+
- lib/xcodeproject/resources/example/example.xcodeproj/project.pbxproj
|
110
|
+
- lib/xcodeproject/resources/example/example/AppDelegate.h
|
111
|
+
- lib/xcodeproject/resources/example/example/AppDelegate.m
|
112
|
+
- lib/xcodeproject/resources/example/example/en.lproj/InfoPlist.strings
|
113
|
+
- lib/xcodeproject/resources/example/example/example-Info.plist
|
114
|
+
- lib/xcodeproject/resources/example/example/example-Prefix.pch
|
115
|
+
- lib/xcodeproject/resources/example/example/main.m
|
116
|
+
- lib/xcodeproject/root_node.rb
|
117
|
+
- lib/xcodeproject/spec/build_phase_node_spec.rb
|
118
|
+
- lib/xcodeproject/spec/file_node_spec.rb
|
119
|
+
- lib/xcodeproject/spec/pbx_build_file_spec.rb
|
120
|
+
- lib/xcodeproject/spec/pbx_file_reference_spec.rb
|
121
|
+
- lib/xcodeproject/spec/pbx_group_spec.rb
|
122
|
+
- lib/xcodeproject/spec/pbx_native_target_spec.rb
|
123
|
+
- lib/xcodeproject/spec/pbx_project_spec.rb
|
124
|
+
- lib/xcodeproject/spec/project_spec.rb
|
125
|
+
- lib/xcodeproject/spec/spec_helper.rb
|
126
|
+
- lib/xcodeproject/spec/xc_configuration_list_spec.rb
|
127
|
+
- lib/xcodeproject/uuid_generator.rb
|
128
|
+
- lib/xcodeproject/version.rb
|
129
|
+
- lib/xcodeproject/xc_build_configuration.rb
|
130
|
+
- lib/xcodeproject/xc_configuration_list.rb
|
131
|
+
- rakefile
|
132
|
+
- xcodeproject.gemspec
|
133
|
+
has_rdoc: true
|
134
|
+
homepage: https://github.com/manifest/xcodeproject
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
segments:
|
147
|
+
- 1
|
148
|
+
- 8
|
149
|
+
- 7
|
150
|
+
version: 1.8.7
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
version: "0"
|
158
|
+
requirements: []
|
159
|
+
|
160
|
+
rubyforge_project: xcodeproject
|
161
|
+
rubygems_version: 1.3.6
|
162
|
+
signing_key:
|
163
|
+
specification_version: 3
|
164
|
+
summary: Read, write and build xcode projects
|
165
|
+
test_files: []
|
166
|
+
|