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.
24 25 26 27 28 29 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 24 def initialize(argv) @file_path = argv.shift_argument @force = argv.flag?('force') @create_swiftinterface = argv.flag?('create-swiftinterface') super end |
Class Method Details
.options ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 16 def self. [ ['--force', '覆盖已经存在的文件'], ['--create-swiftinterface', '有编译swift文件的framework,如果不包含swiftinterface则无法生成xcframework。 设置该参数会生成一个swiftinterface文件解决create失败的问题。'] ] end |
Instance Method Details
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 36 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, @create_swiftinterface ) builder.build_static_xcframework end |
#validate! ⇒ Object
31 32 33 34 |
# File 'lib/cocoapods-util/command/xcframework/xcframework.rb', line 31 def validate! super help! '必须传入framework路径或名称.' unless @file_path end |