Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: CocoaPods/Xcodeproj
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.2.0
Choose a base ref
...
head repository: CocoaPods/Xcodeproj
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.2.1
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Jul 2, 2012

  1. Unverified

    No user is associated with the committer email.
    Copy the full SHA
    ae2d4b9 View commit details
  2. Add release task. Closes #17.

    alloy committed Jul 2, 2012

    Unverified

    No user is associated with the committer email.
    Copy the full SHA
    f18c5cf View commit details
  3. Release 0.2.1

    alloy committed Jul 2, 2012

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4042ea0 View commit details
Showing with 124 additions and 14 deletions.
  1. +14 −5 Gemfile.lock
  2. +75 −2 Rakefile
  3. +1 −1 lib/xcodeproj.rb
  4. +11 −6 lib/xcodeproj/project.rb
  5. +23 −0 spec/project_spec.rb
19 changes: 14 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -2,12 +2,21 @@ GEM
remote: http://rubygems.org/
specs:
bacon (1.1.0)
kicker (2.5.0)
rb-fsevent
ffi (1.0.11)
kicker (2.6.0)
listen
listen (0.4.7)
rb-fchange (~> 0.0.5)
rb-fsevent (~> 0.9.1)
rb-inotify (~> 0.8.8)
rake (0.9.2.2)
rb-fsevent (0.9.0)
redcarpet (2.1.0)
yard (0.7.5)
rb-fchange (0.0.5)
ffi
rb-fsevent (0.9.1)
rb-inotify (0.8.8)
ffi (>= 0.5.0)
redcarpet (2.1.1)
yard (0.8.2.1)

PLATFORMS
ruby
77 changes: 75 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -86,15 +86,88 @@ rescue LoadError
end

namespace :gem do
def gem_version
require File.expand_path('../lib/xcodeproj', __FILE__)
Xcodeproj::VERSION
end

def gem_filename
"xcodeproj-#{gem_version}.gem"
end

desc "Build the gem"
task :build do
sh "gem build xcodeproj.gemspec"
end

desc "Install a gem version of the current code"
task :install => :build do
require File.expand_path('../lib/xcodeproj', __FILE__)
sh "gem install xcodeproj-#{Xcodeproj::VERSION}.gem"
sh "gem install #{gem_filename}"
end

def silent_sh(command)
output = `#{command} 2>&1`
unless $?.success?
puts output
exit 1
end
output
end

desc "Run all specs, build and install gem, commit version change, tag version change, and push everything"
task :release do

unless ENV['SKIP_CHECKS']
if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master'
$stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release."
exit 1
end

if `git tag`.strip.split("\n").include?(gem_version)
$stderr.puts "[!] A tag for version `#{gem_version}' already exists. Change the version in lib/xcodeproj.rb"
exit 1
end

puts "You are about to release `#{gem_version}', is that correct? [y/n]"
exit if $stdin.gets.strip.downcase != 'y'

diff_lines = `git diff --name-only`.strip.split("\n")

if diff_lines.size == 0
$stderr.puts "[!] Change the version number yourself in lib/xcodeproj.rb"
exit 1
end

if diff_lines != ['Gemfile.lock', 'lib/xcodeproj.rb']
$stderr.puts "[!] Only change the version number in a release commit!"
exit 1
end
end

puts "* Running specs"
silent_sh('rake spec:all')

tmp = File.expand_path('../tmp', __FILE__)
tmp_gems = File.join(tmp, 'gems')

Rake::Task['gem:build'].invoke

puts "* Testing gem installation (tmp/gems)"
silent_sh "rm -rf '#{tmp}'"
silent_sh "gem install --install-dir='#{tmp_gems}' #{gem_filename}"

# puts "* Building examples from gem (tmp/gems)"
# ENV['GEM_HOME'] = ENV['GEM_PATH'] = tmp_gems
# ENV['PATH'] = "#{tmp_gems}/bin:#{ENV['PATH']}"
# ENV['FROM_GEM'] = '1'
# silent_sh "rake examples:build"

# Then release
sh "git commit Gemfile.lock lib/xcodeproj.rb -m 'Release #{gem_version}'"
sh "git tag -a #{gem_version} -m 'Release #{gem_version}'"
sh "git push origin master"
sh "git push origin --tags"
sh "gem push #{gem_filename}"
end
end

2 changes: 1 addition & 1 deletion lib/xcodeproj.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Xcodeproj
VERSION = '0.2.0'
VERSION = '0.2.1'

autoload :Config, 'xcodeproj/config'
autoload :Project, 'xcodeproj/project'
17 changes: 11 additions & 6 deletions lib/xcodeproj/project.rb
Original file line number Diff line number Diff line change
@@ -167,12 +167,17 @@ def files
# directory.
# @return [PBXFileReference] The file reference object.
def add_system_framework(name)
group = groups.where('name' => 'Frameworks') || groups.new('name' => 'Frameworks')
group.files.new({
'name' => "#{name}.framework",
'path' => "System/Library/Frameworks/#{name}.framework",
'sourceTree' => 'SDKROOT'
})
path = "System/Library/Frameworks/#{name}.framework"
if file = files.where(:path => path)
file
else
group = groups.where('name' => 'Frameworks') || groups.new('name' => 'Frameworks')
group.files.new({
'name' => "#{name}.framework",
'path' => path,
'sourceTree' => 'SDKROOT'
})
end
end

# @return [PBXObjectList<XCBuildConfiguration] A list of project wide
23 changes: 23 additions & 0 deletions spec/project_spec.rb
Original file line number Diff line number Diff line change
@@ -81,6 +81,29 @@ module ProjectSpecs
@project.build_settings('Release').should == {}
end

it "adds a file reference, for a system framework, to the Frameworks group" do
group = @project.groups.where(:name => 'Frameworks')
file = @project.add_system_framework('QuartzCore')
file.group.should == group
file.name.should == 'QuartzCore.framework'
file.path.should == 'System/Library/Frameworks/QuartzCore.framework'
file.source_tree.should == 'SDKROOT'
end

it "does not add a system framework if it already exists in the project" do
before = @project.files.size

file = @project.add_system_framework('Foundation')
file.name.should == 'Foundation.framework'
@project.files.size.should == before

@project.groups.where(:name => 'Frameworks').name = 'Renamed Frameworks Group'
file = @project.add_system_framework('Foundation')
file.name.should == 'Foundation.framework'
@project.files.size.should == before
end

# TODO this should go to the native target spec
it "adds an `m' or `c' file to the `sources build' phase list" do
%w{ m mm c cpp }.each do |ext|
path = Pathname.new("path/to/file.#{ext}")