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 |
# 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 super end |
Class Method Details
.options ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 48 def self. [ ['--framework', 'Used to generate the framework '], ['--xcframework', 'Used to generate the xcframework '], ['--sources', 'The sources from which to pull dependent pods '] ].concat(super).reject { |(name, _)| name == 'name' } end |
Instance Method Details
#build_binary ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 86 def build_binary project_dir = File.join(@build_dir, 'project') Dir.chdir(project_dir) binary_type = @xcframework ? BinaryType::XCFRAMEWORK : BinaryType::FRAMEWORK build_binary = BuildBinary.new(binary_type) build_binary.build end |
#export_binary ⇒ Object
94 95 96 97 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 94 def export_binary export_dir = @config_instance.root_dir FileUtils.cp_r("#{@build_dir}/#{@pod_name}", export_dir) end |
#generate_project ⇒ Object
82 83 84 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 82 def generate_project BuildProject.new.generate_project end |
#init_config ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 72 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 end |
#prepare ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 63 def prepare puts 'prepare begin' init_config MBuildFileUtils.create_folder(@build_dir) Dir.chdir(@build_dir) BuildProject.new.prepare_project puts 'prepare end' end |
#run ⇒ Object
56 57 58 59 60 61 |
# File 'lib/cocoapods-podspec-binary/command/mbuild.rb', line 56 def run prepare generate_project build_binary export_binary end |