xcodeproj 0.3.5 → 0.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/bin/xcodeproj +13 -0
  2. data/lib/xcodeproj.rb +13 -1
  3. data/lib/xcodeproj/command.rb +131 -0
  4. data/lib/xcodeproj/command/project_diff.rb +53 -0
  5. data/lib/xcodeproj/command/show.rb +35 -0
  6. data/lib/xcodeproj/command/target_diff.rb +43 -0
  7. data/lib/xcodeproj/config.rb +66 -38
  8. data/lib/xcodeproj/constants.rb +146 -0
  9. data/lib/xcodeproj/helper.rb +28 -0
  10. data/lib/xcodeproj/project.rb +462 -156
  11. data/lib/xcodeproj/project/object.rb +251 -138
  12. data/lib/xcodeproj/project/object/build_configuration.rb +27 -0
  13. data/lib/xcodeproj/project/object/build_file.rb +26 -0
  14. data/lib/xcodeproj/project/object/build_phase.rb +132 -61
  15. data/lib/xcodeproj/project/object/build_rule.rb +46 -0
  16. data/lib/xcodeproj/project/object/configuration_list.rb +47 -0
  17. data/lib/xcodeproj/project/object/container_item_proxy.rb +49 -0
  18. data/lib/xcodeproj/project/object/file_reference.rb +80 -48
  19. data/lib/xcodeproj/project/object/group.rb +213 -89
  20. data/lib/xcodeproj/project/object/native_target.rb +171 -114
  21. data/lib/xcodeproj/project/object/root_object.rb +66 -0
  22. data/lib/xcodeproj/project/object/target_dependency.rb +23 -0
  23. data/lib/xcodeproj/project/object_attributes.rb +382 -0
  24. data/lib/xcodeproj/project/object_list.rb +64 -118
  25. data/lib/xcodeproj/project/recursive_diff.rb +116 -0
  26. data/lib/xcodeproj/workspace.rb +56 -2
  27. metadata +38 -10
  28. data/lib/xcodeproj/project/association.rb +0 -54
  29. data/lib/xcodeproj/project/association/has_many.rb +0 -51
  30. data/lib/xcodeproj/project/association/has_one.rb +0 -39
  31. data/lib/xcodeproj/project/association/reflection.rb +0 -86
  32. data/lib/xcodeproj/project/object/configuration.rb +0 -97
@@ -1,54 +0,0 @@
1
- require 'xcodeproj/project/association/has_many'
2
- require 'xcodeproj/project/association/has_one'
3
- require 'xcodeproj/project/association/reflection'
4
-
5
- module Xcodeproj
6
- class Project
7
- module Object
8
-
9
- class AbstractPBXObject
10
- class << self
11
- def has_many(plural_attr_name, options = {}, &block)
12
- create_association(:has_many, plural_attr_name, options, &block)
13
- end
14
-
15
- def has_one(singular_attr_name, options = {})
16
- create_association(:has_one, singular_attr_name, options)
17
- end
18
-
19
- private
20
-
21
- def create_association(type, name, options, &block)
22
- reflection = create_reflection(type, name, options)
23
- unless reflection.inverse?
24
- attribute(reflection.attribute_name, :as => reflection.attribute_getter)
25
- end
26
- define_method(reflection.getter) do
27
- reflection.association_for(self, &block).get
28
- end
29
- define_method(reflection.setter) do |new_value|
30
- reflection.association_for(self, &block).set(new_value)
31
- end
32
- end
33
- end
34
- end
35
-
36
- class Association
37
- attr_reader :owner, :reflection
38
-
39
- def initialize(owner, reflection, &block)
40
- @owner, @reflection, @block = owner, reflection, block
41
- end
42
-
43
- def get
44
- @reflection.inverse? ? inverse_get : direct_get
45
- end
46
-
47
- def set(value)
48
- @reflection.inverse? ? inverse_set(value) : direct_set(value)
49
- end
50
- end
51
-
52
- end
53
- end
54
- end
@@ -1,51 +0,0 @@
1
- module Xcodeproj
2
- class Project
3
- module Object
4
- class Association
5
-
6
- class HasMany < Association
7
- def direct_get
8
- uuids = @owner.send(@reflection.attribute_getter)
9
- if @block
10
- # Evaluate the block, which was specified at the class level, in
11
- # the instance’s context.
12
- @owner.list_by_class(uuids, @reflection.klass) do |list|
13
- list.let(:push) do |new_object|
14
- @owner.instance_exec(new_object, &@block)
15
- end
16
- end
17
- else
18
- @owner.list_by_class(uuids, @reflection.klass)
19
- end
20
- end
21
-
22
- def inverse_get
23
- PBXObjectList.new(@reflection.klass, @owner.project) do |list|
24
- list.let(:uuid_scope) do
25
- @owner.project.objects.list_by_class(@reflection.klass).select do |object|
26
- object.send(@reflection.inverse.attribute_getter) == @owner.uuid
27
- end.map(&:uuid)
28
- end
29
- list.let(:push) do |new_object|
30
- new_object.send(@reflection.inverse.attribute_setter, @owner.uuid)
31
- end
32
- end
33
- end
34
-
35
- # @todo Currently this does not call the @block, which means that
36
- # in theory (like with a group's children) the object stays
37
- # asociated with its old group.
38
- def direct_set(list)
39
- @owner.send(@reflection.attribute_setter, list.map(&:uuid))
40
- end
41
-
42
- def inverse_set(list)
43
- raise NotImplementedError
44
- end
45
- end
46
-
47
- end
48
- end
49
- end
50
- end
51
-
@@ -1,39 +0,0 @@
1
- module Xcodeproj
2
- class Project
3
- module Object
4
- class Association
5
-
6
- # @todo Does this need 'new object'-callback support too?
7
- class HasOne < Association
8
- def direct_get
9
- @owner.project.objects[@owner.send(@reflection.attribute_getter)]
10
- end
11
-
12
- def inverse_get
13
- # Loop over all objects of the class and find the one that includes
14
- # this object in the specified uuid list.
15
- @owner.project.objects.list_by_class(@reflection.klass).find do |object|
16
- object.send(@reflection.inverse.attribute_getter).include?(@owner.uuid)
17
- end
18
- end
19
-
20
- def direct_set(object)
21
- @owner.send(@reflection.attribute_setter, object.uuid)
22
- end
23
-
24
- def inverse_set(object)
25
- # Remove this object from the uuid list of the target
26
- # that this object was associated to.
27
- if previous = @owner.send(@reflection.name)
28
- previous.send(@reflection.inverse.attribute_getter).delete(@owner.uuid)
29
- end
30
- # Now assign this object to the new object
31
- object.send(@reflection.inverse.attribute_getter) << @owner.uuid if object
32
- end
33
- end
34
-
35
- end
36
- end
37
- end
38
- end
39
-
@@ -1,86 +0,0 @@
1
- module Xcodeproj
2
- class Project
3
- module Object
4
-
5
- class AbstractPBXObject
6
- def self.reflections
7
- @reflections ||= []
8
- end
9
-
10
- def self.create_reflection(type, name, options)
11
- (reflections << Association::Reflection.new(type, name, options)).last
12
- end
13
-
14
- def self.reflection(name)
15
- reflections.find { |r| r.name.to_s == name.to_s }
16
- end
17
- end
18
-
19
- class Association
20
- class Reflection
21
- def initialize(type, name, options)
22
- @type, @name, @options = type, name.to_s, options
23
- end
24
-
25
- attr_reader :type, :name, :options
26
-
27
- def klass
28
- @options[:class] ||= begin
29
- name = "PBX#{@name.classify}"
30
- name = "XC#{@name.classify}" unless Xcodeproj::Project::Object.const_defined?(name)
31
- Xcodeproj::Project::Object.const_get(name)
32
- end
33
- end
34
-
35
- def inverse
36
- klass.reflection(@options[:inverse_of])
37
- end
38
-
39
- def inverse?
40
- !!@options[:inverse_of]
41
- end
42
-
43
- def attribute_name
44
- (@options[:uuid] || @options[:uuids] || @name).to_sym
45
- end
46
-
47
- def attribute_getter
48
- case type
49
- when :has_many
50
- uuid_method_name.pluralize
51
- when :has_one
52
- uuid_method_name
53
- end.to_sym
54
- end
55
-
56
- def attribute_setter
57
- "#{attribute_getter}=".to_sym
58
- end
59
-
60
- def getter
61
- @name.to_sym
62
- end
63
-
64
- def setter
65
- "#{@name}=".to_sym
66
- end
67
-
68
- def association_for(owner, &block)
69
- case type
70
- when :has_many then Association::HasMany
71
- when :has_one then Association::HasOne
72
- end.new(owner, self, &block)
73
- end
74
-
75
- private
76
-
77
- def uuid_method_name
78
- (@options[:uuids_as] || @options[:uuid] || @options[:uuids] || "#{@name.singularize}_reference").to_s.singularize
79
- end
80
- end
81
-
82
- end
83
-
84
- end
85
- end
86
- end
@@ -1,97 +0,0 @@
1
- module Xcodeproj
2
- class Project
3
- module Object
4
-
5
- class XCBuildConfiguration < AbstractPBXObject
6
- COMMON_BUILD_SETTINGS = {
7
- :all => {
8
- 'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0',
9
- 'GCC_PRECOMPILE_PREFIX_HEADER' => 'YES',
10
- 'PRODUCT_NAME' => '$(TARGET_NAME)',
11
- 'SKIP_INSTALL' => 'YES',
12
- 'DSTROOT' => '/tmp/xcodeproj.dst',
13
- 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
14
- 'GCC_C_LANGUAGE_STANDARD' => 'gnu99',
15
- 'INSTALL_PATH' => "$(BUILT_PRODUCTS_DIR)",
16
- 'OTHER_LDFLAGS' => '',
17
- 'COPY_PHASE_STRIP' => 'YES',
18
- }.freeze,
19
- :debug => {
20
- 'GCC_DYNAMIC_NO_PIC' => 'NO',
21
- 'GCC_PREPROCESSOR_DEFINITIONS' => ["DEBUG=1", "$(inherited)"],
22
- 'GCC_SYMBOLS_PRIVATE_EXTERN' => 'NO',
23
- 'GCC_OPTIMIZATION_LEVEL' => '0',
24
- 'COPY_PHASE_STRIP' => 'NO',
25
- }.freeze,
26
- :ios => {
27
- 'ARCHS' => "$(ARCHS_STANDARD_32_BIT)",
28
- 'IPHONEOS_DEPLOYMENT_TARGET' => '4.3',
29
- 'PUBLIC_HEADERS_FOLDER_PATH' => "$(TARGET_NAME)",
30
- 'SDKROOT' => 'iphoneos',
31
- }.freeze,
32
- :osx => {
33
- 'ARCHS' => "$(ARCHS_STANDARD_64_BIT)",
34
- 'GCC_ENABLE_OBJC_EXCEPTIONS' => 'YES',
35
- 'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0',
36
- 'MACOSX_DEPLOYMENT_TARGET' => '10.7',
37
- 'SDKROOT' => 'macosx',
38
- 'COMBINE_HIDPI_IMAGES' => 'YES',
39
- }.freeze,
40
- [:osx, :debug] => {
41
- 'ONLY_ACTIVE_ARCH' => 'YES',
42
- }.freeze,
43
- [:osx, :release] => {
44
- 'DEBUG_INFORMATION_FORMAT' => 'dwarf-with-dsym',
45
- }.freeze,
46
- [:ios, :release] => {
47
- 'VALIDATE_PRODUCT' => 'YES',
48
- }.freeze,
49
- }.freeze
50
-
51
- def self.new_release(project)
52
- new(project, nil,
53
- 'name' => 'Release',
54
- 'buildSettings' => COMMON_BUILD_SETTINGS[:all].dup
55
- )
56
- end
57
-
58
- def self.new_debug(project)
59
- new(project, nil,
60
- 'name' => 'Debug',
61
- 'buildSettings' => COMMON_BUILD_SETTINGS[:all].merge(COMMON_BUILD_SETTINGS[:debug])
62
- )
63
- end
64
-
65
- # [Hash] the build settings used when building a target
66
- attribute :build_settings
67
-
68
- # TODO why do I need to specify the uuid here?
69
- has_one :base_configuration, :uuid => :base_configuration_reference
70
-
71
- def initialize(*)
72
- super
73
- self.build_settings ||= {}
74
- end
75
- end
76
-
77
- class XCConfigurationList < AbstractPBXObject
78
- attribute :default_configuration_is_visible
79
- attribute :default_configuration_name
80
-
81
- has_many :build_configurations
82
-
83
- def initialize(*)
84
- super
85
- self.build_configuration_references ||= []
86
- end
87
-
88
- def build_settings(build_configuration_name)
89
- if config = build_configurations.where(:name => build_configuration_name)
90
- config.build_settings
91
- end
92
- end
93
- end
94
-
95
- end
96
- end
97
- end