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

Set PRODUCT_BUNDLE_IDENTIFIER for generated app during lint. #10936

Merged
merged 1 commit into from Sep 9, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -12,7 +12,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Bug Fixes

* None.
* Set `PRODUCT_BUNDLE_IDENTIFIER` for generated app during lint.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#10933](https://github.com/CocoaPods/CocoaPods/issues/10933)


## 1.11.0 (2021-09-01)
Expand Down
Expand Up @@ -62,7 +62,8 @@ class AppHostInstaller
# @param [Hash] info_plist_entries see #info_plist_entries
# @param [String] product_basename see #product_basename
#
def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main: true, add_launchscreen_storyboard: platform == :ios, info_plist_entries: {}, product_basename: nil)
def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just formatting because I was inspecting these sources and its annoying to scroll. Irrelevant to the fix ultimately.

add_launchscreen_storyboard: platform == :ios, info_plist_entries: {}, product_basename: nil)
@sandbox = sandbox
@project = project
@platform = platform
Expand Down
7 changes: 5 additions & 2 deletions lib/cocoapods/validator.rb
Expand Up @@ -585,10 +585,13 @@ def create_app_project
info_plist_path = app_project.path.dirname.+('App/App-Info.plist')
Pod::Installer::Xcode::PodsProjectGenerator::TargetInstallerHelper.create_info_plist_file_with_sandbox(sandbox, info_plist_path, app_target, '1.0.0', Platform.new(consumer.platform_name), :appl)
Pod::Generator::AppTargetHelper.add_swift_version(app_target, derived_swift_version)
# Lint will fail if a AppIcon is set but no image is found with such name
# Happens only with Static Frameworks enabled but shouldn't be set anyway
app_target.build_configurations.each do |config|
# Lint will fail if a AppIcon is set but no image is found with such name
# Happens only with Static Frameworks enabled but shouldn't be set anyway
config.build_settings.delete('ASSETCATALOG_COMPILER_APPICON_NAME')
# Ensure this is set generally but we have seen an issue with ODRs:
# see: https://github.com/CocoaPods/CocoaPods/issues/10933
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

actual fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

verified lint passes on the same sample app given.

end
app_project.save
app_project.recreate_user_schemes
Expand Down
86 changes: 63 additions & 23 deletions spec/unit/validator_spec.rb
Expand Up @@ -1792,7 +1792,7 @@ def create_target_with_validator_consumer(validator, consumer)
project.native_targets.find { |t| t.name == 'App' }
end

describe 'check appicon key deleted' do
describe 'sets various configuration settings' do
before do
@validator = Validator.new(podspec_path, config.sources_manager.master.map(&:url))
@validator.stubs(:validate_url)
Expand All @@ -1802,39 +1802,79 @@ def create_target_with_validator_consumer(validator, consumer)
@validator.send(:tear_down_validation_environment)
end

it 'ios platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:ios)
target = create_target_with_validator_consumer(@validator, consumer)
describe 'sets the product bundle identifier' do
it 'ios platform sets product bundle identifier' do
consumer = Specification.from_file(podspec_path).consumer(:ios)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
target.build_configurations.each do |config|
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'].should == 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
end
end
end

it 'tvos platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:tvos)
target = create_target_with_validator_consumer(@validator, consumer)
it 'tvos platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:tvos)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
target.build_configurations.each do |config|
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'].should == 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
end
end
end

it 'osx platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:osx)
target = create_target_with_validator_consumer(@validator, consumer)
it 'osx platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:osx)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
target.build_configurations.each do |config|
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'].should == 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
end
end

it 'watchos platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:watchos)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'].should == 'org.cocoapods.${PRODUCT_NAME:rfc1034identifier}'
end
end
end

it 'watchos platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:watchos)
target = create_target_with_validator_consumer(@validator, consumer)
describe 'check appicon key deleted' do
it 'ios platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:ios)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
end
end

it 'tvos platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:tvos)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
end
end

it 'osx platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:osx)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
end
end

it 'watchos platform deletes AppIcon key' do
consumer = Specification.from_file(podspec_path).consumer(:watchos)
target = create_target_with_validator_consumer(@validator, consumer)

target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
target.build_configurations.each do |config|
config.build_settings.key?('ASSETCATALOG_COMPILER_APPICON_NAME').should.be.false
end
end
end
end
Expand Down