Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed inhibit_all_warnings? and merged with inhibit_warnings_for_pod? #12

Merged
merged 1 commit into from
Apr 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/cocoapods-core/podfile/target_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,13 @@ def build_configurations=(hash)

#--------------------------------------#

# @return [Bool] whether the target definition should silence all the
# warnings with a compiler flag.
#
def inhibit_all_warnings?
inhibit_warnings_hash['all'] || (parent.inhibit_all_warnings? unless root?)
end

# @return [Bool] whether the target definition should inhibit warnings
# for a single pod
# for a single pod. If inhibit_all_warnings is true, it will
# return true for any asked pod.
#
def inhibits_warnings_for_pod?(pod_name)
return true if inhibit_warnings_hash['all'] || (parent.inhibits_warnings_for_pod?(name) unless root?)

inhibit_warnings_hash['for_pods'] ||= []
inhibit_warnings_hash['for_pods'].include? pod_name
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this implementation the target definition will inherit the inhibit_all_warnings! DSL directive but not will not inherit it when the users specify it per pod. I don't have any strong opinion about the inheritance but I think that they should be consistent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd appreciate if you could paste a real world example, it would make it a bit more clear to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example A

target :ZipApp do
  inhibit_all_warnings!
  pod 'SSZipArchive'
  target :test do
  end
end

The test target inherits SSZipArchive and will inhibit the warnings.

Example B

target :ZipApp do
  pod 'SSZipArchive', :inhibit_warnings => true
  target :test do
  end
end

The test target inherits SSZipArchive and will not inhibit the warnings.

Expand Down
4 changes: 2 additions & 2 deletions spec/podfile/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ module Pod
end

it "allows to inhibit all the warnings of a Target definition" do
podfile = Podfile.new { inhibit_all_warnings! }
podfile.target_definitions["Pods"].inhibit_all_warnings?.should.be.true
podfile = Podfile.new { pod 'ObjectiveRecord'; inhibit_all_warnings! }
podfile.target_definitions["Pods"].inhibits_warnings_for_pod?('ObjectiveRecord').should.be.true
end
end

Expand Down
8 changes: 5 additions & 3 deletions spec/podfile/target_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ module Pod
#--------------------------------------#

it "doesn't inhibit all warnings by default" do
@root.should.not.inhibit_all_warnings?
@root.store_pod("ObjectiveSugar")
@root.should.not.inhibits_warnings_for_pod?("ObjectiveSugar")
end

it "doesn't inhibit warnings per pod by default" do
Expand All @@ -213,12 +214,13 @@ module Pod

it "returns if it should inhibit all warnings" do
@root.inhibit_all_warnings = true
@root.should.inhibit_all_warnings?
@root.should.inhibits_warnings_for_pod?('ObjectiveSugar')
end

it "inherits the option to inhibit all warnings from the parent" do
@root.inhibit_all_warnings = true
@child.should.inhibit_all_warnings?
@child.store_pod('ASIHTTPRequest')
@child.should.inhibits_warnings_for_pod?('ASIHTTPRequest')
end

#--------------------------------------#
Expand Down
8 changes: 4 additions & 4 deletions spec/podfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ module Pod
@podfile.target_definitions[:nested_osx_target].should.not.be.exclusive
end

it "specifies that the inhibit all warnings flag should be added to the target's build settings" do
@podfile.target_definitions["Pods"].should.not.inhibit_all_warnings
@podfile.target_definitions[:test].should.inhibit_all_warnings
@podfile.target_definitions[:subtarget].should.inhibit_all_warnings
it "inhibits warnings for any asked pod if inhibit_all_warnings! is called" do
@podfile.target_definitions["Pods"].inhibits_warnings_for_pod?('SSZipArchive').should.not.be.true
@podfile.target_definitions[:test].inhibits_warnings_for_pod?('JSONKit').should.be.true
@podfile.target_definitions[:subtarget].inhibits_warnings_for_pod?('Reachability').should.be.true
end

it "returns the Xcode project that contains the target to link with" do
Expand Down