cocoapods-fy-bin 0.1.6 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0366cd54caf14a564266fc214c5d60fbe97d96773b4354ea0e69a0696160f41
4
- data.tar.gz: 6f8122f4f8f4e067f4e8f18163a930612fb8c5f2a452b7b8e81da4b98c6034b4
3
+ metadata.gz: 213c8226fe3dfbe423df192225e48ff350ca37494e79b7efc212c18f57698931
4
+ data.tar.gz: 1ab095c3672015afbeed53497a15127065f8076d3caeed0c1d985d6074bc71b1
5
5
  SHA512:
6
- metadata.gz: 0eb16f11626788cda94240af0e863cd41b1654a0245305c520c543205cdcfdf88f371cb96f680061f7ed0f9224e991b4a646ea5b197c3b373649cf57a3dd21f4
7
- data.tar.gz: f0a5bc9d0e07d5aa3edd87a9a21b1c1cb76d776b3e3b4acebfaa928f0c3194b2fd8218b31ed2852c2ce67ca405d96b4fa4bab8078d2b7b8475f4e1ebb26068aa
6
+ metadata.gz: 49037edd4a308d61702a13315c2d4071e68b43b7430f010a35632ce3dda73d3f014a4e274ba1d8ad1b755b9b0e75c3a9e5ef4daf4722730147a719c40f6eab09
7
+ data.tar.gz: e182deff9c70c7793daa6cade6f23a64cf94aad5e6080d6e1c88501c381e037354796394927371674d7ce9d2513e5f8330b1bc286b987c29bfc64b132426b45b
data/README.md CHANGED
@@ -1 +1,40 @@
1
+ ### 特色:
1
2
 
3
+ 1.**支持swift二进制化编译**
4
+
5
+ 2.**支持源码/二进制切换**
6
+
7
+ 3.**无入侵、不影响现有业务**
8
+
9
+ 关于 插件具体的架构部署实践和更详细的资源,可以参考
10
+
11
+ > [iOS编译速度如何稳定提高10倍以上](https://juejin.cn/post/6903407900006449160)
12
+ >
13
+ > [iOS美团同款"ZSource"二进制调试实现](https://juejin.im/post/5f066cfa5188252e893a136e)
14
+ >
15
+ > [iOS教你如何像RN一样实时编译](https://juejin.im/post/6850037272415813645)
16
+ >
17
+ > [Swift编译慢?请看这里,全套开源](https://juejin.im/post/6890419459639476237)
18
+ >
19
+ > [OC-Demo](https://github.com/su350380433/cocoapods-imy-bin-demo)
20
+ >
21
+ > [Swift-OC-Demo](https://github.com/su350380433/Swift-OC-Demo)
22
+
23
+
24
+
25
+
26
+
27
+ ## 一、使用教程
28
+
29
+ [使用教程](./使用教程.md)
30
+
31
+
32
+
33
+
34
+ ## 二、感谢
35
+
36
+ **[cocoapods-imy-bin](https://github.com/MeetYouDevs/cocoapods-imy-bin)**
37
+
38
+ **[cocoapods-bin](https://github.com/tripleCC/cocoapods-bin)**
39
+
40
+ [美团 iOS 工程 zsource 命令背后的那些事儿](https://tech.meituan.com/2019/08/08/the-things-behind-the-ios-project-zsource-command.html)
@@ -59,6 +59,7 @@ module Pod
59
59
  @archs = argv.option('archs', 'armv7,arm64')
60
60
  @pre_build_shell = argv.option('pre_build_shell') || ''
61
61
  @suf_build_shell = argv.option('suf_build_shell') || ''
62
+ @build_permission = argv.option('build_permission') || ''
62
63
  @toolchain = argv.option('toolchain') || ''
63
64
  @config = argv.option('configuration', 'Release')
64
65
 
@@ -96,6 +97,7 @@ module Pod
96
97
  @archs,
97
98
  @pre_build_shell,
98
99
  @suf_build_shell,
100
+ @build_permission,
99
101
  @toolchain,
100
102
  CBin::Config::Builder.instance.white_pod_list.include?(@spec.name),
101
103
  @config)
@@ -24,7 +24,8 @@ module Pod
24
24
  ['--archs', "需要二进制组件的架构"],
25
25
  ['--pre_build_shell', "xcodebuild前的脚本命令"],
26
26
  ['--suf_build_shell', "xcodebuild后的脚本命令"],
27
- ['--toolchain', "设置toolchain"]
27
+ ['--toolchain', "设置toolchain"],
28
+ ['--build_permission', "xcodebuild权限"]
28
29
  ].concat(Pod::Command::Gen.options).concat(super).uniq
29
30
  end
30
31
 
@@ -44,6 +45,7 @@ module Pod
44
45
  @archs = argv.flag?('archs', 'arm64')
45
46
  @pre_build_shell = argv.option('pre_build_shell') || ''
46
47
  @suf_build_shell = argv.option('suf_build_shell') || ''
48
+ @build_permission = argv.option('build_permission') || ''
47
49
  @toolchain = argv.option('toolchain') || ''
48
50
  @config = argv.option('configuration', 'Debug')
49
51
  @additional_args = argv.remainder!
@@ -138,6 +140,9 @@ module Pod
138
140
  if @suf_build_shell
139
141
  argvs += ["--suf_build_shell=#{@suf_build_shell}"]
140
142
  end
143
+ if @build_permission
144
+ argvs += ["--build_permission=#{@build_permission}"]
145
+ end
141
146
  if @toolchain
142
147
  argvs += ["--toolchain=#{@toolchain}"]
143
148
  end
@@ -1,12 +1,10 @@
1
1
 
2
- require 'cocoapods-fy-bin/command/bin/initHotKey'
3
2
  require 'cocoapods-fy-bin/command/bin/init'
4
3
  require 'cocoapods-fy-bin/command/bin/archive'
5
4
  require 'cocoapods-fy-bin/command/bin/auto'
6
5
  require 'cocoapods-fy-bin/command/bin/code'
7
6
  require 'cocoapods-fy-bin/command/bin/update'
8
7
  require 'cocoapods-fy-bin/command/bin/install'
9
- require 'cocoapods-fy-bin/command/bin/imy'
10
8
 
11
9
  require 'cocoapods-fy-bin/helpers'
12
10
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.9'
4
4
  end
5
5
 
6
6
  module Pod
@@ -22,6 +22,7 @@ module CBin
22
22
  archs,
23
23
  pre_build_shell,
24
24
  suf_build_shell,
25
+ build_permission,
25
26
  toolchain,
26
27
  skip_archive = false,
27
28
  build_model="Release")
@@ -33,6 +34,7 @@ module CBin
33
34
  @archs = archs
34
35
  @pre_build_shell = pre_build_shell
35
36
  @suf_build_shell = suf_build_shell
37
+ @build_permission = build_permission
36
38
  @toolchain = toolchain
37
39
  @skip_archive = skip_archive
38
40
  @framework_output = framework_output
@@ -62,7 +64,7 @@ module CBin
62
64
  source_dir = Dir.pwd
63
65
  file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
64
66
  Dir.chdir(workspace_directory) do
65
- builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir, @archs, @pre_build_shell, @suf_build_shell, @toolchain, @isRootSpec, @build_model)
67
+ builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir, @archs, @pre_build_shell, @suf_build_shell, @build_permission, @toolchain, @isRootSpec, @build_model)
66
68
  @@build_defines = builder.build if @isRootSpec
67
69
  begin
68
70
  @framework_path = builder.lipo_build(@@build_defines) unless @skip_archive
@@ -76,7 +78,7 @@ module CBin
76
78
  source_dir = zip_dir
77
79
  file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
78
80
  Dir.chdir(workspace_directory) do
79
- builder = CBin::Library::Builder.new(@spec, file_accessor, @platform, source_dir , @archs, @pre_build_shell, @framework_path)
81
+ builder = CBin::Library::Builder.new(@spec, file_accessor, @platform, source_dir , @archs, @framework_path)
80
82
  builder.build
81
83
  end
82
84
  end
@@ -10,7 +10,7 @@ module CBin
10
10
  class Builder
11
11
  include Pod
12
12
  #Debug下还待完成
13
- def initialize(spec, file_accessor, platform, source_dir, archs, pre_build_shell, suf_build_shell, toolchain, isRootSpec = true, build_model="Debug")
13
+ def initialize(spec, file_accessor, platform, source_dir, archs, pre_build_shell, suf_build_shell, build_permission, toolchain, isRootSpec = true, build_model="Debug")
14
14
  @spec = spec
15
15
  @source_dir = source_dir
16
16
  @file_accessor = file_accessor
@@ -20,6 +20,7 @@ module CBin
20
20
  @archs = archs
21
21
  @pre_build_shell = pre_build_shell
22
22
  @suf_build_shell = suf_build_shell
23
+ @build_permission = build_permission
23
24
  @toolchain = toolchain
24
25
  #vendored_static_frameworks 只有 xx.framework 需要拼接为 xx.framework/xx by slj
25
26
  vendored_static_frameworks = file_accessor.vendored_static_frameworks.map do |framework|
@@ -177,15 +178,16 @@ module CBin
177
178
  defines += "GCC_PREPROCESSOR_DEFINITIONS='$(inherited)'"
178
179
  defines += " SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited)' "
179
180
  defines += @spec.consumer(@platform).compiler_flags.join(' ')
180
- options = ios_build_options
181
+ # options = ios_build_options
181
182
  # if is_debug_model
182
183
  archs = ios_architectures
183
184
  # archs = %w[arm64 armv7 armv7s]
184
185
  pre_build_command
185
186
  archs.map do |arch|
186
- # -fembed-bitcode支持bitcode BUILD_LIBRARY_FOR_DISTRIBUTION=YES 构建向后兼容的framework
187
+ # -fembed-bitcode包含bitcode BUILD_LIBRARY_FOR_DISTRIBUTION=YES 构建向后兼容的framework
187
188
  xcodebuild(defines, "ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\' DEBUG_INFORMATION_FORMAT=\'dwarf-with-dsym\' BUILD_LIBRARY_FOR_DISTRIBUTION=YES","build-#{arch}",@build_model)
188
189
  end
190
+ suf_build_command
189
191
  # else
190
192
  # xcodebuild(defines,options)
191
193
  # end
@@ -250,10 +252,10 @@ module CBin
250
252
  def xcodebuild(defines = '', args = '', build_dir = 'build', build_model = 'Debug')
251
253
 
252
254
  unless File.exist?("Pods.xcodeproj") #cocoapods-generate v2.0.0
253
- command = "sudo xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{File.join(File.expand_path("..", build_dir), File.basename(build_dir))} clean build -configuration #{build_model} -target #{target_name} -project ./Pods/Pods.xcodeproj 2>&1"
255
+ command = "#{@build_permission}xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{File.join(File.expand_path("..", build_dir), File.basename(build_dir))} clean build -configuration #{build_model} -target #{target_name} -project ./Pods/Pods.xcodeproj 2>&1"
254
256
  puts command
255
257
  else
256
- command = "sudo xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{build_model} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
258
+ command = "#{@build_permission}xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{build_model} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
257
259
  puts command
258
260
  end
259
261
 
@@ -11,14 +11,13 @@ module CBin
11
11
  class Builder
12
12
  include Pod
13
13
 
14
- def initialize(spec, file_accessor, platform, source_dir, archs, pre_build_shell, framework_path)
14
+ def initialize(spec, file_accessor, platform, source_dir, archs, framework_path)
15
15
  @spec = spec
16
16
  @source_dir = source_dir
17
17
  @file_accessor = file_accessor
18
18
  @platform = platform
19
19
  @framework = framework_path
20
20
  @archs = archs
21
- @pre_build_shell = pre_build_shell
22
21
  @source_files = "#{@source_dir}/#{library.name_path}"
23
22
  @source_zip_file = "#{@source_files}.zip"
24
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-fy-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - dr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-07 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -110,9 +110,7 @@ files:
110
110
  - lib/cocoapods-fy-bin/command/bin/archive.rb
111
111
  - lib/cocoapods-fy-bin/command/bin/auto.rb
112
112
  - lib/cocoapods-fy-bin/command/bin/code.rb
113
- - lib/cocoapods-fy-bin/command/bin/imy.rb
114
113
  - lib/cocoapods-fy-bin/command/bin/init.rb
115
- - lib/cocoapods-fy-bin/command/bin/initHotKey.rb
116
114
  - lib/cocoapods-fy-bin/command/bin/install.rb
117
115
  - lib/cocoapods-fy-bin/command/bin/lib/lint.rb
118
116
  - lib/cocoapods-fy-bin/command/bin/repo/update.rb
@@ -122,8 +120,6 @@ files:
122
120
  - lib/cocoapods-fy-bin/config/config.rb
123
121
  - lib/cocoapods-fy-bin/config/config_asker.rb
124
122
  - lib/cocoapods-fy-bin/config/config_builder.rb
125
- - lib/cocoapods-fy-bin/config/config_hot_key.rb
126
- - lib/cocoapods-fy-bin/config/config_hot_key_asker.rb
127
123
  - lib/cocoapods-fy-bin/gem_version.rb
128
124
  - lib/cocoapods-fy-bin/helpers.rb
129
125
  - lib/cocoapods-fy-bin/helpers/build_helper.rb
@@ -1,46 +0,0 @@
1
- require 'cocoapods-fy-bin/config/config_hot_key_asker'
2
-
3
- module Pod
4
- class Command
5
- class Bin < Command
6
- class Imy < Bin
7
- self.summary = '快捷键'
8
- self.description = <<-DESC
9
- 创建 文件,在其中保存插件需要的配置信息,
10
- 如二进制私有源地址、源码私有源地址等。
11
- DESC
12
-
13
- self.arguments = [
14
- CLAide::Argument.new('1', false)
15
- ]
16
-
17
- def self.options
18
- [
19
- ].concat(super)
20
- end
21
-
22
- def initialize(argv)
23
- @hot_key = argv.shift_argument || '1'
24
- super
25
- end
26
-
27
- def run
28
- CBin.config_hot_key.set_hot_key_index(@hot_key)
29
- UI.puts "cd #{CBin.config_hot_key.hot_key_dir}".yellow
30
-
31
- if Dir.exist?(CBin.config_hot_key.hot_key_dir)
32
- Dir.chdir(CBin.config_hot_key.hot_key_dir) do
33
- UI.puts " #{CBin.config_hot_key.hot_key_cmd}".yellow
34
- system CBin.config_hot_key.hot_key_cmd
35
- end
36
- else
37
- raise "配置项中文件目录不存在 #{CBin.config_hot_key.hot_key_dir}"
38
- end
39
-
40
-
41
- end
42
-
43
- end
44
- end
45
- end
46
- end
@@ -1,70 +0,0 @@
1
-
2
- require 'cocoapods-fy-bin/config/config_hot_key_asker'
3
-
4
- module Pod
5
- class Command
6
- class Bin < Command
7
- class Inithk < Bin
8
- self.summary = '初始化快捷键配置.'
9
- self.description = <<-DESC
10
- 创建 文件,在其中保存插件需要的配置信息,
11
- 如二进制私有源地址、源码私有源地址等。
12
- DESC
13
-
14
- def self.options
15
- [
16
- ['--bin-url=URL', '配置文件地址,直接从此地址下载配置文件']
17
- ].concat(super)
18
- end
19
-
20
- def initialize(argv)
21
- @bin_url = argv.option('bin-url')
22
- super
23
- end
24
-
25
- def run
26
- if @bin_url.nil?
27
- config_with_asker
28
- else
29
- config_with_url(@bin_url)
30
- end
31
- end
32
-
33
- private
34
-
35
- def config_with_url(url)
36
- require 'open-uri'
37
-
38
- UI.puts "开始下载配置文件...\n"
39
- file = open(url)
40
- contents = YAML.safe_load(file.read)
41
-
42
- UI.puts "开始同步配置文件...\n"
43
- CBin.config_hot_key.sync_config(contents.to_hash)
44
- UI.puts "设置完成.\n".green
45
- rescue Errno::ENOENT => e
46
- raise Informative, "配置文件路径 #{url} 无效,请确认后重试."
47
- end
48
-
49
- def config_with_asker
50
- asker = CBin::Config_Hot_Key::Asker.new
51
- asker.wellcome_message
52
-
53
- config = {}
54
- template_hash = CBin.config_hot_key.template_hash
55
- template_hash.each do |k, v|
56
- default = begin
57
- CBin.config_hot_key.send(k)
58
- rescue StandardError
59
- nil
60
- end
61
- config[k] = asker.ask_with_answer(v[:description], default, v[:selection])
62
- end
63
-
64
- CBin.config_hot_key.sync_config(config)
65
- asker.done_message
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,103 +0,0 @@
1
- require 'yaml'
2
- require 'cocoapods-fy-bin/native/podfile'
3
- require 'cocoapods-fy-bin/native/podfile_env'
4
- require 'cocoapods/generate'
5
-
6
- module CBin
7
- class Config_Hot_Key
8
-
9
- def config_file
10
- config_file_with_hot_key_index(hot_key_index)
11
- end
12
-
13
- def template_hash
14
- {
15
- 'hot_key_index' => { description: '快捷键', default: '1', selection: %w[1 2 3...] },
16
- 'hot_key_dir' => { description: '快捷键执行目录', default: '' },
17
- 'hot_key_cmd' => { description: '快捷键执行命令', default: 'pod bin update --no-repo-update' }
18
- }
19
- end
20
-
21
- def config_file_with_hot_key_index(hot_key_index)
22
- file = config_file_whith_hot_key_index(hot_key_index)
23
- raise "\n===== #{hot_key_index} 参数有误,请检查%w[1 2 3...]===" unless (hot_key_index.to_i).is_a?(Integer)
24
- File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
25
- end
26
-
27
- def hot_key_index
28
- @hot_key_index = 1 if @hot_key_index.is_a?(NilClass)
29
- @hot_key_index
30
- end
31
-
32
- def set_hot_key_index(hot_key_index)
33
- @hot_key_index = hot_key_index
34
- end
35
-
36
- def config_file_whith_hot_key_index(hot_key_index)
37
- "hot_key_#{hot_key_index}.yml"
38
- end
39
-
40
- def sync_config(config)
41
- File.open(config_file_with_hot_key_index(config['hot_key_index']), 'w+') do |f|
42
- f.write(config.to_yaml)
43
- end
44
- end
45
-
46
- def default_config
47
- @default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
48
- end
49
-
50
- private
51
-
52
- def load_config
53
- file = config_file
54
- if (!file.nil?) && File.exist?(config_file)
55
- YAML.load_file(config_file)
56
- else
57
- default_config
58
- end
59
- end
60
-
61
- def config
62
- @config ||= begin
63
- puts "====== cocoapods-fy-bin #{CBin::VERSION} 版本 ======== \n"
64
- @config = OpenStruct.new load_config
65
- validate!
66
- @config
67
- end
68
- end
69
-
70
- def validate!
71
- template_hash.each do |k, v|
72
- selection = v[:selection]
73
- next if !selection || selection.empty?
74
-
75
- config_value = @config.send(k)
76
- next unless config_value
77
- unless selection.include?(config_value)
78
- raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
79
- end
80
- end
81
- end
82
-
83
- def respond_to_missing?(method, include_private = false)
84
- config.respond_to?(method) || super
85
- end
86
-
87
- def method_missing(method, *args, &block)
88
- if config.respond_to?(method)
89
- config.send(method, *args)
90
- elsif template_hash.keys.include?(method.to_s)
91
- raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
92
- else
93
- super
94
- end
95
- end
96
- end
97
-
98
- def self.config_hot_key
99
- @config_hot_key ||= Config_Hot_Key.new
100
- end
101
-
102
- end
103
-
@@ -1,57 +0,0 @@
1
- require 'yaml'
2
- require 'cocoapods-fy-bin/config/config_hot_key'
3
-
4
- module CBin
5
- class Config_Hot_Key
6
- class Asker
7
- def show_prompt
8
- print ' > '.green
9
- end
10
-
11
- def ask_with_answer(question, pre_answer, selection)
12
- print "\n#{question}\n"
13
-
14
- print_selection_info = lambda {
15
- print "可选值:[ #{selection.join(' / ')} ]\n" if selection
16
- }
17
- print_selection_info.call
18
- print "旧值:#{pre_answer}\n" unless pre_answer.nil?
19
-
20
- answer = ''
21
- loop do
22
- show_prompt
23
- answer = STDIN.gets.chomp.strip
24
-
25
- if answer == '' && !pre_answer.nil?
26
- answer = pre_answer
27
- print answer.yellow
28
- print "\n"
29
- end
30
-
31
- next if answer.empty?
32
- break if !selection || selection.include?(answer)
33
-
34
- print_selection_info.call
35
- end
36
-
37
- answer
38
- end
39
-
40
- def wellcome_message
41
- print <<~EOF
42
-
43
- 开始设置快捷键 pod bin imy.
44
- 所有的信息都会保存在 #{CBin.config_hot_key.config_file} 文件中.
45
- %w[hot_key.yaml]
46
- 你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
47
-
48
- #{CBin.config_hot_key.default_config.to_yaml}
49
- EOF
50
- end
51
-
52
- def done_message
53
- print "\n设置完成.\n".green
54
- end
55
- end
56
- end
57
- end