Commit 4ccc718b authored by Fabio Pelosin's avatar Fabio Pelosin

[Specification] support for weak frameworks.

Closes #263
parent f2cfa5f8
GIT GIT
remote: git://github.com/CocoaPods/Xcodeproj.git remote: git://github.com/CocoaPods/Xcodeproj.git
revision: 2da2c3688dfd240b376f671e8e6525ba28729f38 revision: 88c230a58fc7a0a9f850bc2cb929625345804aef
specs: specs:
xcodeproj (0.2.3) xcodeproj (0.2.3)
activesupport (~> 3.2.6) activesupport (~> 3.2.6)
...@@ -74,7 +74,7 @@ GEM ...@@ -74,7 +74,7 @@ GEM
ffi (>= 0.5.0) ffi (>= 0.5.0)
redcarpet (2.1.1) redcarpet (2.1.1)
slop (2.4.4) slop (2.4.4)
vcr (2.2.2) vcr (2.2.3)
webmock (1.8.7) webmock (1.8.7)
addressable (>= 2.2.7) addressable (>= 2.2.7)
crack (>= 0.1.7) crack (>= 0.1.7)
......
...@@ -44,6 +44,7 @@ module Pod ...@@ -44,6 +44,7 @@ module Pod
preserve_paths preserve_paths
exclude_header_search_paths exclude_header_search_paths
frameworks frameworks
weak_frameworks
libraries libraries
dependencies dependencies
compiler_flags ].each do |attr| compiler_flags ].each do |attr|
...@@ -127,6 +128,8 @@ module Pod ...@@ -127,6 +128,8 @@ module Pod
xcconfig= xcconfig=
framework= framework=
frameworks= frameworks=
weak_framework=
weak_frameworks=
library= library=
libraries= libraries=
compiler_flags= compiler_flags=
...@@ -240,11 +243,13 @@ module Pod ...@@ -240,11 +243,13 @@ module Pod
pltf_chained_attr_accessor :preserve_paths, lambda {|value, current| pattern_list(value) } # Paths that should not be cleaned pltf_chained_attr_accessor :preserve_paths, lambda {|value, current| pattern_list(value) } # Paths that should not be cleaned
pltf_chained_attr_accessor :exclude_header_search_paths, lambda {|value, current| pattern_list(value) } # Headers to be excluded from being added to search paths (RestKit) pltf_chained_attr_accessor :exclude_header_search_paths, lambda {|value, current| pattern_list(value) } # Headers to be excluded from being added to search paths (RestKit)
pltf_chained_attr_accessor :frameworks, lambda {|value, current| (current << value).flatten } pltf_chained_attr_accessor :frameworks, lambda {|value, current| (current << value).flatten }
pltf_chained_attr_accessor :weak_frameworks, lambda {|value, current| (current << value).flatten }
pltf_chained_attr_accessor :libraries, lambda {|value, current| (current << value).flatten } pltf_chained_attr_accessor :libraries, lambda {|value, current| (current << value).flatten }
alias_method :resource=, :resources= alias_method :resource=, :resources=
alias_method :preserve_path=, :preserve_paths= alias_method :preserve_path=, :preserve_paths=
alias_method :framework=, :frameworks= alias_method :framework=, :frameworks=
alias_method :weak_framework=, :weak_frameworks=
alias_method :library=, :libraries= alias_method :library=, :libraries=
# @!method header_dir= # @!method header_dir=
...@@ -271,9 +276,11 @@ module Pod ...@@ -271,9 +276,11 @@ module Pod
platform_attr_writer :xcconfig, lambda {|value, current| current.tap { |c| c.merge!(value) } } platform_attr_writer :xcconfig, lambda {|value, current| current.tap { |c| c.merge!(value) } }
def xcconfig def xcconfig
raw_xconfig.dup. result = raw_xconfig.dup
tap { |x| x.libraries.merge libraries }. result.libraries.merge(libraries)
tap { |x| x.frameworks.merge frameworks } result.frameworks.merge(frameworks)
result.weak_frameworks.merge(weak_frameworks)
result
end end
def raw_xconfig def raw_xconfig
......
...@@ -79,6 +79,13 @@ describe "A Pod::Specification loaded from a podspec" do ...@@ -79,6 +79,13 @@ describe "A Pod::Specification loaded from a podspec" do
'-framework SystemConfiguration' } '-framework SystemConfiguration' }
end end
it "has a shortcut to add weak frameworks to the xcconfig" do
@spec.weak_frameworks = 'Twitter'
@spec.activate_platform(:ios).xcconfig.should == {
"OTHER_LDFLAGS"=>"-framework SystemConfiguration -weak_frameworks Twitter"
}
end
it "has a shortcut to add libraries to the xcconfig" do it "has a shortcut to add libraries to the xcconfig" do
@spec.libraries = 'z', 'xml2' @spec.libraries = 'z', 'xml2'
@spec.activate_platform(:ios).xcconfig.should == { @spec.activate_platform(:ios).xcconfig.should == {
...@@ -293,6 +300,7 @@ describe "A Pod::Specification subspec" do ...@@ -293,6 +300,7 @@ describe "A Pod::Specification subspec" do
fss.ios.source_files = 'subspec_ios.m' fss.ios.source_files = 'subspec_ios.m'
fss.osx.source_files = 'subspec_osx.m' fss.osx.source_files = 'subspec_osx.m'
fss.framework = 'CoreGraphics' fss.framework = 'CoreGraphics'
fss.weak_framework = 'Twitter'
fss.library = 'z' fss.library = 'z'
fss.subspec 'SecondSubSpec' do |sss| fss.subspec 'SecondSubSpec' do |sss|
...@@ -428,18 +436,24 @@ describe "A Pod::Specification subspec" do ...@@ -428,18 +436,24 @@ describe "A Pod::Specification subspec" do
@subsubspec.frameworks.should == %w[ CoreData CoreGraphics ] @subsubspec.frameworks.should == %w[ CoreData CoreGraphics ]
end end
it "resolves the weak frameworks correctly" do
@spec.activate_platform(:ios)
@spec.weak_frameworks.should == %w[ ]
@subspec.weak_frameworks.should == %w[ Twitter ]
end
it "resolves the xcconfig" do it "resolves the xcconfig" do
@spec.activate_platform(:ios) @spec.activate_platform(:ios)
@spec.xcconfig = { 'OTHER_LDFLAGS' => "-Wl,-no_compact_unwind" } @spec.xcconfig = { 'OTHER_LDFLAGS' => "-Wl,-no_compact_unwind" }
@spec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -framework CoreData"} @spec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -framework CoreData"}
@subspec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -lz -framework CoreData -framework CoreGraphics"} @subspec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -lz -framework CoreData -framework CoreGraphics -weak_frameworks Twitter"}
@subsubspec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -lz -framework CoreData -framework CoreGraphics"} @subsubspec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -lz -framework CoreData -framework CoreGraphics -weak_frameworks Twitter"}
@subsubspec.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' } @subsubspec.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
@spec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -framework CoreData"} @spec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -framework CoreData"}
@subsubspec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -lz -framework CoreData -framework CoreGraphics", "HEADER_SEARCH_PATHS"=>"$(SDKROOT)/usr/include/libxml2"} @subsubspec.xcconfig.should == {"OTHER_LDFLAGS"=>"-Wl,-no_compact_unwind -lxml -lz -framework CoreData -framework CoreGraphics -weak_frameworks Twitter", "HEADER_SEARCH_PATHS"=>"$(SDKROOT)/usr/include/libxml2"}
end end
end 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