cocoapods 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,82 @@
1
+ module Pod
2
+ class Specification
3
+ class Set
4
+ def self.sets
5
+ @sets ||= {}
6
+ end
7
+
8
+ def self.by_specification_name(name)
9
+ sets[name]
10
+ end
11
+
12
+ # This keeps an identity map of sets so that you always get the same Set
13
+ # instance for the same pod directory.
14
+ def self.by_pod_dir(pod_dir)
15
+ set = new(pod_dir)
16
+ sets[set.name] ||= set
17
+ sets[set.name]
18
+ end
19
+
20
+ attr_reader :pod_dir
21
+
22
+ def initialize(pod_dir)
23
+ @pod_dir = pod_dir
24
+ @required_by = []
25
+ end
26
+
27
+ def required_by(specification)
28
+ dependency = specification.dependency_by_name(name)
29
+ unless @required_by.empty? || dependency.requirement.satisfied_by?(required_version)
30
+ # TODO add graph that shows which dependencies led to this.
31
+ raise Informative, "#{specification} tries to activate `#{dependency}', " \
32
+ "but already activated version `#{required_version}' " \
33
+ "by #{@required_by.join(', ')}."
34
+ end
35
+ @required_by << specification
36
+ end
37
+
38
+ def dependency
39
+ @required_by.inject(Dependency.new(name)) do |previous, spec|
40
+ previous.merge(spec.dependency_by_name(name))
41
+ end
42
+ end
43
+
44
+ def only_part_of_other_pod?
45
+ @required_by.all? { |spec| spec.dependency_by_name(name).only_part_of_other_pod? }
46
+ end
47
+
48
+ def name
49
+ @pod_dir.basename.to_s
50
+ end
51
+
52
+ def specification_path
53
+ @pod_dir + required_version.to_s + "#{name}.podspec"
54
+ end
55
+
56
+ def specification
57
+ Specification.from_podspec(specification_path)
58
+ end
59
+
60
+ # Return the first version that matches the current dependency.
61
+ def required_version
62
+ versions.find { |v| dependency.match?(name, v) } ||
63
+ raise(Informative, "Required version (#{dependency}) not found for `#{name}'.")
64
+ end
65
+
66
+ def ==(other)
67
+ self.class === other && @pod_dir == other.pod_dir
68
+ end
69
+
70
+ def to_s
71
+ "#<#{self.class.name} for `#{name}' with required version `#{required_version}'>"
72
+ end
73
+ alias_method :inspect, :to_s
74
+
75
+ # Returns Pod::Version instances, for each version directory, sorted from
76
+ # highest version to lowest.
77
+ def versions
78
+ @pod_dir.children.map { |v| Version.new(v.basename) }.sort.reverse
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ module Gem
2
+ end
3
+ require 'rubygems/version'
4
+
5
+ module Pod
6
+ class Version < Gem::Version
7
+ end
8
+ end
9
+
@@ -0,0 +1,33 @@
1
+ module Pod
2
+ module Xcode
3
+ class Config
4
+ def initialize(xcconfig_hash = {})
5
+ @attributes = {}
6
+ merge!(xcconfig_hash)
7
+ end
8
+
9
+ def to_hash
10
+ @attributes
11
+ end
12
+
13
+ def merge!(xcconfig_hash)
14
+ xcconfig_hash.each do |key, value|
15
+ if existing_value = @attributes[key]
16
+ @attributes[key] = "#{existing_value} #{value}"
17
+ else
18
+ @attributes[key] = value
19
+ end
20
+ end
21
+ end
22
+ alias_method :<<, :merge!
23
+
24
+ def to_s
25
+ @attributes.map { |key, value| "#{key} = #{value}" }.join("\n")
26
+ end
27
+
28
+ def create_in(pods_root)
29
+ (pods_root + 'Pods.xcconfig').open('w') { |file| file << to_s }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,132 @@
1
+ framework 'Foundation'
2
+
3
+ module Pod
4
+ module Xcode
5
+ class Project
6
+ # TODO this is a workaround for an issue with MacRuby with compiled files
7
+ # that makes the use of __FILE__ impossible.
8
+ #
9
+ #TEMPLATES_DIR = Pathname.new(File.expand_path('../../../../xcode-project-templates', __FILE__))
10
+ file = $LOADED_FEATURES.find { |file| file =~ %r{cocoapods/xcode/project\.rbo?$} }
11
+ TEMPLATES_DIR = Pathname.new(File.expand_path('../../../../xcode-project-templates', file))
12
+
13
+ # TODO see if we really need different templates for iOS and OS X
14
+ def self.ios_static_library
15
+ new TEMPLATES_DIR + 'cocoa-touch-static-library'
16
+ end
17
+
18
+ def initialize(template_dir)
19
+ @template_dir = template_dir
20
+ file = template_dir + template_file
21
+ @template = NSMutableDictionary.dictionaryWithContentsOfFile(file.to_s)
22
+ end
23
+
24
+ def template_file
25
+ 'Pods.xcodeproj/project.pbxproj'
26
+ end
27
+
28
+ def to_hash
29
+ @template
30
+ end
31
+
32
+ def find_objects(conditions)
33
+ objects.select do |_, object|
34
+ object.objectsForKeys(conditions.keys, notFoundMarker:Object.new) == conditions.values
35
+ end
36
+ end
37
+
38
+ def find_object(conditions)
39
+ find_objects(conditions).first
40
+ end
41
+
42
+ def source_files
43
+ conditions = { 'isa' => 'PBXFileReference', 'sourceTree' => 'SOURCE_ROOT' }
44
+ find_objects(conditions).map do |_, object|
45
+ if %w{ .h .m .mm .c .cpp }.include?(File.extname(object['path']))
46
+ Pathname.new(object['path'])
47
+ end
48
+ end.compact
49
+ end
50
+
51
+ def add_source_file(file)
52
+ file_ref_uuid = add_file_reference(file, 'SOURCE_ROOT')
53
+ add_file_to_group(file_ref_uuid, 'Pods')
54
+ if file.extname == '.h'
55
+ build_file_uuid = add_build_file(file_ref_uuid, "settings" => { "ATTRIBUTES" => ["Public"] })
56
+ add_file_to_list('PBXHeadersBuildPhase', build_file_uuid)
57
+ else
58
+ build_file_uuid = add_build_file(file_ref_uuid)
59
+ add_file_to_list('PBXSourcesBuildPhase', build_file_uuid)
60
+ end
61
+ file_ref_uuid
62
+ end
63
+
64
+ def create_in(pods_root)
65
+ @template_dir.children.each do |child|
66
+ FileUtils.cp_r(child, pods_root + child.relative_path_from(@template_dir))
67
+ end
68
+ pbxproj = pods_root + template_file
69
+ @template.writeToFile(pbxproj.to_s, atomically:true)
70
+ end
71
+
72
+ private
73
+
74
+ def add_object(object)
75
+ uuid = generate_uuid
76
+ objects[uuid] = object
77
+ uuid
78
+ end
79
+
80
+ def add_file_reference(path, source_tree)
81
+ add_object({
82
+ "name" => path.basename.to_s,
83
+ "isa" => "PBXFileReference",
84
+ "sourceTree" => source_tree,
85
+ "path" => path.to_s,
86
+ })
87
+ end
88
+
89
+ def add_build_file(file_ref_uuid, extra = {})
90
+ add_object(extra.merge({
91
+ "isa" => "PBXBuildFile",
92
+ "fileRef" => file_ref_uuid
93
+ }))
94
+ end
95
+
96
+ def add_file_to_list(isa, build_file_uuid)
97
+ object_uuid, object = objects_by_isa(isa).first
98
+ object['files'] << build_file_uuid
99
+ end
100
+
101
+ def add_file_to_group(file_ref_uuid, name)
102
+ object_uuid, object = objects.find do |_, object|
103
+ object['isa'] == 'PBXGroup' && object['name'] == name
104
+ end
105
+ object['children'] << file_ref_uuid
106
+ end
107
+
108
+ def objects
109
+ @template['objects']
110
+ end
111
+
112
+ def objects_by_isa(isa)
113
+ objects.select { |_, object| object['isa'] == isa }
114
+ end
115
+
116
+ def generate_uuid
117
+ _uuid = CFUUIDCreate(nil)
118
+ uuid = CFUUIDCreateString(nil, _uuid)
119
+ CFRelease(_uuid)
120
+ CFMakeCollectable(uuid)
121
+ # Xcode's version is actually shorter, not worrying about collisions too much right now.
122
+ uuid.gsub('-', '')[0..23]
123
+ end
124
+
125
+ public
126
+
127
+ def pretty_print
128
+ puts `ruby -r pp -e 'pp(#{@template.inspect})'`
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,7 @@
1
+ //
2
+ // Prefix header for all source files of the 'Pods' target in the 'Pods' project
3
+ //
4
+
5
+ #ifdef __OBJC__
6
+ #import <UIKit/UIKit.h>
7
+ #endif
@@ -0,0 +1,232 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ 515B0FB9141D52E0001DC3E6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 515B0FB8141D52E0001DC3E6 /* Foundation.framework */; };
11
+ /* End PBXBuildFile section */
12
+
13
+ /* Begin PBXFileReference section */
14
+ 515160D0141EC5D100EBB823 /* Pods.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Pods.xcconfig; sourceTree = "<group>"; };
15
+ 515B0FB5141D52E0001DC3E6 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
16
+ 515B0FB8141D52E0001DC3E6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
17
+ 515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Pods-Prefix.pch"; sourceTree = SOURCE_ROOT; };
18
+ /* End PBXFileReference section */
19
+
20
+ /* Begin PBXFrameworksBuildPhase section */
21
+ 515B0FB2141D52E0001DC3E6 /* Frameworks */ = {
22
+ isa = PBXFrameworksBuildPhase;
23
+ buildActionMask = 2147483647;
24
+ files = (
25
+ 515B0FB9141D52E0001DC3E6 /* Foundation.framework in Frameworks */,
26
+ );
27
+ runOnlyForDeploymentPostprocessing = 0;
28
+ };
29
+ /* End PBXFrameworksBuildPhase section */
30
+
31
+ /* Begin PBXGroup section */
32
+ 515B0FAA141D52E0001DC3E6 = {
33
+ isa = PBXGroup;
34
+ children = (
35
+ 515160D0141EC5D100EBB823 /* Pods.xcconfig */,
36
+ 515B0FC9141D5FBE001DC3E6 /* Pods */,
37
+ 515B0FB7141D52E0001DC3E6 /* Frameworks */,
38
+ 515B0FB6141D52E0001DC3E6 /* Products */,
39
+ );
40
+ sourceTree = "<group>";
41
+ };
42
+ 515B0FB6141D52E0001DC3E6 /* Products */ = {
43
+ isa = PBXGroup;
44
+ children = (
45
+ 515B0FB5141D52E0001DC3E6 /* libPods.a */,
46
+ );
47
+ name = Products;
48
+ sourceTree = "<group>";
49
+ };
50
+ 515B0FB7141D52E0001DC3E6 /* Frameworks */ = {
51
+ isa = PBXGroup;
52
+ children = (
53
+ 515B0FB8141D52E0001DC3E6 /* Foundation.framework */,
54
+ );
55
+ name = Frameworks;
56
+ sourceTree = "<group>";
57
+ };
58
+ 515B0FBB141D52E0001DC3E6 /* Supporting Files */ = {
59
+ isa = PBXGroup;
60
+ children = (
61
+ 515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */,
62
+ );
63
+ name = "Supporting Files";
64
+ path = Pods;
65
+ sourceTree = "<group>";
66
+ };
67
+ 515B0FC9141D5FBE001DC3E6 /* Pods */ = {
68
+ isa = PBXGroup;
69
+ children = (
70
+ 515B0FBB141D52E0001DC3E6 /* Supporting Files */,
71
+ );
72
+ name = Pods;
73
+ sourceTree = "<group>";
74
+ };
75
+ /* End PBXGroup section */
76
+
77
+ /* Begin PBXHeadersBuildPhase section */
78
+ 515B0FB3141D52E0001DC3E6 /* Headers */ = {
79
+ isa = PBXHeadersBuildPhase;
80
+ buildActionMask = 2147483647;
81
+ files = (
82
+ );
83
+ runOnlyForDeploymentPostprocessing = 0;
84
+ };
85
+ /* End PBXHeadersBuildPhase section */
86
+
87
+ /* Begin PBXNativeTarget section */
88
+ 515B0FB4141D52E0001DC3E6 /* Pods */ = {
89
+ isa = PBXNativeTarget;
90
+ buildConfigurationList = 515B0FC2141D52E0001DC3E6 /* Build configuration list for PBXNativeTarget "Pods" */;
91
+ buildPhases = (
92
+ 515B0FB1141D52E0001DC3E6 /* Sources */,
93
+ 515B0FB2141D52E0001DC3E6 /* Frameworks */,
94
+ 515B0FB3141D52E0001DC3E6 /* Headers */,
95
+ );
96
+ buildRules = (
97
+ );
98
+ dependencies = (
99
+ );
100
+ name = Pods;
101
+ productName = Pods;
102
+ productReference = 515B0FB5141D52E0001DC3E6 /* libPods.a */;
103
+ productType = "com.apple.product-type.library.static";
104
+ };
105
+ /* End PBXNativeTarget section */
106
+
107
+ /* Begin PBXProject section */
108
+ 515B0FAC141D52E0001DC3E6 /* Project object */ = {
109
+ isa = PBXProject;
110
+ buildConfigurationList = 515B0FAF141D52E0001DC3E6 /* Build configuration list for PBXProject "Pods" */;
111
+ compatibilityVersion = "Xcode 3.2";
112
+ developmentRegion = English;
113
+ hasScannedForEncodings = 0;
114
+ knownRegions = (
115
+ en,
116
+ );
117
+ mainGroup = 515B0FAA141D52E0001DC3E6;
118
+ productRefGroup = 515B0FB6141D52E0001DC3E6 /* Products */;
119
+ projectDirPath = "";
120
+ projectRoot = "";
121
+ targets = (
122
+ 515B0FB4141D52E0001DC3E6 /* Pods */,
123
+ );
124
+ };
125
+ /* End PBXProject section */
126
+
127
+ /* Begin PBXSourcesBuildPhase section */
128
+ 515B0FB1141D52E0001DC3E6 /* Sources */ = {
129
+ isa = PBXSourcesBuildPhase;
130
+ buildActionMask = 2147483647;
131
+ files = (
132
+ );
133
+ runOnlyForDeploymentPostprocessing = 0;
134
+ };
135
+ /* End PBXSourcesBuildPhase section */
136
+
137
+ /* Begin XCBuildConfiguration section */
138
+ 515B0FC0141D52E0001DC3E6 /* Debug */ = {
139
+ isa = XCBuildConfiguration;
140
+ buildSettings = {
141
+ ALWAYS_SEARCH_USER_PATHS = NO;
142
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
143
+ COPY_PHASE_STRIP = NO;
144
+ GCC_C_LANGUAGE_STANDARD = gnu99;
145
+ GCC_DYNAMIC_NO_PIC = NO;
146
+ GCC_OPTIMIZATION_LEVEL = 0;
147
+ GCC_PREPROCESSOR_DEFINITIONS = (
148
+ "DEBUG=1",
149
+ "$(inherited)",
150
+ );
151
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
152
+ GCC_VERSION = com.apple.compilers.llvmgcc42;
153
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
154
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
155
+ GCC_WARN_UNUSED_VARIABLE = YES;
156
+ INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
157
+ IPHONEOS_DEPLOYMENT_TARGET = 4.3;
158
+ PUBLIC_HEADERS_FOLDER_PATH = "$(TARGET_NAME)";
159
+ SDKROOT = iphoneos;
160
+ };
161
+ name = Debug;
162
+ };
163
+ 515B0FC1141D52E0001DC3E6 /* Release */ = {
164
+ isa = XCBuildConfiguration;
165
+ buildSettings = {
166
+ ALWAYS_SEARCH_USER_PATHS = NO;
167
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
168
+ COPY_PHASE_STRIP = YES;
169
+ GCC_C_LANGUAGE_STANDARD = gnu99;
170
+ GCC_VERSION = com.apple.compilers.llvmgcc42;
171
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
172
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
173
+ GCC_WARN_UNUSED_VARIABLE = YES;
174
+ INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
175
+ IPHONEOS_DEPLOYMENT_TARGET = 4.3;
176
+ PUBLIC_HEADERS_FOLDER_PATH = "$(TARGET_NAME)";
177
+ SDKROOT = iphoneos;
178
+ VALIDATE_PRODUCT = YES;
179
+ };
180
+ name = Release;
181
+ };
182
+ 515B0FC3141D52E0001DC3E6 /* Debug */ = {
183
+ isa = XCBuildConfiguration;
184
+ baseConfigurationReference = 515160D0141EC5D100EBB823 /* Pods.xcconfig */;
185
+ buildSettings = {
186
+ DSTROOT = /tmp/Pods.dst;
187
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
188
+ GCC_PREFIX_HEADER = "Pods-Prefix.pch";
189
+ OTHER_LDFLAGS = "-ObjC";
190
+ PRODUCT_NAME = "$(TARGET_NAME)";
191
+ SKIP_INSTALL = YES;
192
+ };
193
+ name = Debug;
194
+ };
195
+ 515B0FC4141D52E0001DC3E6 /* Release */ = {
196
+ isa = XCBuildConfiguration;
197
+ baseConfigurationReference = 515160D0141EC5D100EBB823 /* Pods.xcconfig */;
198
+ buildSettings = {
199
+ DSTROOT = /tmp/Pods.dst;
200
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
201
+ GCC_PREFIX_HEADER = "Pods-Prefix.pch";
202
+ OTHER_LDFLAGS = "-ObjC";
203
+ PRODUCT_NAME = "$(TARGET_NAME)";
204
+ SKIP_INSTALL = YES;
205
+ };
206
+ name = Release;
207
+ };
208
+ /* End XCBuildConfiguration section */
209
+
210
+ /* Begin XCConfigurationList section */
211
+ 515B0FAF141D52E0001DC3E6 /* Build configuration list for PBXProject "Pods" */ = {
212
+ isa = XCConfigurationList;
213
+ buildConfigurations = (
214
+ 515B0FC0141D52E0001DC3E6 /* Debug */,
215
+ 515B0FC1141D52E0001DC3E6 /* Release */,
216
+ );
217
+ defaultConfigurationIsVisible = 0;
218
+ defaultConfigurationName = Release;
219
+ };
220
+ 515B0FC2141D52E0001DC3E6 /* Build configuration list for PBXNativeTarget "Pods" */ = {
221
+ isa = XCConfigurationList;
222
+ buildConfigurations = (
223
+ 515B0FC3141D52E0001DC3E6 /* Debug */,
224
+ 515B0FC4141D52E0001DC3E6 /* Release */,
225
+ );
226
+ defaultConfigurationIsVisible = 0;
227
+ defaultConfigurationName = Release;
228
+ };
229
+ /* End XCConfigurationList section */
230
+ };
231
+ rootObject = 515B0FAC141D52E0001DC3E6 /* Project object */;
232
+ }