Class: BuildProject
- Defined in:
- lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb
Overview
Class prepare project
Instance Method Summary collapse
- #add_build_settings ⇒ Object
- #build_settings_code ⇒ Object
- #generate_project ⇒ Object
-
#initialize ⇒ BuildProject
constructor
A new instance of BuildProject.
- #prepare_project ⇒ Object
- #project_install ⇒ Object
- #update_podfile ⇒ Object
Constructor Details
#initialize ⇒ BuildProject
Returns a new instance of BuildProject.
7 8 9 10 |
# File 'lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb', line 7 def initialize @config_instance = MBuildConfig.instance @project_dir = File.join(MBuildConfig.instance.mbuild_dir, 'BinaryProj/Example') end |
Instance Method Details
#add_build_settings ⇒ Object
53 54 55 56 57 |
# File 'lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb', line 53 def add_build_settings File.open('Podfile', 'a+') do |podfile| podfile.puts build_settings_code end end |
#build_settings_code ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb', line 59 def build_settings_code " post_install do |installer|\n installer.pods_project.targets.each do |target|\n target.build_configurations.each do |config|\n config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'\n end\n end\n end\n CODE\nend\n" |
#generate_project ⇒ Object
25 26 27 28 29 30 |
# File 'lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb', line 25 def generate_project config_instance = MBuildConfig.instance add_build_settings if config_instance.swift update_podfile project_install end |
#prepare_project ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb', line 12 def prepare_project example_dir = File.join(MBuildConfig.instance.mbuild_dir, 'BinaryProj') if File.directory?(example_dir) Git.open(example_dir).reset_hard Git.open(example_dir).clean(force: true) Git.open(example_dir).pull else MBuildFileUtils.create_folder(@project_dir) example_url = '[email protected]:HuolalaTech/hll-cocoapods-podspec-binary.git' Git.clone(example_url, example_dir) end end |
#project_install ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb', line 45 def project_install Dir.chdir(@project_dir) do update_argv = [] update_command = Pod::Command::Update.new(CLAide::ARGV.new(update_argv)) update_command.run end end |
#update_podfile ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cocoapods-podspec-binary/mbuild/mbuild_project.rb', line 32 def update_podfile podfile_path = File.join(@project_dir, 'Podfile') podfile_content = File.read(podfile_path) pod_name = @config_instance.pod_name pod_version = @config_instance.pod_version new_content = podfile_content.gsub('BINARY_NAME', pod_name).gsub('BINARY_VERSION', pod_version) if @config_instance.sources new_content.prepend(@config_instance.sources.split(',').map { |it| "source \"#{it.strip}\"\n" }.join) end File.open(podfile_path, 'w') { |file| file.puts new_content } end |