Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: CocoaPods/Xcodeproj
...
head fork: CocoaPods/Xcodeproj
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 10 files changed
  • 0 commit comments
  • 2 contributors
View
2  Gemfile
@@ -9,7 +9,7 @@ group :development do
gem "bacon"
gem "mocha-on-bacon"
gem 'prettybacon', :git => 'https://github.com/irrationalfab/PrettyBacon.git', :branch => 'master'
- gem "kicker"
+ gem "kicker", :git => 'https://github.com/alloy/kicker.git', :branch => '3.0.0'
end
group :documentation do
View
18 Gemfile.lock
@@ -1,4 +1,13 @@
GIT
+ remote: https://github.com/alloy/kicker.git
+ revision: 885b3d274372af0b9839d1172d1ac3bc5552c604
+ branch: 3.0.0
+ specs:
+ kicker (3.0.0pre2)
+ listen (~> 1.1.0)
+ notify (~> 0.5.2)
+
+GIT
remote: https://github.com/irrationalfab/PrettyBacon.git
revision: c42de649708149bbfb5fb5beefa65440855cf876
branch: master
@@ -9,7 +18,7 @@ GIT
PATH
remote: .
specs:
- xcodeproj (0.8.0)
+ xcodeproj (0.8.1)
activesupport (~> 3.2.13)
colored (~> 1.2)
@@ -31,9 +40,7 @@ GEM
ffi (1.9.0)
github-markup (0.7.5)
i18n (0.6.1)
- kicker (2.6.1)
- listen
- listen (1.2.2)
+ listen (1.1.6)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
@@ -44,6 +51,7 @@ GEM
mocha-on-bacon (0.2.2)
mocha (>= 0.13.0)
multi_json (1.7.7)
+ notify (0.5.2)
posix-spawn (0.3.6)
pygments.rb (0.5.1)
posix-spawn (~> 0.3.6)
@@ -72,7 +80,7 @@ DEPENDENCIES
bacon
coveralls
github-markup
- kicker
+ kicker!
mocha
mocha-on-bacon
prettybacon!
View
2  lib/xcodeproj.rb
@@ -1,5 +1,5 @@
module Xcodeproj
- VERSION = '0.8.0' unless defined? Xcodeproj::VERSION
+ VERSION = '0.8.1' unless defined? Xcodeproj::VERSION
class PlainInformative < StandardError
end
View
22 lib/xcodeproj/config.rb
@@ -1,3 +1,5 @@
+require 'shellwords'
+
module Xcodeproj
# This class holds the data for a Xcode build settings file (xcconfig) and
@@ -136,12 +138,13 @@ def to_hash(prefix = nil)
#
def merge!(xcconfig)
if xcconfig.is_a? Config
- @attributes.merge!(xcconfig.attributes) { |key, v1, v2| "#{v1} #{v2}" }
+ merge_attributes!(xcconfig.attributes)
@libraries.merge(xcconfig.libraries)
@frameworks.merge(xcconfig.frameworks)
@weak_frameworks.merge(xcconfig.weak_frameworks)
else
- @attributes.merge!(xcconfig.to_hash) { |key, v1, v2| "#{v1} #{v2}" }
+ merge_attributes!(xcconfig.to_hash)
+
# Parse frameworks and libraries. Then remove them from the linker
# flags
flags = @attributes['OTHER_LDFLAGS']
@@ -225,6 +228,21 @@ def hash_from_file_content(string)
hash
end
+ # Merges the given attributes hash while ensuring values are not duplicated.
+ #
+ # @param [Hash] attributes
+ # The attributes hash to merge into @attributes.
+ #
+ # @return [void]
+ #
+ def merge_attributes!(attributes)
+ @attributes.merge!(attributes) do |_, v1, v2|
+ v1, v2 = v1.strip, v2.strip
+ existing = v1.strip.shellsplit
+ existing.include?(v2) ? v1 : "#{v1} #{v2}"
+ end
+ end
+
# Strips the comments from a line of an xcconfig string.
#
# @param [String] line
View
13 lib/xcodeproj/constants.rb
@@ -111,6 +111,8 @@ module Constants
'GCC_SYMBOLS_PRIVATE_EXTERN' => 'NO',
'GCC_OPTIMIZATION_LEVEL' => '0',
'COPY_PHASE_STRIP' => 'NO',
+ # TODO: enable after Xcode 4
+ # 'ONLY_ACTIVE_ARCH' => 'YES',
}.freeze,
:release => {
'OTHER_CFLAGS' => ['-DNS_BLOCK_ASSERTIONS=1', "$(inherited)"],
@@ -144,6 +146,17 @@ module Constants
}.freeze,
}.freeze
+ # @return [Hash] The default build settings for a new project.
+ #
+ PROJECT_DEFAULT_BUILD_SETTINGS = {
+ :release => {
+ }.freeze,
+ :debug => {
+ # TODO: enable after Xcode 4
+ # 'ONLY_ACTIVE_ARCH' => 'YES',
+ }.freeze,
+ }.freeze
+
# @return [Hash] The corresponding numeric value of each copy build phase
# destination.
#
View
2  lib/xcodeproj/project.rb
@@ -118,7 +118,7 @@ def initialize(xcodeproj = nil)
%w| Release Debug |.each do |name|
build_configuration = new(XCBuildConfiguration)
build_configuration.name = name
- build_configuration.build_settings = {}
+ build_configuration.build_settings = Constants::PROJECT_DEFAULT_BUILD_SETTINGS[name.downcase.to_sym].dup
config_list.build_configurations << build_configuration
end
View
14 lib/xcodeproj/project/object/group.rb
@@ -109,8 +109,12 @@ def version_groups
# Creates a new file reference with the given path and adds it to the
# group or to an optional subpath.
#
- # @note The subpath is created if needed, similar to the UNIX command
- # `mkdir -p`
+ # @note The subpath is created if needed, similar to the UNIX command
+ # `mkdir -p`
+ #
+ # @note To closely match the Xcode behaviour the name attribute of
+ # the file reference is set only if the path of the file is not
+ # equal to the path of the group.
#
# @param [#to_s] path
# the file system path of the file.
@@ -128,6 +132,12 @@ def new_file(path, sub_group_path = nil, set_name = true)
target = find_subpath(sub_group_path, true)
target.children << file
+
+ same_path_of_group = target.path == file.pathname.dirname.to_s
+ same_path_project = file.pathname.dirname.to_s == '.' && target.path.nil?
+ unless same_path_of_group || same_path_project
+ file.name = file.pathname.basename.to_s
+ end
file
end
View
11 spec/config_spec.rb
@@ -150,7 +150,7 @@
config.should == { 'Key' => 'Value' }
end
- it "doesn't duplicates libraries and frameworks" do
+ it "doesn't duplicate libraries and frameworks" do
hash = { 'OTHER_LDFLAGS' => '-framework Foundation -weak_framework Twitter -lxml2.2.7.3' }
config = Xcodeproj::Config.new(hash)
# merge the original hash again
@@ -163,6 +163,15 @@
config.libraries.to_a.should.be.equal %w[ xml2.2.7.3 ]
end
+ it "doesn't duplicate other attribute values" do
+ hash = { 'CLANG_CXX_LIBRARY' => 'libc++' }
+ config = Xcodeproj::Config.new(hash)
+ config.merge!(hash)
+ config.to_hash.should == hash
+ config.merge!(config)
+ config.to_hash.should == hash
+ end
+
it 'it preserves OTHER_LDFLAGS not related to libraries and frameworks' do
config1 = Xcodeproj::Config.new({ 'OTHER_LDFLAGS' => %w{-ObjC -fobjc-arc}.join(' ') })
config2 = Xcodeproj::Config.new({ 'OTHER_LDFLAGS' => '-framework SystemConfiguration' })
View
10 spec/project/object/group_spec.rb
@@ -45,6 +45,16 @@ module ProjectSpecs
@group.files.should.include file
end
+ it "set the name attribute of the file reference if the file is not in the same dir of the group" do
+ ref = @group.new_file('sub_dir/ZOMG.md')
+ ref.name.should == 'ZOMG.md'
+ end
+
+ it "doesn't set the name attribute of the file reference if the file is in the same dir of the group" do
+ ref = @group.new_file('ZOMG.md')
+ ref.name.should.be.nil
+ end
+
it "returns a list of files and groups" do
@group.children.map(&:display_name).sort.should == %w{ Abracadabra.h Abracadabra.m Banana.h Banana.m ZappMachine }
end
View
3  spec/project/object_spec.rb
@@ -194,13 +194,14 @@ module ProjectSpecs
@file.to_tree_hash.should == {
"displayName" => "file.m",
"isa" => "PBXFileReference",
+ "name" => "file.m",
"path" => "Classes/file.m",
"sourceTree" => "SOURCE_ROOT",
"lastKnownFileType" => "sourcecode.c.objc",
"includeInIndex" => "1"
}
children = @group.to_tree_hash['children'].map { |child| child['name'] || child['path'] }
- children.should == ["Products", "Frameworks", "Classes/file.m"]
+ children.should == ["Products", "Frameworks", "file.m"]
end
it "returns the pretty print representation" do

No commit comments for this range

Something went wrong with that request. Please try again.