Skip to content

Commit

Permalink
Merge branch 'xcodeproj-gem'. Closes CocoaPods#24.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Nov 12, 2011
2 parents dba5cbf + da41a65 commit 2ab89bd
Show file tree
Hide file tree
Showing 18 changed files with 119 additions and 1,247 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -13,3 +13,6 @@
[submodule "spec/fixtures/integration/sstoolkit"]
path = spec/fixtures/integration/sstoolkit
url = https://github.com/samsoffes/sstoolkit.git
[submodule "external/xcodeproj"]
path = external/xcodeproj
url = git@github.com:alloy/xcodeproj.git
3 changes: 1 addition & 2 deletions bin/pod
@@ -1,8 +1,7 @@
#!/usr/bin/env macruby

if $0 == __FILE__
require 'rubygems'
gem 'activesupport', '~> 3.1.1'
$:.unshift File.expand_path('../../external/xcodeproj/lib', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
end

Expand Down
3 changes: 1 addition & 2 deletions cocoapods.gemspec
Expand Up @@ -31,8 +31,7 @@ Gem::Specification.new do |s|
" $ sudo macgem install rubygems-compile\n" \
" $ sudo macgem compile cocoapods\n\n"

s.add_runtime_dependency 'activesupport', '~> 3.1.1'
s.add_runtime_dependency 'i18n', '~> 0.6.0' # only needed for ActiveSupport :-/
s.add_runtime_dependency 'xcodeproj', '~> 0.0.1'

## Make sure you can build the gem on older versions of RubyGems too:
s.rubygems_version = "1.6.2"
Expand Down
1 change: 1 addition & 0 deletions external/xcodeproj
Submodule xcodeproj added at af5d34
15 changes: 6 additions & 9 deletions lib/cocoapods.rb
Expand Up @@ -12,26 +12,23 @@ class Informative < StandardError
autoload :Executable, 'cocoapods/executable'
autoload :Installer, 'cocoapods/installer'
autoload :Podfile, 'cocoapods/podfile'
autoload :ProjectTemplate, 'cocoapods/project_template'
autoload :Resolver, 'cocoapods/resolver'
autoload :Source, 'cocoapods/source'
autoload :Spec, 'cocoapods/specification'
autoload :Specification, 'cocoapods/specification'
autoload :Version, 'cocoapods/version'

module Xcode
autoload :Config, 'cocoapods/xcode/config'
autoload :CopyResourcesScript, 'cocoapods/xcode/copy_resources_script'
autoload :Project, 'cocoapods/xcode/project'
autoload :Workspace, 'cocoapods/xcode/workspace'
end

autoload :Pathname, 'pathname'
end

module Xcodeproj
autoload :Config, 'cocoapods/xcodeproj_ext'
autoload :Project, 'cocoapods/xcodeproj_ext'
autoload :Workspace, 'cocoapods/xcodeproj_ext'
end

class Pathname
def glob(pattern = '')
Dir.glob((self + pattern).to_s).map { |f| Pathname.new(f) }
end
end

42 changes: 36 additions & 6 deletions lib/cocoapods/installer.rb
Expand Up @@ -14,6 +14,36 @@ def build_specifications
end
end

class CopyResourcesScript
CONTENT = <<EOS
#!/bin/sh
install_resource()
{
echo "cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}
}
EOS

attr_reader :resources

# A list of files relative to the project pods root.
def initialize(resources)
@resources = resources
end

def save_as(pathname)
pathname.open('w') do |script|
script.puts CONTENT
@resources.each do |resource|
script.puts "install_resource '#{resource}'"
end
end
# TODO use File api
system("chmod +x '#{pathname}'")
end
end

class Target
include Config::Mixin
include Shared
Expand All @@ -25,7 +55,7 @@ def initialize(podfile, project, definition)
end

def xcconfig
@xcconfig ||= Xcode::Config.new({
@xcconfig ||= Xcodeproj::Config.new({
# In a workspace this is where the static library headers should be found.
'USER_HEADER_SEARCH_PATHS' => '"$(BUILT_PRODUCTS_DIR)/Pods"',
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
Expand All @@ -40,7 +70,7 @@ def xcconfig_filename
end

def copy_resources_script
@copy_resources_script ||= Xcode::CopyResourcesScript.new(build_specifications.map do |spec|
@copy_resources_script ||= CopyResourcesScript.new(build_specifications.map do |spec|
spec.expanded_resources
end.flatten)
end
Expand Down Expand Up @@ -134,7 +164,7 @@ def initialize(podfile)

def project
return @project if @project
@project = ProjectTemplate.for_platform(@podfile.platform)
@project = Xcodeproj::Project.for_platform(@podfile.platform)
# First we need to resolve dependencies across *all* targets, so that the
# same correct versions of pods are being used for all targets. This
# happens when we call `build_specifications'.
Expand Down Expand Up @@ -191,7 +221,7 @@ def install!
def configure_project(projpath)
root = File.dirname(projpath)
xcworkspace = File.join(root, File.basename(projpath, '.xcodeproj') + '.xcworkspace')
workspace = Xcode::Workspace.new_from_xcworkspace(xcworkspace)
workspace = Xcodeproj::Workspace.new_from_xcworkspace(xcworkspace)
pods_projpath = File.join(config.project_pods_root, 'Pods.xcodeproj')
root = Pathname.new(root).expand_path
[projpath, pods_projpath].each do |path|
Expand All @@ -200,7 +230,7 @@ def configure_project(projpath)
end
workspace.save_as(xcworkspace)

app_project = Xcode::Project.new(projpath)
app_project = Xcodeproj::Project.new(projpath)
return if app_project.files.find { |file| file.path =~ /libPods\.a$/ }

configfile = app_project.files.new('path' => 'Pods/Pods.xcconfig')
Expand All @@ -212,7 +242,7 @@ def configure_project(projpath)

libfile = app_project.files.new_static_library('Pods')
libfile.group = app_project.main_group.groups.find { |g| g.name == 'Frameworks' }
app_project.objects.select_by_class(Xcode::Project::PBXFrameworksBuildPhase).each do |build_phase|
app_project.objects.select_by_class(Xcodeproj::Project::PBXFrameworksBuildPhase).each do |build_phase|
build_phase.files << libfile.buildFiles.new
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cocoapods/specification.rb
Expand Up @@ -22,7 +22,7 @@ def self.from_file(path)

def initialize
@dependencies = []
@xcconfig = Xcode::Config.new
@xcconfig = Xcodeproj::Config.new
yield self if block_given?
end

Expand Down
33 changes: 0 additions & 33 deletions lib/cocoapods/xcode/config.rb

This file was deleted.

33 changes: 0 additions & 33 deletions lib/cocoapods/xcode/copy_resources_script.rb

This file was deleted.

0 comments on commit 2ab89bd

Please sign in to comment.