From 51f27719223c3e40db42ba8198dca85b21404bcd Mon Sep 17 00:00:00 2001 From: Derek Ostrander Date: Tue, 30 Oct 2018 14:33:51 -0700 Subject: [PATCH 1/6] Add option to app host installer whether or not ot add a main - App specs should not add main --- .../pods_project_generator/app_host_installer.rb | 11 +++++++++-- .../pods_project_generator/pod_target_installer.rb | 8 +++++++- .../app_host_installer_spec.rb | 13 +++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb index 1805d27322..2f19640dac 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb @@ -33,6 +33,10 @@ class AppHostInstaller # attr_reader :app_target_label + # @return [Boolean] whether the app host installer should add main + # + attr_reader :add_main + # Initialize a new instance # # @param [Sandbox] sandbox @see #sandbox @@ -41,14 +45,16 @@ class AppHostInstaller # @param [String] subgroup_name @see #subgroup_name # @param [String] group_name @see #group_name # @param [String] app_target_label see #app_target_label + # @param [Boolean] add_main see #add_main # - def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label) + def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main = true) @sandbox = sandbox @project = project @platform = platform @subgroup_name = subgroup_name @group_name = group_name @app_target_label = app_target_label + @add_main = add_main target_group = project.pod_group(group_name) @group = target_group[subgroup_name] || target_group.new_group(subgroup_name) end @@ -66,7 +72,8 @@ def install! configuration.build_settings['CURRENT_PROJECT_VERSION'] = '1' end - Pod::Generator::AppTargetHelper.add_app_host_main_file(project, app_host_target, platform_name, @group, app_target_label) + + Pod::Generator::AppTargetHelper.add_app_host_main_file(project, app_host_target, platform_name, @group, app_target_label) if add_main Pod::Generator::AppTargetHelper.add_launchscreen_storyboard(project, app_host_target, @group, app_target_label) if platform == :ios additional_entries = platform == :ios ? ADDITIONAL_IOS_INFO_PLIST_ENTRIES : {} create_info_plist_file_with_sandbox(sandbox, app_host_info_plist_path, app_host_target, '1.0.0', platform, diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb index a416cd047c..571f599cfd 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb @@ -377,7 +377,13 @@ def add_app_targets subspec_name = target.subspec_label(app_spec) app_target_label = target.app_target_label(app_spec) platform = target.platform - app_native_target = AppHostInstaller.new(sandbox, project, platform, subspec_name, spec_name, app_target_label).install! + app_native_target = AppHostInstaller.new(sandbox, + project, + platform, + subspec_name, + spec_name, + app_target_label, + false).install! target.user_build_configurations.each do |bc_name, type| app_native_target.add_build_configuration(bc_name, type) diff --git a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb index 0f0e99289d..97e47ec587 100644 --- a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb +++ b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb @@ -43,6 +43,19 @@ class PodsProjectGenerator ] end + it 'does not add main to the group' do + name = 'AppHost-PodName-iOS-Unit-Tests' + installer = AppHostInstaller.new(config.sandbox, @project, Platform.ios, + name, + 'Subgroup', + name) + installer.install! + @project.pod_group('Subgroup')[name].files.map(&:name).sort.should == [ + 'AppHost-PodName-iOS-Unit-Tests-Info.plist', + 'LaunchScreen.storyboard', + ] + end + it 'sets the correct build settings for an iOS app host target' do installer = AppHostInstaller.new(config.sandbox, @project, Platform.ios, 'AppHost-PodName-iOS-Unit-Tests', From ee43cd8b03d3619de6d4f608cd5c81b1af6b7f5b Mon Sep 17 00:00:00 2001 From: Derek Ostrander Date: Tue, 30 Oct 2018 14:37:04 -0700 Subject: [PATCH 2/6] Fix changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec99effb6d..728ce27302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,10 +16,19 @@ To install release candidates run `[sudo] gem install cocoapods --pre` [Derek Ostrander](https://github.com/dostrander) [#8158](https://github.com/CocoaPods/CocoaPods/pull/8158) +* Don't add main for app specs. + [Derek Ostrander](https://github.com/dostrander) + [#8235](https://github.com/CocoaPods/CocoaPods/pull/8235) + * Add documentation for the Podfile installation options [Eric Amorde](https://github.com/amorde) [#8198](https://github.com/CocoaPods/CocoaPods/issues/8198) [guides.cocoapods.org #142](https://github.com/CocoaPods/guides.cocoapods.org/issues/142) + +* Adds app spec project integration. + [Derek Ostrander](https://github.com/dostrander) + [#8158](https://github.com/CocoaPods/CocoaPods/pull/8158) + * None. From df635edbdfe01e27bc80b1b9843f1a102ce53c49 Mon Sep 17 00:00:00 2001 From: Derek Ostrander Date: Tue, 30 Oct 2018 14:39:08 -0700 Subject: [PATCH 3/6] Fix spec --- .../xcode/pods_project_generator/app_host_installer_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb index 97e47ec587..b2c5c36c1c 100644 --- a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb +++ b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb @@ -48,7 +48,8 @@ class PodsProjectGenerator installer = AppHostInstaller.new(config.sandbox, @project, Platform.ios, name, 'Subgroup', - name) + name, + false) installer.install! @project.pod_group('Subgroup')[name].files.map(&:name).sort.should == [ 'AppHost-PodName-iOS-Unit-Tests-Info.plist', From a9a0095ed7623e202d9fe701ac38c50b2ec8ef3c Mon Sep 17 00:00:00 2001 From: Derek Ostrander Date: Tue, 30 Oct 2018 15:13:33 -0700 Subject: [PATCH 4/6] run rubocoop --- .../xcode/pods_project_generator/app_host_installer.rb | 1 - .../xcode/pods_project_generator/app_host_installer_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb index 2f19640dac..839c02f51d 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb @@ -72,7 +72,6 @@ def install! configuration.build_settings['CURRENT_PROJECT_VERSION'] = '1' end - Pod::Generator::AppTargetHelper.add_app_host_main_file(project, app_host_target, platform_name, @group, app_target_label) if add_main Pod::Generator::AppTargetHelper.add_launchscreen_storyboard(project, app_host_target, @group, app_target_label) if platform == :ios additional_entries = platform == :ios ? ADDITIONAL_IOS_INFO_PLIST_ENTRIES : {} diff --git a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb index b2c5c36c1c..65bef7026c 100644 --- a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb +++ b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb @@ -52,8 +52,8 @@ class PodsProjectGenerator false) installer.install! @project.pod_group('Subgroup')[name].files.map(&:name).sort.should == [ - 'AppHost-PodName-iOS-Unit-Tests-Info.plist', - 'LaunchScreen.storyboard', + 'AppHost-PodName-iOS-Unit-Tests-Info.plist', + 'LaunchScreen.storyboard', ] end From b36ed84d9a26f486ff1e8d776457e4efc2c0b0e6 Mon Sep 17 00:00:00 2001 From: Derek Ostrander Date: Wed, 31 Oct 2018 08:35:13 -0700 Subject: [PATCH 5/6] PR Feedback --- CHANGELOG.md | 15 ++++----------- .../pods_project_generator/app_host_installer.rb | 4 ++-- .../pod_target_installer.rb | 2 +- .../app_host_installer_spec.rb | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 728ce27302..cb50dfe5bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,18 +8,14 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Enhancements -* Multiple Swift versions support - [Dimitris Koutsogiorgas](https://github.com/dnkoutso) - [#8191](https://github.com/CocoaPods/CocoaPods/issues/8191) - -* Adds app spec project integration. - [Derek Ostrander](https://github.com/dostrander) - [#8158](https://github.com/CocoaPods/CocoaPods/pull/8158) - * Don't add main for app specs. [Derek Ostrander](https://github.com/dostrander) [#8235](https://github.com/CocoaPods/CocoaPods/pull/8235) +* Multiple Swift versions support + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#8191](https://github.com/CocoaPods/CocoaPods/issues/8191) + * Add documentation for the Podfile installation options [Eric Amorde](https://github.com/amorde) [#8198](https://github.com/CocoaPods/CocoaPods/issues/8198) @@ -29,9 +25,6 @@ To install release candidates run `[sudo] gem install cocoapods --pre` [Derek Ostrander](https://github.com/dostrander) [#8158](https://github.com/CocoaPods/CocoaPods/pull/8158) - -* None. - ##### Bug Fixes * None. diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb index 839c02f51d..6c6edeaadc 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb @@ -33,7 +33,7 @@ class AppHostInstaller # attr_reader :app_target_label - # @return [Boolean] whether the app host installer should add main + # @return [Boolean] whether the app host installer should add main.m # attr_reader :add_main @@ -47,7 +47,7 @@ class AppHostInstaller # @param [String] app_target_label see #app_target_label # @param [Boolean] add_main see #add_main # - def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main = true) + def initialize(sandbox, project, platform, subgroup_name, group_name, app_target_label, add_main: true) @sandbox = sandbox @project = project @platform = platform diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb index 571f599cfd..59ec1e3dd7 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb @@ -383,7 +383,7 @@ def add_app_targets subspec_name, spec_name, app_target_label, - false).install! + :add_main => false).install! target.user_build_configurations.each do |bc_name, type| app_native_target.add_build_configuration(bc_name, type) diff --git a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb index 65bef7026c..3d54573e4c 100644 --- a/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb +++ b/spec/unit/installer/xcode/pods_project_generator/app_host_installer_spec.rb @@ -49,7 +49,7 @@ class PodsProjectGenerator name, 'Subgroup', name, - false) + :add_main => false) installer.install! @project.pod_group('Subgroup')[name].files.map(&:name).sort.should == [ 'AppHost-PodName-iOS-Unit-Tests-Info.plist', From 566fd47664d416fef6296a3254c7d26ad93163e4 Mon Sep 17 00:00:00 2001 From: Derek Ostrander Date: Fri, 2 Nov 2018 12:49:12 -0700 Subject: [PATCH 6/6] Fix changelog --- CHANGELOG.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb50dfe5bc..4171e14b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,20 +10,22 @@ To install release candidates run `[sudo] gem install cocoapods --pre` * Don't add main for app specs. [Derek Ostrander](https://github.com/dostrander) - [#8235](https://github.com/CocoaPods/CocoaPods/pull/8235) + [#8235](https://github.com/CocoaPods/CocoaPods/pull/8235)st * Multiple Swift versions support [Dimitris Koutsogiorgas](https://github.com/dnkoutso) [#8191](https://github.com/CocoaPods/CocoaPods/issues/8191) +* Adds app spec project integration. + [Derek Ostrander](https://github.com/dostrander) + [#8158](https://github.com/CocoaPods/CocoaPods/pull/8158) + * Add documentation for the Podfile installation options [Eric Amorde](https://github.com/amorde) [#8198](https://github.com/CocoaPods/CocoaPods/issues/8198) [guides.cocoapods.org #142](https://github.com/CocoaPods/guides.cocoapods.org/issues/142) - -* Adds app spec project integration. - [Derek Ostrander](https://github.com/dostrander) - [#8158](https://github.com/CocoaPods/CocoaPods/pull/8158) + +* None. ##### Bug Fixes