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

Ability to manually set DNS_BLOCK_ASSERTIONS=1 #803

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
### Fixes

* [#802](https://github.com/CocoaPods/CocoaPods/issues/802): Ability to add
`-DNS_BLOCK_ASSERTIONS=1` to `OTHER_CFLAGS` and `OTHER_CPLUSPLUSFLAGS` with
`set_dns_block_assertions_flag!` to your Podfile.

## 0.16.2 ## 0.16.2
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.1...0.16.2) • [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.1...0.4.3) [CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.16.1...0.16.2) • [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/compare/0.4.1...0.4.3)


Expand Down
17 changes: 17 additions & 0 deletions lib/cocoapods/installer/target_installer.rb
Expand Up @@ -74,6 +74,8 @@ def generate_xcconfig(pods, sandbox)
xcconfig = Xcodeproj::Config.new({ xcconfig = Xcodeproj::Config.new({
'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build 'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
'OTHER_LDFLAGS' => default_ld_flags, 'OTHER_LDFLAGS' => default_ld_flags,
'OTHER_CFLAGS' => default_c_flags,
'OTHER_CPLUSPLUSFLAGS' => default_cplusplus_flags,
'HEADER_SEARCH_PATHS' => '${PODS_HEADERS_SEARCH_PATHS}', 'HEADER_SEARCH_PATHS' => '${PODS_HEADERS_SEARCH_PATHS}',
# CocoaPods global keys # CocoaPods global keys
'PODS_ROOT' => @target_definition.relative_pods_root, 'PODS_ROOT' => @target_definition.relative_pods_root,
Expand Down Expand Up @@ -129,6 +131,8 @@ def configure_build_configurations(xcconfig_file, sandbox)
@target.build_configurations.each do |config| @target.build_configurations.each do |config|
config.base_configuration_reference = xcconfig_file config.base_configuration_reference = xcconfig_file
config.build_settings['OTHER_LDFLAGS'] = '' config.build_settings['OTHER_LDFLAGS'] = ''
config.build_settings['OTHER_CFLAGS'] = ''
config.build_settings['OTHER_CPLUSPLUSFLAGS'] = ''
config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name
config.build_settings['PODS_ROOT'] = '${SRCROOT}' config.build_settings['PODS_ROOT'] = '${SRCROOT}'
config.build_settings['PODS_HEADERS_SEARCH_PATHS'] = '${PODS_BUILD_HEADERS_SEARCH_PATHS}' config.build_settings['PODS_HEADERS_SEARCH_PATHS'] = '${PODS_BUILD_HEADERS_SEARCH_PATHS}'
Expand Down Expand Up @@ -171,6 +175,19 @@ def default_ld_flags
flags << '-fobjc-arc' if @podfile.set_arc_compatibility_flag? && self.requires_arc flags << '-fobjc-arc' if @podfile.set_arc_compatibility_flag? && self.requires_arc
flags.join(" ") flags.join(" ")
end end

def default_c_flags
flags = []
flags << '-DNS_BLOCK_ASSERTIONS=1' if @podfile.set_dns_block_assertions_flag?
flags.join(" ")
end

def default_cplusplus_flags
flags = []
flags << '-DNS_BLOCK_ASSERTIONS=1' if @podfile.set_dns_block_assertions_flag?
flags.join(" ")
end

end end
end end
end end
Expand Down
8 changes: 8 additions & 0 deletions lib/cocoapods/podfile.rb
Expand Up @@ -503,6 +503,10 @@ def set_arc_compatibility_flag!
@set_arc_compatibility_flag = true @set_arc_compatibility_flag = true
end end


def set_dns_block_assertions_flag!
@set_dns_block_assertions_flag = true
end

# Not attributes # Not attributes


def podfile? def podfile?
Expand All @@ -528,6 +532,10 @@ def set_arc_compatibility_flag?
@set_arc_compatibility_flag @set_arc_compatibility_flag
end end


def set_dns_block_assertions_flag?
@set_dns_block_assertions_flag
end

def user_build_configurations def user_build_configurations
configs_array = @target_definitions.values.map { |td| td.user_project.build_configurations } configs_array = @target_definitions.values.map { |td| td.user_project.build_configurations }
configs_array.inject({}) { |hash, config| hash.merge(config) } configs_array.inject({}) { |hash, config| hash.merge(config) }
Expand Down
7 changes: 7 additions & 0 deletions spec/unit/installer/target_installer_spec.rb
Expand Up @@ -68,6 +68,13 @@ def do_install!
@installer.xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc") @installer.xcconfig.to_hash['OTHER_LDFLAGS'].split(" ").should.include("-fobjc-arc")
end end


it "adds the -DNS_BLOCK_ASSERTIONS=1 to OTHER_CFLAGS if set_dns_block_assertions_flag is set" do
@podfile.stubs(:set_dns_block_assertions_flag? => true)
do_install!
@installer.xcconfig.to_hash['OTHER_CFLAGS'].split(" ").should.include("-DNS_BLOCK_ASSERTIONS=1")
@installer.xcconfig.to_hash['OTHER_CPLUSPLUSFLAGS'].split(" ").should.include("-DNS_BLOCK_ASSERTIONS=1")
end

it "does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default" do it "does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default" do
do_install! do_install!
@installer.target.build_configurations.each do |config| @installer.target.build_configurations.each do |config|
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/podfile_spec.rb
Expand Up @@ -79,6 +79,10 @@
Pod::Podfile.new { set_arc_compatibility_flag! }.should.set_arc_compatibility_flag Pod::Podfile.new { set_arc_compatibility_flag! }.should.set_arc_compatibility_flag
end end


it "specifies that DNS_BLOCK_ASSERTIONS flag should be generated" do
Pod::Podfile.new { set_dns_block_assertions_flag! }.should.set_dns_block_assertions_flag
end

it "stores a block that will be called with the Installer before the target integration" do it "stores a block that will be called with the Installer before the target integration" do
yielded = nil yielded = nil
Pod::Podfile.new do Pod::Podfile.new do
Expand Down