Class: BB::PodUtils
- Inherits:
-
Object
- Object
- BB::PodUtils
- Defined in:
- lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb
Class Method Summary collapse
-
.above_xcode_16_version ⇒ Object
xcode16以上.
-
.below_xcode_15_version ⇒ Object
xcode15以下.
-
.below_xcode_16_version ⇒ Object
xcode16以下.
-
.compare_xcode_14_version ⇒ Object
xcode14以上,14以后不再支持armv7(32位设备).
-
.compare_xcode_15_version ⇒ Object
xcode15以上.
-
.getInfoPlistPath ⇒ Object
获取info配置文件路径.
-
.getProjectBundleIdentifier ⇒ Object
获取包名.
-
.getProjectDevelopmentTeam ⇒ Object
证书团队id.
-
.getProjectPath ⇒ Object
获取工程路径.
-
.getProjectRootPath ⇒ Object
获取工程根目录路径.
-
.getValueFromInfoPlist(key) ⇒ Object
获取info配置key对应的值.
-
.getXcodeprojPath ⇒ Object
xcode目录.
-
.xcode_version ⇒ Object
获取Xcode版本.
Class Method Details
.above_xcode_16_version ⇒ Object
xcode16以上
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 162 def self.above_xcode_16_version current_version = xcode_version if current_version.nil? puts "未找到安装的Xcode版本。".red else puts "当前Xcode版本:#{current_version}" num_ver = current_version.to_i return num_ver >= 16 end return false end |
.below_xcode_15_version ⇒ Object
xcode15以下
142 143 144 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 142 def self.below_xcode_15_version return !compare_xcode_15_version end |
.below_xcode_16_version ⇒ Object
xcode16以下
158 159 160 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 158 def self.below_xcode_16_version return !above_xcode_16_version end |
.compare_xcode_14_version ⇒ Object
xcode14以上,14以后不再支持armv7(32位设备)
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 130 def self.compare_xcode_14_version current_version = xcode_version if current_version.nil? puts "未找到安装的Xcode版本。".red else puts "当前Xcode版本:#{current_version}" num_ver = current_version.to_i return num_ver >= 14 end return false end |
.compare_xcode_15_version ⇒ Object
xcode15以上
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 146 def self.compare_xcode_15_version current_version = xcode_version if current_version.nil? puts "未找到安装的Xcode版本。".red else puts "当前Xcode版本:#{current_version}" num_ver = current_version.to_i return num_ver >= 15 end return false end |
.getInfoPlistPath ⇒ Object
获取info配置文件路径
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 75 def self.getInfoPlistPath path = File.join(getProjectPath, "bbframework/Resources/Info.plist") if File.exist?(path) return path end info_path = "" # 定义搜索目录 search_dir = getProjectPath # 使用 Find 模块来递归搜索目录中的文件 Find.find(search_dir) do |path| name = File.basename(path) # 排除 pods 文件夹 if FileTest.directory?(path) && (name == 'Pods' || name.include?('.xcodeproj') || name.include?('Tests')) Find.prune elsif FileTest.file?(path) && name == 'Info.plist' # 如果找到 Info.plist 文件,则输出其路径 puts "Info.plist 文件路径:#{path}" info_path = path end end if File.exist?(info_path) return info_path end puts "无法找打工程Info.plist配置文件,工程目录:#{getProjectPath} @hm确认".red return nil # raise Informative, "#{path} File no exist, please check" unless File.exist?(path) # return path end |
.getProjectBundleIdentifier ⇒ 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 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 33 def self.getProjectBundleIdentifier projectBundleIdentifierKey = "PRODUCT_BUNDLE_IDENTIFIER" value = getValueFromInfoPlist(projectBundleIdentifierKey) if #{value} == #{projectBundleIdentifierKey} project = Xcodeproj::Project.open(getXcodeprojPath) project.targets.each do |target| target.build_configurations.each do |config| value = config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] if value && !value.empty? break end end if value && !value.empty? break end end puts "xcodeproj BundleIdentifier:#{value}" return value else puts "info BundleIdentifier:#{value}" return value end end |
.getProjectDevelopmentTeam ⇒ Object
证书团队id
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 58 def self.getProjectDevelopmentTeam value = "" project = Xcodeproj::Project.open(getXcodeprojPath) project.targets.each do |target| target.build_configurations.each do |config| value = config.build_settings['DEVELOPMENT_TEAM'] if value && !value.empty? # 做你的处理 break end end end puts "xcodeproj DevelopmentTeam:#{value}" return value end |
.getProjectPath ⇒ Object
获取工程路径
18 19 20 21 22 23 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 18 def self.getProjectPath path = Dir.pwd # puts "Project Path:#{path}".yellow raise Informative, "#{path} File no exist, please check" unless File.exist?(path) return path end |
.getProjectRootPath ⇒ Object
获取工程根目录路径
11 12 13 14 15 16 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 11 def self.getProjectRootPath path = File.("..", getProjectPath) # puts "Project Root Path:#{path}".red raise Informative, "#{path} File no exist, please check" unless File.exist?(path) return path end |
.getValueFromInfoPlist(key) ⇒ Object
获取info配置key对应的值
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 104 def self.getValueFromInfoPlist(key) plistPath = getInfoPlistPath if !plistPath.nil? value = `/usr/libexec/PlistBuddy -c "Print #{key}" #{plistPath}` value = value.rstrip() puts "#{key} => #{value}" return value end return "" end |
.getXcodeprojPath ⇒ Object
xcode目录
25 26 27 28 29 30 31 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 25 def self.getXcodeprojPath name = Dir.glob("*.xcodeproj")[0] path = File.join(getProjectPath, name) # puts "xcodeproj:#{path}" raise Informative, "#{path} File no exist, please check" unless File.exist?(path) return path end |
.xcode_version ⇒ Object
获取Xcode版本
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb', line 115 def self.xcode_version xcode_version_output = `xcode-select -p` return nil if xcode_version_output.empty? xcode_path = xcode_version_output.chomp version_output = `xcodebuild -version` # Extract the Xcode version number version_match = version_output.match(/Xcode (\d+(\.\d+)+)/) return nil if version_match.nil? xcode_version = version_match[1] return xcode_version end |