diff --git a/.github/workflows/Specs.yml b/.github/workflows/Specs.yml index f47cf2b..a6aa41c 100644 --- a/.github/workflows/Specs.yml +++ b/.github/workflows/Specs.yml @@ -6,7 +6,7 @@ jobs: fail-fast: false matrix: task: [SPECS] - ruby: [2.6, 2.7] + ruby: ['2.7', '3.0'] os: [ubuntu-20.04] name: ${{ matrix.task }} / ${{ matrix.os }} / Ruby ${{ matrix.ruby }} diff --git a/Gemfile b/Gemfile index 1812ba0..a70ada1 100644 --- a/Gemfile +++ b/Gemfile @@ -6,10 +6,12 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } gemspec -gem 'clintegracon', '~> 0.9.0' +gem 'bacon', git: 'https://github.com/leahneukirchen/bacon' +gem 'clintegracon', git: 'https://github.com/mrackwitz/CLIntegracon' gem 'cocoapods', github: 'CocoaPods/CocoaPods' gem 'cocoapods-core', github: 'CocoaPods/Core' gem 'inch_by_inch', '~> 1.0.1' gem 'prettybacon' +gem 'rexml' gem 'rspec', '~> 3.10' gem 'rubocop', '~> 0.55.0' diff --git a/Gemfile.lock b/Gemfile.lock index 868d088..713750d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,10 +36,24 @@ GIT public_suffix typhoeus (~> 1.0) +GIT + remote: https://github.com/leahneukirchen/bacon + revision: 34068e01b6cc8b83f744b28e8ae7b4fd07affccb + specs: + bacon (1.2.0) + +GIT + remote: https://github.com/mrackwitz/CLIntegracon + revision: ca88b7b8920b6b6542f9b4ad2b1748855783dbae + specs: + clintegracon (0.9.0) + colored2 (~> 3.1) + diffy + PATH remote: . specs: - cocoapods-generate (2.2.3) + cocoapods-generate (2.2.4) cocoapods-disable-podfile-validations (>= 0.1.1, < 0.3.0) GEM @@ -58,11 +72,7 @@ GEM json (>= 1.5.1) ast (2.4.0) atomos (0.1.3) - bacon (1.2.0) claide (1.0.3) - clintegracon (0.9.0) - colored2 (~> 3.1) - diffy cocoapods-deintegrate (1.0.4) cocoapods-disable-podfile-validations (0.2.0) cocoapods-downloader (1.4.0) @@ -73,7 +83,7 @@ GEM nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.2.0) - coderay (1.1.2) + coderay (1.1.3) colored2 (3.1.2) concurrent-ruby (1.1.6) diff-lcs (1.4.4) @@ -97,8 +107,8 @@ GEM inch (~> 0.8.0) rake (~> 10.0) json (2.3.1) - method_source (0.9.0) - minitest (5.14.1) + method_source (1.0.0) + minitest (5.17.0) molinillo (0.6.6) nanaimo (0.3.0) nap (1.1.0) @@ -109,12 +119,13 @@ GEM powerpack (0.1.1) prettybacon (0.0.2) bacon (~> 1.2) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) public_suffix (4.0.6) rainbow (3.0.0) rake (10.5.0) + rexml (3.2.5) rspec (3.10.0) rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) @@ -138,37 +149,43 @@ GEM ruby-macho (1.4.0) ruby-progressbar (1.9.0) sparkr (0.4.1) - term-ansicolor (1.6.0) + sync (0.5.0) + term-ansicolor (1.7.1) tins (~> 1.0) thread_safe (0.3.6) - tins (1.16.3) + tins (1.32.1) + sync typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (1.2.10) thread_safe (~> 0.1) unicode-display_width (1.3.0) + webrick (1.7.0) xcodeproj (1.17.1) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) - yard (0.9.20) + yard (0.9.28) + webrick (~> 1.7.0) PLATFORMS ruby DEPENDENCIES + bacon! bundler (>= 1.16, < 3) - clintegracon (~> 0.9.0) + clintegracon! cocoapods! cocoapods-core! cocoapods-generate! inch_by_inch (~> 1.0.1) prettybacon rake (~> 10.0) + rexml rspec (~> 3.10) rubocop (~> 0.55.0) BUNDLED WITH - 1.17.3 + 2.3.26 diff --git a/VERSION b/VERSION index 5859406..530cdd9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.3 +2.2.4 diff --git a/lib/cocoapods/generate/installer.rb b/lib/cocoapods/generate/installer.rb index 8fb9d0d..af4ced6 100644 --- a/lib/cocoapods/generate/installer.rb +++ b/lib/cocoapods/generate/installer.rb @@ -187,7 +187,7 @@ def perform_post_install_steps(app_project, installer) native_app_target.resources_build_phase.clear if (app_host_source_dir = configuration.app_host_source_dir) - relative_app_host_source_dir = app_host_source_dir.relative_path_from(installer.sandbox.root) + relative_app_host_source_dir = app_host_source_dir.relative_path_from(install_directory) groups = {} app_host_source_dir.find do |file| diff --git a/spec/cocoapods/generate/installer_spec.rb b/spec/cocoapods/generate/installer_spec.rb index 5056db1..1a85bf5 100644 --- a/spec/cocoapods/generate/installer_spec.rb +++ b/spec/cocoapods/generate/installer_spec.rb @@ -25,7 +25,8 @@ def native_target_double(name, project) let(:podspecs) { [Pod::Spec.new(nil, 'A'), Pod::Spec.new(nil, 'B')] } let(:lockfile_specs) { [] } - let(:gen_directory) { Pathname('./spec/cocoapods/generate/gen') } + let(:repo_root) { Pathname('./spec/cocoapods').expand_path } + let(:gen_directory) { repo_root + Pathname('generate/gen') } let(:lockfile) { Pod::Lockfile.generate(podfile, lockfile_specs, {}) } let(:config_options) do { podfile: podfile, lockfile: lockfile, use_podfile: !!podfile, @@ -47,8 +48,10 @@ def native_target_double(name, project) end describe_method 'perform_post_install_steps' do + let(:project_root) { gen_directory + 'Workspace' } + let(:project_path) { project_root + 'AppProject.xcodeproj' } let(:app_project) do - app_project = Xcodeproj::Project.new(Pathname.new(gen_directory + 'AppProject.xcodeproj')) + app_project = Xcodeproj::Project.new(project_path) app_project.new_target(:application, 'App-iOS', :ios) app_project end @@ -67,6 +70,7 @@ def native_target_double(name, project) let(:cocoapods_installer) do installer = double('cocoapods_installer') allow(installer).to receive(:pod_targets).and_return([pod_target_a, pod_target_b]) + allow(installer).to receive(:sandbox).and_return(double('sandbox', root: project_root + 'Pods')) allow(installer).to receive(:target_installation_results).and_return( Pod::Installer::Xcode::PodsProjectGenerator::InstallationResults.new(pod_target_installation_results) ) @@ -103,6 +107,36 @@ def native_target_double(name, project) end end end + + context 'with app_host_source_dir' do + let(:app_host_source_dir) { repo_root + Pathname('sample_app_host') } + let(:app_target_name) { 'App-iOS' } + let(:config_options) do + { podfile: podfile, lockfile: lockfile, use_podfile: !!podfile, + use_lockfile_versions: !!lockfile, gen_directory: gen_directory, + app_host_source_dir: app_host_source_dir} + end + + it 'places the sources relative to the project root' do + allow(File).to receive(:exist?).with(Xcodeproj::XCScheme.user_data_dir(pods_project.path) + 'A.xcscheme').and_return(true) + allow(File).to receive(:exist?).with(Xcodeproj::XCScheme.user_data_dir(pods_project.path) + 'B.xcscheme').and_return(true) + allow(Xcodeproj::XCScheme).to receive(:share_scheme).with(pods_project.path, 'A') + allow(Xcodeproj::XCScheme).to receive(:share_scheme).with(pods_project.path, 'B') + + allow(File).to receive(:exist?).with(app_host_source_dir.to_s).and_return(true) + + subject + + app_target = app_project.groups.find { |g| g.name == app_target_name } + expect(app_project.path).to eq project_path + expect(app_target.real_path).to eq app_host_source_dir + expect(app_target.children.map { |c| c.real_path }).to contain_exactly( + app_host_source_dir + 'AppDelegate.swift', + project_root + app_target_name + 'Info.plist', + project_root + app_target_name + 'LaunchScreen.storyboard' + ) + end + end end describe_method 'create_app_project' do diff --git a/spec/cocoapods/sample_app_host/AppDelegate.swift b/spec/cocoapods/sample_app_host/AppDelegate.swift new file mode 100644 index 0000000..b355557 --- /dev/null +++ b/spec/cocoapods/sample_app_host/AppDelegate.swift @@ -0,0 +1,7 @@ +import MarketLogging + +@UIApplicationMain +class AppDelegate: UIApplicationDelegate { + init() { + } +} diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1b1857a..de13b71 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -73,6 +73,7 @@ def print(message) config.expect_with :rspec do |c| c.syntax = :expect + c.max_formatted_output_length = 1000 end config.extend(Module.new do