Skip to content

Commit

Permalink
copy modulemap file before excute xbuld command
Browse files Browse the repository at this point in the history
  • Loading branch information
HamGuy committed Jul 8, 2020
1 parent f95c6c2 commit c22fc93
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
33 changes: 32 additions & 1 deletion lib/cocoapods-packager/builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Pod
class Builder
def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps)
def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps,working_dir)
@platform = platform
@static_installer = static_installer
@source_dir = source_dir
Expand All @@ -14,6 +14,7 @@ def initialize(platform, static_installer, source_dir, static_sandbox_root, dyna
@config = config
@bundle_identifier = bundle_identifier
@exclude_deps = exclude_deps
@working_dir = working_dir

@file_accessors = @static_installer.pod_targets.select { |t| t.pod_name == @spec.name }.flat_map(&:file_accessors)
end
Expand Down Expand Up @@ -317,6 +318,7 @@ def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-pack
end

command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
copy_modulemap
output = `#{command}`.lines.to_a

if $?.exitstatus != 0
Expand All @@ -330,5 +332,34 @@ def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-pack
Process.exit
end
end

def copy_modulemap

spec_name = @spec.name
modulemap_soure_dir = "#{@source_dir}/Example/Pods/Target Support Files/#{spec_name}/#{spec_name}.modulemap"

if Dir.exist?(modulemap_soure_dir)
UI.puts("not exies expmle source dir")
modulemap_soure_dir = "#{@source_dir}/Pods/Target Support Files/#{spec_name}/#{spec_name}.modulemap"
end

unless Dir.exist?(modulemap_soure_dir)
directory_name = "#{@working_dir}/build/Pods.build/Release-iphonesimulator/#{spec_name}"
FileUtils.mkdir_p(directory_name) unless File.exists?(directory_name)

modulemap_target_dir = "#{directory_name}/#{spec_name}.modulemap"

UI.puts("copy file from #{modulemap_soure_dir} to #{modulemap_target_dir}")
FileUtils.cp(modulemap_soure_dir, modulemap_target_dir)

directory_name = "#{@working_dir}/build/Release-iphonesimulator/#{spec_name}"
FileUtils.mkdir_p(directory_name) unless File.exists?(directory_name)

modulemap_target_dir = "#{directory_name}/#{spec_name}.modulemap"

UI.puts("copy file from #{modulemap_soure_dir} to #{modulemap_target_dir}")
FileUtils.cp(modulemap_soure_dir, modulemap_target_dir)
end
end
end
end
5 changes: 4 additions & 1 deletion lib/pod/command/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def initialize(argv)
@spec = spec_with_path(@name)
@is_spec_from_path = true if @spec
@spec ||= spec_with_name(@name)
@working_dir = nil
super
end

Expand All @@ -77,6 +78,7 @@ def run

target_dir, work_dir = create_working_directory
return if target_dir.nil?
@working_dir = work_dir
build_package

`mv "#{work_dir}" "#{target_dir}"`
Expand Down Expand Up @@ -164,7 +166,8 @@ def perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
@dynamic,
@config,
@bundle_identifier,
@exclude_deps
@exclude_deps,
@working_dir
)

builder.build(@package_type)
Expand Down

0 comments on commit c22fc93

Please sign in to comment.