Skip to content

Commit

Permalink
Merge pull request #9792 from seanreinhardtapps/sr-plist-bundle-id-wa…
Browse files Browse the repository at this point in the history
…rning

[Pod Target Installer] Add PRODUCT_BUNDLE_IDENTIFIER to build settings when info_plist defines a bundle id
  • Loading branch information
dnkoutso committed May 22, 2020
2 parents 7673c15 + 3ff8142 commit c8bf1c6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Bug Fixes

* Fix Xcode 11 warning when setting Bundle Identifier in `info_plist`
[Sean Reinhardt](https://github.com/seanreinhardtapps)
[#9536](https://github.com/CocoaPods/CocoaPods/issues/9536)

* Fix `incompatible encoding regexp match` for linting non-ascii pod name
[banjun](https://github.com/banjun)
[#9765](https://github.com/CocoaPods/CocoaPods/issues/9765)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,30 @@ def custom_build_settings
settings['SWIFT_VERSION'] = target.swift_version
end

if info_plist_bundle_id
settings['PRODUCT_BUNDLE_IDENTIFIER'] = info_plist_bundle_id
end

settings
end

# @return [String] Bundle Identifier found in the custom Info.plist entries
#
def info_plist_bundle_id
return @plist_bundle_id if defined?(@plist_bundle_id)
unless target.info_plist_entries.nil?
@plist_bundle_id = target.info_plist_entries['CFBundleIdentifier']
unless @plist_bundle_id.nil?
message = "The `#{target.name}` target " \
"sets a Bundle Identifier of `#{@plist_bundle_id}` in it's info.plist file. " \
'The Bundle Identifier should be set using pod_target_xcconfig: ' \
"s.pod_target_xcconfig = { 'PRODUCT_BUNDLE_IDENTIFIER': '#{@plist_bundle_id}' }`."
UI.warn message
end
@plist_bundle_id
end
end

# Filters the given resource file references discarding empty paths which are
# added by their parent directory. This will also include references to the parent [PBXVariantGroup]
# for all resources underneath it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,50 @@ class PodsProjectGenerator
end
end

it 'adds bundle identifier from info_plist to build settings' do
@banana_spec.info_plist = {
'CFBundleIdentifier' => 'some.bundle.id',
}
@installer.install!
@project.targets.first.build_configurations.each do |config|
config.resolve_build_setting('PRODUCT_BUNDLE_IDENTIFIER').should == 'some.bundle.id'
end
end

it 'cleans up temporary directories' do
@installer.expects(:clean_support_files_temp_dir).once
@installer.install!
end

describe 'info_plist_bundle_id' do
it 'cache and return CFBundleIdentifier value when present in info_plist hash' do
@installer.target.root_spec.info_plist = { 'CFBundleIdentifier' => 'CocoaPods.test.id' }
@installer.send(:info_plist_bundle_id).should == 'CocoaPods.test.id'
@installer.instance_variable_get(:@plist_bundle_id).should == 'CocoaPods.test.id'
end

it 'logs warning when CFBundleIdentifier value present in info_plist hash' do
@installer.target.root_spec.info_plist = { 'CFBundleIdentifier' => 'CocoaPods.test.id' }
@installer.send(:info_plist_bundle_id)
UI.warnings.should.include 'The `BananaLib` target ' \
'sets a Bundle Identifier of `CocoaPods.test.id` in it\'s info.plist file. ' \
'The Bundle Identifier should be set using pod_target_xcconfig: ' \
's.pod_target_xcconfig = { \'PRODUCT_BUNDLE_IDENTIFIER\': \'CocoaPods.test.id\' }`.'
end

it 'returns nil with no CFBundleIdentifier info_plist hash' do
@installer.target.root_spec.info_plist = nil
@installer.send(:info_plist_bundle_id).should.nil?
@installer.target.root_spec.info_plist = {}
@installer.send(:info_plist_bundle_id).should.nil?
@installer.instance_variable_get(:@plist_bundle_id).should.nil?
UI.warnings.should.not.include 'The `BananaLib` target ' \
'sets a Bundle Identifier of `CocoaPods.test.id` in it\'s info.plist file. ' \
'The Bundle Identifier should be set using pod_target_xcconfig: ' \
's.pod_target_xcconfig = { \'PRODUCT_BUNDLE_IDENTIFIER\': \'CocoaPods.test.id\' }`.'
end
end

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

describe 'headers folder paths' do
Expand Down

0 comments on commit c8bf1c6

Please sign in to comment.