Commit 44030731 authored by Eloy Duran's avatar Eloy Duran

Include UIKit by default and add a way to add frameworks and search paths to the xcodeproj.

parent bbbce5aa
......@@ -132,7 +132,8 @@ module Pod
file = file.relative_path_from(config.project_pods_root)
project.add_source_file(file)
end
#project.pretty_print
project.add_framework(Pathname.new('usr/lib/libxml2.2.7.3.dylib'))
project.add_header_search_paths(%w{ $(SDKROOT)/usr/include/libxml2 })
project.create_in(config.project_pods_root)
end
......
......@@ -13,7 +13,6 @@ module Pod
@template_dir = template_dir
file = template_dir + template_file
@template = NSMutableDictionary.dictionaryWithContentsOfFile(file.to_s)
pretty_print
end
def template_file
......@@ -28,7 +27,7 @@ module Pod
"sourceTree" => "SOURCE_ROOT",
"path" => file.to_s,
}
add_file_to_files_group(file_ref_uuid)
add_file_to_group(file_ref_uuid, 'Pods')
if file.extname == '.h'
add_header(file, file_ref_uuid)
......@@ -52,13 +51,37 @@ module Pod
add_file_to_list('PBXHeadersBuildPhase', build_file_uuid)
end
def add_framework(path)
file_ref_uuid = generate_uuid
objects[file_ref_uuid] = {
"name" => path.basename.to_s,
"isa" => "PBXFileReference",
"sourceTree" => "SDKROOT",
"path" => path.to_s,
}
add_file_to_group(file_ref_uuid, 'Frameworks')
build_file_uuid = generate_uuid
objects[build_file_uuid] = {
"isa" => "PBXBuildFile",
"fileRef" => file_ref_uuid
}
add_file_to_list('PBXFrameworksBuildPhase', build_file_uuid)
end
def add_header_search_paths(paths)
objects_by_isa('XCBuildConfiguration').each do |uuid, object|
existing_paths = object['buildSettings']['HEADER_SEARCH_PATHS'] ||= []
existing_paths.concat(paths)
end
end
def to_hash
@template
end
def create_in(pods_root)
@template_dir.children.each do |child|
puts "Copy #{child} to #{pods_root + child.relative_path_from(@template_dir)}"
FileUtils.cp_r(child, pods_root + child.relative_path_from(@template_dir))
end
pbxproj = pods_root + template_file
......@@ -68,27 +91,25 @@ module Pod
private
def add_file_to_list(isa, build_file_uuid)
object_uuid, object = object_by_isa(isa)
#object['files'] ||= []
object_uuid, object = objects_by_isa(isa).first
object['files'] << build_file_uuid
objects[object_uuid] = object
#objects[object_uuid] = object
end
def add_file_to_files_group(file_ref_uuid)
def add_file_to_group(file_ref_uuid, name)
object_uuid, object = objects.find do |_, object|
object['isa'] == 'PBXGroup' && object['name'] == 'Pods'
object['isa'] == 'PBXGroup' && object['name'] == name
end
#object['children'] ||= []
object['children'] << file_ref_uuid
objects[object_uuid] = object
#objects[object_uuid] = object
end
def objects
@template['objects']
end
def object_by_isa(isa)
objects.find { |_, object| object['isa'] == isa }
def objects_by_isa(isa)
objects.select { |_, object| object['isa'] == isa }
end
def generate_uuid
......
......@@ -8,15 +8,12 @@
/* Begin PBXBuildFile section */
515B0FB9141D52E0001DC3E6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 515B0FB8141D52E0001DC3E6 /* Foundation.framework */; };
515B0FBF141D52E0001DC3E6 /* Pods.m in Sources */ = {isa = PBXBuildFile; fileRef = 515B0FBE141D52E0001DC3E6 /* Pods.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
515B0FB5141D52E0001DC3E6 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
515B0FB8141D52E0001DC3E6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Pods-Prefix.pch"; path = "Pods/Pods-Prefix.pch"; sourceTree = SOURCE_ROOT; };
515B0FBD141D52E0001DC3E6 /* Pods.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Pods.h; path = Pods/Pods.h; sourceTree = SOURCE_ROOT; };
515B0FBE141D52E0001DC3E6 /* Pods.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Pods.m; path = Pods/Pods.m; sourceTree = SOURCE_ROOT; };
515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Pods-Prefix.pch"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -68,8 +65,6 @@
515B0FC9141D5FBE001DC3E6 /* Pods */ = {
isa = PBXGroup;
children = (
515B0FBD141D52E0001DC3E6 /* Pods.h */,
515B0FBE141D52E0001DC3E6 /* Pods.m */,
515B0FBB141D52E0001DC3E6 /* Supporting Files */,
);
name = Pods;
......@@ -132,7 +127,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
515B0FBF141D52E0001DC3E6 /* Pods.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -184,7 +178,7 @@
buildSettings = {
DSTROOT = /tmp/Pods.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Pods/Pods-Prefix.pch";
GCC_PREFIX_HEADER = "Pods-Prefix.pch";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
......@@ -196,7 +190,7 @@
buildSettings = {
DSTROOT = /tmp/Pods.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Pods/Pods-Prefix.pch";
GCC_PREFIX_HEADER = "Pods-Prefix.pch";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
......
//
// Pods.h
// Pods
//
// Created by Eloy Duran on 11-09-11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Pods : NSObject
@end
//
// Pods.m
// Pods
//
// Created by Eloy Duran on 11-09-11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "Pods.h"
@implementation Pods
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
@end
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