Class: Pod::Command::Util::XCFramework
- Inherits:
-
Pod::Command::Util
- Object
- Pod::Command
- Pod::Command::Util
- Pod::Command::Util::XCFramework
- Defined in:
- lib/cocoapods-util/command/xcframework/xcframework.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ XCFramework
constructor
A new instance of XCFramework.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ XCFramework
Returns a new instance of XCFramework.
22 23 24 25 26 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 22 def initialize(argv) @file_path = argv.shift_argument @force = argv.flag?('force') super end |
Class Method Details
.options ⇒ Object
16 17 18 19 20 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 16 def self. [ ['--force', '覆盖已经存在的文件'] ] end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 33 def run # 获取真实路径,~ 为进程所有者的主目录 @file_path = File.(@file_path) if !File.exist?(@file_path) || !(@file_path =~ /\.framework$/) help! "路径不存在或传入的路径不是framework文件" return end source_dir = File.dirname(@file_path) framework_name = File.basename(@file_path, ".framework") target_dir = "#{source_dir}/#{framework_name}.xcframework" if File.exist?(target_dir) if @force Pathname.new(target_dir).rmtree else help! "#{target_dir}已经存在,使用`--force`可以覆盖已有文件" end end builder = XCFrameworkBuilder.new( framework_name, source_dir ) builder.build_static_xcframework end |
#validate! ⇒ Object
28 29 30 31 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 28 def validate! super help! '必须传入framework路径或名称.' unless @file_path end |