Commit cca8cdfb authored by Eloy Duran's avatar Eloy Duran

Stash work on project creation.

parent edd18888
...@@ -122,13 +122,18 @@ module Pod ...@@ -122,13 +122,18 @@ module Pod
spec = set.podspec spec = set.podspec
spec.read(:source_files).each do |pattern| spec.read(:source_files).each do |pattern|
pattern = spec.pod_destroot + pattern pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{m,mm,c,cpp}' if pattern.directory? pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
source_files.concat(Dir.glob(pattern.to_s)) source_files.concat(Dir.glob(pattern.to_s).map { |f| Pathname.new(f) })
end end
end end
project = XcodeProject.static_library project = XcodeProject.static_library
project.source_files = source_files source_files.each do |file|
file = file.relative_path_from(config.project_pods_root)
project.add_source_file(file)
end
#project.pretty_print
project.create_at(config.project_pods_root + 'Pods.xcodeproj')
end end
include Config::Mixin include Config::Mixin
......
...@@ -6,17 +6,95 @@ module Pod ...@@ -6,17 +6,95 @@ module Pod
# TODO see if we really need different templates for iOS and OS X # TODO see if we really need different templates for iOS and OS X
def self.static_library def self.static_library
new TEMPLATES_DIR + 'cocoa-touch-static-library.pbxproj' new TEMPLATES_DIR + 'cocoa-touch-static-library/Pods.xcodeproj/project.pbxproj'
end end
def initialize(template) def initialize(template)
@template = NSDictionary.dictionaryWithContentsOfFile(template.to_s) @template = NSMutableDictionary.dictionaryWithContentsOfFile(template.to_s)
p @template #pretty_print
end end
def source_files=(files) def add_source_file(file)
@source_files = files file_ref_uuid = generate_uuid
@load_paths = files.map { |file| File.dirname(file) }.uniq objects[file_ref_uuid] = {
"name" => file.basename.to_s,
"isa" => "PBXFileReference",
"sourceTree" => "SOURCE_ROOT",
"path" => file.to_s,
}
add_file_to_files_group(file_ref_uuid)
if file.extname == '.h'
add_header(file, file_ref_uuid)
else
build_file_uuid = generate_uuid
objects[build_file_uuid] = {
"isa" => "PBXBuildFile",
"fileRef" => file_ref_uuid
}
add_file_to_list('PBXSourcesBuildPhase', build_file_uuid)
end
end
def add_header(file, file_ref_uuid)
build_file_uuid = generate_uuid
objects[build_file_uuid] = {
"isa" => "PBXBuildFile",
"fileRef" => file_ref_uuid,
"settings"=> { "ATTRIBUTES" => ["Public"] }
}
add_file_to_list('PBXHeadersBuildPhase', build_file_uuid)
end
def to_hash
@template
end
def create_at(xcodeproj)
xcodeproj.mkpath
pbxproj = xcodeproj + 'project.pbxproj'
@template.writeToFile(pbxproj.to_s, atomically:true)
end
private
def add_file_to_list(isa, build_file_uuid)
object_uuid, object = object_by_isa(isa)
#object['files'] ||= []
object['files'] << build_file_uuid
objects[object_uuid] = object
end
def add_file_to_files_group(file_ref_uuid)
object_uuid, object = objects.find do |_, object|
object['isa'] == 'PBXGroup' && object['name'] == 'Files'
end
#object['children'] ||= []
object['children'] << file_ref_uuid
objects[object_uuid] = object
end
def objects
@template['objects']
end
def object_by_isa(isa)
objects.find { |_, object| object['isa'] == isa }
end
def generate_uuid
_uuid = CFUUIDCreate(nil)
uuid = CFUUIDCreateString(nil, _uuid)
CFRelease(_uuid)
CFMakeCollectable(uuid)
# Xcode's version is actually shorter, not worrying about collisions too much right now.
uuid.gsub('-', '')[0..23]
end
public
def pretty_print
puts `ruby -r pp -e 'pp(#{@template.inspect})'`
end end
end end
end end
...@@ -7,85 +7,93 @@ ...@@ -7,85 +7,93 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
515B0F8E141D3E3A001DC3E6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 515B0F8D141D3E3A001DC3E6 /* Foundation.framework */; }; 515B0FB9141D52E0001DC3E6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 515B0FB8141D52E0001DC3E6 /* Foundation.framework */; };
515B0FA1141D3FB7001DC3E6 /* Pods.h in Headers */ = {isa = PBXBuildFile; fileRef = 515B0F9F141D3FB7001DC3E6 /* Pods.h */; settings = {ATTRIBUTES = (Public, ); }; }; 515B0FBF141D52E0001DC3E6 /* Pods.m in Sources */ = {isa = PBXBuildFile; fileRef = 515B0FBE141D52E0001DC3E6 /* Pods.m */; };
515B0FA2141D3FB7001DC3E6 /* Pods.m in Sources */ = {isa = PBXBuildFile; fileRef = 515B0FA0141D3FB7001DC3E6 /* Pods.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
515B0F8A141D3E3A001DC3E6 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 515B0FB5141D52E0001DC3E6 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
515B0F8D141D3E3A001DC3E6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 515B0FB8141D52E0001DC3E6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
515B0F9F141D3FB7001DC3E6 /* Pods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Pods.h; path = nested/files/Pods.h; sourceTree = SOURCE_ROOT; }; 515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Pods-Prefix.pch"; sourceTree = "<group>"; };
515B0FA0141D3FB7001DC3E6 /* Pods.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Pods.m; path = nested/files/Pods.m; sourceTree = SOURCE_ROOT; }; 515B0FBD141D52E0001DC3E6 /* Pods.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Pods.h; sourceTree = "<group>"; };
515B0FBE141D52E0001DC3E6 /* Pods.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Pods.m; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
515B0F87141D3E3A001DC3E6 /* Frameworks */ = { 515B0FB2141D52E0001DC3E6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
515B0F8E141D3E3A001DC3E6 /* Foundation.framework in Frameworks */, 515B0FB9141D52E0001DC3E6 /* Foundation.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
515B0F7F141D3E3A001DC3E6 = { 515B0FAA141D52E0001DC3E6 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
515B0F9E141D3FA0001DC3E6 /* Files */, 515B0FBA141D52E0001DC3E6 /* Pods */,
515B0F8C141D3E3A001DC3E6 /* Frameworks */, 515B0FB7141D52E0001DC3E6 /* Frameworks */,
515B0F8B141D3E3A001DC3E6 /* Products */, 515B0FB6141D52E0001DC3E6 /* Products */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
515B0F8B141D3E3A001DC3E6 /* Products */ = { 515B0FB6141D52E0001DC3E6 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
515B0F8A141D3E3A001DC3E6 /* libPods.a */, 515B0FB5141D52E0001DC3E6 /* libPods.a */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
515B0F8C141D3E3A001DC3E6 /* Frameworks */ = { 515B0FB7141D52E0001DC3E6 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
515B0F8D141D3E3A001DC3E6 /* Foundation.framework */, 515B0FB8141D52E0001DC3E6 /* Foundation.framework */,
); );
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
515B0F9E141D3FA0001DC3E6 /* Files */ = { 515B0FBA141D52E0001DC3E6 /* Pods */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
515B0F9F141D3FB7001DC3E6 /* Pods.h */, 515B0FBD141D52E0001DC3E6 /* Pods.h */,
515B0FA0141D3FB7001DC3E6 /* Pods.m */, 515B0FBE141D52E0001DC3E6 /* Pods.m */,
515B0FBB141D52E0001DC3E6 /* Supporting Files */,
); );
name = Files; path = Pods;
sourceTree = "<group>";
};
515B0FBB141D52E0001DC3E6 /* Supporting Files */ = {
isa = PBXGroup;
children = (
515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */ /* Begin PBXHeadersBuildPhase section */
515B0F88141D3E3A001DC3E6 /* Headers */ = { 515B0FB3141D52E0001DC3E6 /* Headers */ = {
isa = PBXHeadersBuildPhase; isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
515B0FA1141D3FB7001DC3E6 /* Pods.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXHeadersBuildPhase section */ /* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
515B0F89141D3E3A001DC3E6 /* Pods */ = { 515B0FB4141D52E0001DC3E6 /* Pods */ = {
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 515B0F97141D3E3A001DC3E6 /* Build configuration list for PBXNativeTarget "Pods" */; buildConfigurationList = 515B0FC2141D52E0001DC3E6 /* Build configuration list for PBXNativeTarget "Pods" */;
buildPhases = ( buildPhases = (
515B0F86141D3E3A001DC3E6 /* Sources */, 515B0FB1141D52E0001DC3E6 /* Sources */,
515B0F87141D3E3A001DC3E6 /* Frameworks */, 515B0FB2141D52E0001DC3E6 /* Frameworks */,
515B0F88141D3E3A001DC3E6 /* Headers */, 515B0FB3141D52E0001DC3E6 /* Headers */,
); );
buildRules = ( buildRules = (
); );
...@@ -93,44 +101,44 @@ ...@@ -93,44 +101,44 @@
); );
name = Pods; name = Pods;
productName = Pods; productName = Pods;
productReference = 515B0F8A141D3E3A001DC3E6 /* libPods.a */; productReference = 515B0FB5141D52E0001DC3E6 /* libPods.a */;
productType = "com.apple.product-type.library.static"; productType = "com.apple.product-type.library.static";
}; };
/* End PBXNativeTarget section */ /* End PBXNativeTarget section */
/* Begin PBXProject section */ /* Begin PBXProject section */
515B0F81141D3E3A001DC3E6 /* Project object */ = { 515B0FAC141D52E0001DC3E6 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
buildConfigurationList = 515B0F84141D3E3A001DC3E6 /* Build configuration list for PBXProject "Pods" */; buildConfigurationList = 515B0FAF141D52E0001DC3E6 /* Build configuration list for PBXProject "Pods" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = English;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
en, en,
); );
mainGroup = 515B0F7F141D3E3A001DC3E6; mainGroup = 515B0FAA141D52E0001DC3E6;
productRefGroup = 515B0F8B141D3E3A001DC3E6 /* Products */; productRefGroup = 515B0FB6141D52E0001DC3E6 /* Products */;
projectDirPath = ""; projectDirPath = "";
projectRoot = ""; projectRoot = "";
targets = ( targets = (
515B0F89141D3E3A001DC3E6 /* Pods */, 515B0FB4141D52E0001DC3E6 /* Pods */,
); );
}; };
/* End PBXProject section */ /* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
515B0F86141D3E3A001DC3E6 /* Sources */ = { 515B0FB1141D52E0001DC3E6 /* Sources */ = {
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
515B0FA2141D3FB7001DC3E6 /* Pods.m in Sources */, 515B0FBF141D52E0001DC3E6 /* Pods.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
515B0F95141D3E3A001DC3E6 /* Debug */ = { 515B0FC0141D52E0001DC3E6 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
...@@ -153,7 +161,7 @@ ...@@ -153,7 +161,7 @@
}; };
name = Debug; name = Debug;
}; };
515B0F96141D3E3A001DC3E6 /* Release */ = { 515B0FC1141D52E0001DC3E6 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
...@@ -170,7 +178,7 @@ ...@@ -170,7 +178,7 @@
}; };
name = Release; name = Release;
}; };
515B0F98141D3E3A001DC3E6 /* Debug */ = { 515B0FC3141D52E0001DC3E6 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
DSTROOT = /tmp/Pods.dst; DSTROOT = /tmp/Pods.dst;
...@@ -182,7 +190,7 @@ ...@@ -182,7 +190,7 @@
}; };
name = Debug; name = Debug;
}; };
515B0F99141D3E3A001DC3E6 /* Release */ = { 515B0FC4141D52E0001DC3E6 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
DSTROOT = /tmp/Pods.dst; DSTROOT = /tmp/Pods.dst;
...@@ -197,25 +205,24 @@ ...@@ -197,25 +205,24 @@
/* End XCBuildConfiguration section */ /* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */ /* Begin XCConfigurationList section */
515B0F84141D3E3A001DC3E6 /* Build configuration list for PBXProject "Pods" */ = { 515B0FAF141D52E0001DC3E6 /* Build configuration list for PBXProject "Pods" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
515B0F95141D3E3A001DC3E6 /* Debug */, 515B0FC0141D52E0001DC3E6 /* Debug */,
515B0F96141D3E3A001DC3E6 /* Release */, 515B0FC1141D52E0001DC3E6 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
515B0F97141D3E3A001DC3E6 /* Build configuration list for PBXNativeTarget "Pods" */ = { 515B0FC2141D52E0001DC3E6 /* Build configuration list for PBXNativeTarget "Pods" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
515B0F98141D3E3A001DC3E6 /* Debug */, 515B0FC3141D52E0001DC3E6 /* Debug */,
515B0F99141D3E3A001DC3E6 /* Release */, 515B0FC4141D52E0001DC3E6 /* Release */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
}; };
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };
rootObject = 515B0F81141D3E3A001DC3E6 /* Project object */; rootObject = 515B0FAC141D52E0001DC3E6 /* Project object */;
} }
//
// Prefix header for all source files of the 'Pods' target in the 'Pods' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment