Skip to content

Commit

Permalink
Switch to xcodeproj gem
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanw committed Nov 11, 2011
1 parent 87e1a0b commit be78f0d
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 1,223 deletions.
3 changes: 1 addition & 2 deletions cocoapods.gemspec
Original file line number Diff line number Diff line change
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
32 changes: 25 additions & 7 deletions lib/cocoapods.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require 'rubygems'
require 'xcodeproj'

module Pod
VERSION = '0.2.0'

Expand All @@ -19,13 +22,6 @@ class Informative < StandardError
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

Expand All @@ -35,3 +31,25 @@ def glob(pattern = '')
end
end

# Sorry to dump these here...

class Xcode::Project
# Shortcut access to the `Pods' PBXGroup.
def pods
groups.find { |g| g.name == 'Pods' } || groups.new({ 'name' => 'Pods' })
end

# Adds a group as child to the `Pods' group.
def add_pod_group(name)
pods.groups.new('name' => name)
end

class PBXCopyFilesBuildPhase
def self.new_pod_dir(project, pod_name, path)
new(project, nil, {
"dstPath" => "$(PUBLIC_HEADERS_FOLDER_PATH)/#{path}",
"name" => "Copy #{pod_name} Public Headers",
})
end
end
end
32 changes: 31 additions & 1 deletion lib/cocoapods/installer.rb
Original file line number Diff line number Diff line change
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 @@ -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
3 changes: 2 additions & 1 deletion lib/cocoapods/project_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def self.for_platform(platform)
'INSTALL_PATH' => "$(BUILT_PRODUCTS_DIR)",
'GCC_WARN_ABOUT_MISSING_PROTOTYPES' => 'YES',
'GCC_WARN_ABOUT_RETURN_TYPE' => 'YES',
'GCC_WARN_UNUSED_VARIABLE' => 'YES'
'GCC_WARN_UNUSED_VARIABLE' => 'YES',
'OTHER_LDFLAGS' => ''
},
:debug => {
'GCC_DYNAMIC_NO_PIC' => 'NO',
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.

Loading

0 comments on commit be78f0d

Please sign in to comment.