Skip to content

Commit

Permalink
Merge pull request #166 from square/jmartin/fix-app_host_source_dir
Browse files Browse the repository at this point in the history
Fix app_host_source_dir to find the sources relative to the correct root folder
  • Loading branch information
Justin Martin authored Feb 10, 2023
2 parents 164e8b6 + 29c4386 commit fc94b68
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
49 changes: 33 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.3
2.2.4
2 changes: 1 addition & 1 deletion lib/cocoapods/generate/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
38 changes: 36 additions & 2 deletions spec/cocoapods/generate/installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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)
)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/cocoapods/sample_app_host/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import MarketLogging

@UIApplicationMain
class AppDelegate: UIApplicationDelegate {
init() {
}
}
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc94b68

Please sign in to comment.