Class: Pod::Command::MBuild
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::MBuild
- Defined in:
- lib/cocoapods-podspec-binary/command/mbuild.rb
Overview
Create a PR to add your plugin to CocoaPods/cocoapods.org in the ‘plugins.json` file, once your plugin is released.
This is an example of a cocoapods plugin adding a top-level subcommand to the ‘pod’ command.
You can also create subcommands of existing or new commands. Say you wanted to add a subcommand to ‘list` to show newly deprecated pods, (e.g. `pod list deprecated`), there are a few things that would need to change.
-
move this file to ‘lib/pod/command/list/deprecated.rb` and update the class to exist in the the Pod::Command::List namespace
-
change this class to extend from ‘List` instead of `Command`. This tells the plugin system that it is a subcommand of `list`.
-
edit ‘lib/cocoapods_plugins.rb` to require this file
Class Method Summary collapse
Instance Method Summary collapse
- #build_binary ⇒ Object
- #export_binary ⇒ Object
- #generate_project ⇒ Object
- #init_config ⇒ Object
-
#initialize(argv) ⇒ MBuild
constructor
A new instance of MBuild.
- #prepare ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ MBuild
Returns a new instance of MBuild.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 38 def initialize(argv) @framework = argv.flag?('framework', true) @xcframework = argv.flag?('xcframework', false) @pod_name = argv.shift_argument @pod_version = argv.shift_argument @config_instance = MBuildConfig.instance @build_dir = @config_instance.mbuild_dir @sources = argv.option('sources') super end |
Class Method Details
.options ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 49 def self. [ ['--framework', 'Used to generate the framework '], ['--xcframework', 'Used to generate the xcframework '], ['--sources=[sources]', 'The sources from which to pull dependent pods '] ].concat(super).reject { |(name, _)| name == 'name' } end |
Instance Method Details
#build_binary ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 89 def build_binary puts "Commencing the build of #{@pod_name}:#{@pod_version}." project_dir = File.join(@build_dir, 'BinaryProj/Example') Dir.chdir(project_dir) binary_type = @xcframework ? BinaryType::XCFRAMEWORK : BinaryType::FRAMEWORK build_binary = BuildBinary.new(binary_type) build_binary.build puts "The successful build of the #{@pod_name}:#{@pod_version} #{@binary_type}." end |
#export_binary ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 99 def export_binary puts 'Exporting binary files.' export_dir = @config_instance.root_dir FileUtils.cp_r("#{@build_dir}/#{@pod_name}-#{@pod_version}", export_dir) FileUtils.rm_rf("#{@build_dir}/#{@pod_name}-#{@pod_version}") puts 'Task execution completed.' end |
#generate_project ⇒ Object
85 86 87 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 85 def generate_project BuildProject.new.generate_project end |
#init_config ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 71 def init_config mbuild_yml = File.join(Dir.pwd, '.mbuild.yml') if File.file?(mbuild_yml) @config_instance.load_config else @config_instance.command_config(@pod_name, @pod_version) end @config_instance.library_type = @xcframework ? BinaryType::XCFRAMEWORK : BinaryType::FRAMEWORK puts "Preparing to generate the binary version of #{@pod_name}:#{@pod_version}." return unless @sources @config_instance.sources = @sources end |
#prepare ⇒ Object
64 65 66 67 68 69 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 64 def prepare init_config MBuildFileUtils.create_folder(@build_dir) Dir.chdir(@build_dir) BuildProject.new.prepare_project end |
#run ⇒ Object
57 58 59 60 61 62 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 57 def run prepare generate_project build_binary export_binary end |