From 48973fbb6b8d0e600bc9e43c798fd25af86e92a1 Mon Sep 17 00:00:00 2001 From: Dimitris Koutsogiorgas Date: Thu, 9 Sep 2021 13:00:57 -0700 Subject: [PATCH] Set `INFOPLIST_FILE` build setting to `$(SRCROOT)/App/App-Info.plist` during lint. --- CHANGELOG.md | 4 ++++ .../target_installer_helper.rb | 12 +++++++++--- lib/cocoapods/validator.rb | 8 +++++++- spec/unit/validator_spec.rb | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index add70b2c7b..2cdac21c28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes +* Set `INFOPLIST_FILE` build setting to `$(SRCROOT)/App/App-Info.plist` during lint. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#10927](https://github.com/CocoaPods/CocoaPods/issues/10927) + * Set `PRODUCT_BUNDLE_IDENTIFIER` for generated app during lint. [Dimitris Koutsogiorgas](https://github.com/dnkoutso) [#10933](https://github.com/CocoaPods/CocoaPods/issues/10933) diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb b/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb index c9fd0bb7cd..72b16b6a54 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb @@ -48,17 +48,23 @@ def update_changed_file(generator, path) # @param [Hash] additional_entries # any additional entries to include in this Info.plist file. # + # @param [String] build_setting_value + # an optional value to set for the `INFOPLIST_FILE` build setting on the + # native target. If none is specified then the value is calculated from the + # Info.plist path relative to the sandbox root. + # # @return [void] # def create_info_plist_file_with_sandbox(sandbox, path, native_target, version, platform, - bundle_package_type = :fmwk, additional_entries: {}) + bundle_package_type = :fmwk, additional_entries: {}, + build_setting_value: nil) UI.message "- Generating Info.plist file at #{UI.path(path)}" do generator = Generator::InfoPlistFile.new(version, platform, bundle_package_type, additional_entries) update_changed_file(generator, path) - relative_path_string = path.relative_path_from(sandbox.root).to_s + build_setting_value ||= path.relative_path_from(sandbox.root).to_s native_target.build_configurations.each do |c| - c.build_settings['INFOPLIST_FILE'] = relative_path_string + c.build_settings['INFOPLIST_FILE'] = build_setting_value end end end diff --git a/lib/cocoapods/validator.rb b/lib/cocoapods/validator.rb index c7ba864c24..c69b9314a9 100644 --- a/lib/cocoapods/validator.rb +++ b/lib/cocoapods/validator.rb @@ -583,7 +583,13 @@ def create_app_project app_target = Pod::Generator::AppTargetHelper.add_app_target(app_project, consumer.platform_name, deployment_target) sandbox = Sandbox.new(config.sandbox_root) 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::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, + :build_setting_value => '$(SRCROOT)/App/App-Info.plist') Pod::Generator::AppTargetHelper.add_swift_version(app_target, derived_swift_version) app_target.build_configurations.each do |config| # Lint will fail if a AppIcon is set but no image is found with such name diff --git a/spec/unit/validator_spec.rb b/spec/unit/validator_spec.rb index f7c9784637..7f5d08b448 100644 --- a/spec/unit/validator_spec.rb +++ b/spec/unit/validator_spec.rb @@ -998,7 +998,7 @@ def podspec_path(name = 'JSONKit', version = '1.4', source = nil) target.deployment_target.should.be.nil target.platform_name.should == :ios target.build_configurations.each do |c| - File.basename(c.build_settings['INFOPLIST_FILE']).should == 'App-Info.plist' + c.build_settings['INFOPLIST_FILE'].should == '$(SRCROOT)/App/App-Info.plist' end Xcodeproj::Project.schemes(project.path).should == %w(App) end