cocoapods-mtxx-bin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +11 -0
  4. data/lib/cocoapods-mtxx-bin/command/bin/archive.rb +206 -0
  5. data/lib/cocoapods-mtxx-bin/command/bin/auto.rb +212 -0
  6. data/lib/cocoapods-mtxx-bin/command/bin/code.rb +232 -0
  7. data/lib/cocoapods-mtxx-bin/command/bin/imy.rb +45 -0
  8. data/lib/cocoapods-mtxx-bin/command/bin/init.rb +94 -0
  9. data/lib/cocoapods-mtxx-bin/command/bin/initHotKey.rb +70 -0
  10. data/lib/cocoapods-mtxx-bin/command/bin/install.rb +44 -0
  11. data/lib/cocoapods-mtxx-bin/command/bin/lib/lint.rb +67 -0
  12. data/lib/cocoapods-mtxx-bin/command/bin/repo/push.rb +115 -0
  13. data/lib/cocoapods-mtxx-bin/command/bin/repo/update.rb +42 -0
  14. data/lib/cocoapods-mtxx-bin/command/bin/repo.rb +14 -0
  15. data/lib/cocoapods-mtxx-bin/command/bin/spec/create.rb +73 -0
  16. data/lib/cocoapods-mtxx-bin/command/bin/spec/lint.rb +109 -0
  17. data/lib/cocoapods-mtxx-bin/command/bin/spec.rb +13 -0
  18. data/lib/cocoapods-mtxx-bin/command/bin/update.rb +154 -0
  19. data/lib/cocoapods-mtxx-bin/command/bin.rb +65 -0
  20. data/lib/cocoapods-mtxx-bin/command.rb +1 -0
  21. data/lib/cocoapods-mtxx-bin/config/config.rb +166 -0
  22. data/lib/cocoapods-mtxx-bin/config/config_asker.rb +60 -0
  23. data/lib/cocoapods-mtxx-bin/config/config_builder.rb +216 -0
  24. data/lib/cocoapods-mtxx-bin/config/config_hot_key.rb +103 -0
  25. data/lib/cocoapods-mtxx-bin/config/config_hot_key_asker.rb +57 -0
  26. data/lib/cocoapods-mtxx-bin/gem_version.rb +9 -0
  27. data/lib/cocoapods-mtxx-bin/helpers/Info.plist +0 -0
  28. data/lib/cocoapods-mtxx-bin/helpers/build_helper.rb +167 -0
  29. data/lib/cocoapods-mtxx-bin/helpers/build_utils.rb +64 -0
  30. data/lib/cocoapods-mtxx-bin/helpers/framework.rb +86 -0
  31. data/lib/cocoapods-mtxx-bin/helpers/framework_builder.rb +551 -0
  32. data/lib/cocoapods-mtxx-bin/helpers/library.rb +54 -0
  33. data/lib/cocoapods-mtxx-bin/helpers/library_builder.rb +90 -0
  34. data/lib/cocoapods-mtxx-bin/helpers/sources_helper.rb +35 -0
  35. data/lib/cocoapods-mtxx-bin/helpers/spec_creator.rb +170 -0
  36. data/lib/cocoapods-mtxx-bin/helpers/spec_files_helper.rb +80 -0
  37. data/lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb +304 -0
  38. data/lib/cocoapods-mtxx-bin/helpers/upload_helper.rb +104 -0
  39. data/lib/cocoapods-mtxx-bin/helpers.rb +5 -0
  40. data/lib/cocoapods-mtxx-bin/native/acknowledgements.rb +27 -0
  41. data/lib/cocoapods-mtxx-bin/native/analyzer.rb +85 -0
  42. data/lib/cocoapods-mtxx-bin/native/file_accessor.rb +28 -0
  43. data/lib/cocoapods-mtxx-bin/native/gen.rb +79 -0
  44. data/lib/cocoapods-mtxx-bin/native/installation_options.rb +25 -0
  45. data/lib/cocoapods-mtxx-bin/native/installer.rb +135 -0
  46. data/lib/cocoapods-mtxx-bin/native/linter.rb +26 -0
  47. data/lib/cocoapods-mtxx-bin/native/path_source.rb +33 -0
  48. data/lib/cocoapods-mtxx-bin/native/pod_source_installer.rb +19 -0
  49. data/lib/cocoapods-mtxx-bin/native/pod_target_installer.rb +94 -0
  50. data/lib/cocoapods-mtxx-bin/native/podfile.rb +91 -0
  51. data/lib/cocoapods-mtxx-bin/native/podfile_env.rb +37 -0
  52. data/lib/cocoapods-mtxx-bin/native/podfile_generator.rb +201 -0
  53. data/lib/cocoapods-mtxx-bin/native/podspec_finder.rb +25 -0
  54. data/lib/cocoapods-mtxx-bin/native/resolver.rb +238 -0
  55. data/lib/cocoapods-mtxx-bin/native/sandbox_analyzer.rb +34 -0
  56. data/lib/cocoapods-mtxx-bin/native/source.rb +35 -0
  57. data/lib/cocoapods-mtxx-bin/native/sources_manager.rb +19 -0
  58. data/lib/cocoapods-mtxx-bin/native/specification.rb +31 -0
  59. data/lib/cocoapods-mtxx-bin/native/target_validator.rb +41 -0
  60. data/lib/cocoapods-mtxx-bin/native/validator.rb +40 -0
  61. data/lib/cocoapods-mtxx-bin/native.rb +25 -0
  62. data/lib/cocoapods-mtxx-bin/source_provider_hook.rb +53 -0
  63. data/lib/cocoapods-mtxx-bin.rb +2 -0
  64. data/lib/cocoapods_plugin.rb +2 -0
  65. data/spec/command/bin_spec.rb +12 -0
  66. data/spec/spec_helper.rb +50 -0
  67. metadata +182 -0
@@ -0,0 +1,27 @@
1
+
2
+
3
+ module Pod
4
+ module Generator
5
+ class Acknowledgements
6
+ def license_text(spec)
7
+ return nil unless spec.license
8
+
9
+ text = spec.license[:text]
10
+ unless text
11
+ if license_file = spec.license[:file]
12
+ license_path = file_accessor(spec).root + license_file
13
+ if File.exist?(license_path)
14
+ text = IO.read(license_path)
15
+ else
16
+ # UI.warn "Unable to read the license file `#{license_file}` " \
17
+ # "for the spec `#{spec}`"
18
+ end
19
+ elsif license_file = file_accessor(spec).license
20
+ text = IO.read(license_file)
21
+ end
22
+ end
23
+ text
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,85 @@
1
+
2
+
3
+ require 'parallel'
4
+ require 'cocoapods'
5
+
6
+ module Pod
7
+ class Installer
8
+ class Analyzer
9
+ # > 1.6.0
10
+ # all_specs[dep.name] 为 nil 会崩溃
11
+ # 主要原因是 all_specs 分析错误
12
+ # 查看 source 是否正确
13
+ #
14
+ # def dependencies_for_specs(specs, platform, all_specs)
15
+ # return [] if specs.empty? || all_specs.empty?
16
+
17
+ # dependent_specs = Set.new
18
+
19
+ # specs.each do |s|
20
+ # s.dependencies(platform).each do |dep|
21
+ # all_specs[dep.name].each do |spec|
22
+ # dependent_specs << spec
23
+ # end
24
+ # end
25
+ # end
26
+
27
+ # dependent_specs - specs
28
+ # end
29
+
30
+ # > 1.5.3 版本
31
+ # rewrite update_repositories
32
+ #
33
+ alias old_update_repositories update_repositories
34
+ def update_repositories
35
+ if installation_options.update_source_with_multi_processes
36
+ # 并发更新私有源
37
+ # 这里多线程会导致 pod update 额外输出 --verbose 的内容
38
+ # 不知道为什么?
39
+ Parallel.each(sources.uniq(&:url), in_processes: 4) do |source|
40
+ if source.git?
41
+ config.sources_manager.update(source.name, true)
42
+ else
43
+ UI.message "Skipping `#{source.name}` update because the repository is not a git source repository."
44
+ end
45
+ end
46
+ @specs_updated = true
47
+ else
48
+ old_update_repositories
49
+ end
50
+ end
51
+
52
+ # 解决 dep.name = xxx/binary 时,all_specs[dep.name] 返回nil,导致调用 each 方法报错
53
+ alias old_dependencies_for_specs dependencies_for_specs
54
+ def dependencies_for_specs(specs, platform, all_specs)
55
+ dependent_specs = {
56
+ :debug => Set.new,
57
+ :release => Set.new,
58
+ }
59
+
60
+ if !specs.empty? && !all_specs.empty?
61
+ specs.each do |s|
62
+ s.dependencies(platform).each do |dep|
63
+ all_specs[dep.name].each do |spec|
64
+ if spec.non_library_specification?
65
+ if s.test_specification? && spec.name == s.consumer(platform).app_host_name && spec.app_specification?
66
+ # This needs to be handled separately, since we _don't_ want to treat this as a "normal" dependency
67
+ next
68
+ end
69
+ raise Informative, "`#{s}` depends upon `#{spec}`, which is a `#{spec.spec_type}` spec."
70
+ end
71
+
72
+ dependent_specs.each do |config, set|
73
+ next unless s.dependency_whitelisted_for_configuration?(dep, config)
74
+ set << spec
75
+ end
76
+ end unless all_specs[dep.name].nil? # 解决 dep.name = xxx/binary 时,all_specs[dep.name]返回的是nil,导致调用 each 方法报错
77
+ end
78
+ end
79
+ end
80
+
81
+ Hash[dependent_specs.map { |k, v| [k, (v - specs).group_by(&:root)] }].freeze
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,28 @@
1
+ require 'macho'
2
+ require 'cocoapods'
3
+
4
+ module Pod
5
+ class Sandbox
6
+ class FileAccessor
7
+
8
+ # swift动态库 需要设置为true
9
+ def dynamic_binary?(binary)
10
+ @cached_dynamic_binary_results ||= {}
11
+ return @cached_dynamic_binary_results[binary] unless @cached_dynamic_binary_results[binary].nil?
12
+ return false unless binary.file?
13
+
14
+ @cached_dynamic_binary_results[binary] = MachO.open(binary).dylib?
15
+ rescue MachO::MachOError
16
+ @cached_dynamic_binary_results[binary] = true
17
+
18
+ end
19
+
20
+ # def expanded_paths(patterns, options = {})
21
+ # return [] if patterns.empty?
22
+ # path_list.glob(patterns, options).flatten.compact.uniq
23
+ # end
24
+
25
+ #-----------------------------------------------------------------------#
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,79 @@
1
+
2
+ # hook cocoapods-generate的Gen类和Installer类
3
+
4
+ module Pod
5
+ class Command
6
+ class Gen < Command
7
+
8
+ alias old_run run
9
+
10
+ def run
11
+ UI.puts "[pod gen] Running with #{configuration.to_s.gsub("\n", " \n")}" if configuration.pod_config.verbose?
12
+
13
+ # this is done here rather than in the installer so we only update sources once,
14
+ # even if there are multiple podspecs
15
+ update_sources if configuration.repo_update?
16
+
17
+ installers = []
18
+ Generate::PodfileGenerator.new(configuration).podfiles_by_spec.each do |spec, podfile|
19
+ installer = Generate::Installer.new(configuration, spec, podfile).install!
20
+ installers << installer
21
+ end
22
+
23
+ remove_warnings(UI.warnings)
24
+
25
+ installers
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ module Pod
32
+ module Generate
33
+ class Installer
34
+
35
+ alias old_install! install!
36
+
37
+ def install!
38
+ UI.title "Generating #{spec.name} in #{UI.path install_directory}" do
39
+ clean! if configuration.clean?
40
+ install_directory.mkpath
41
+
42
+ UI.message 'Creating stub application' do
43
+ create_app_project
44
+ end
45
+
46
+ UI.message 'Writing Podfile' do
47
+ podfile.defined_in_file.open('w') { |f| f << podfile.to_yaml }
48
+ end
49
+
50
+ installer = nil
51
+ UI.section 'Installing...' do
52
+ configuration.pod_config.with_changes(installation_root: install_directory, podfile: podfile,
53
+ lockfile: configuration.lockfile, sandbox: nil,
54
+ sandbox_root: install_directory + 'Pods',
55
+ podfile_path: podfile.defined_in_file,
56
+ silent: !configuration.pod_config.verbose?, verbose: false,
57
+ lockfile_path: nil) do
58
+ installer = ::Pod::Installer.new(configuration.pod_config.sandbox, podfile, configuration.lockfile)
59
+ installer.use_default_plugins = configuration.use_default_plugins
60
+ installer.install!
61
+ end
62
+ end
63
+
64
+ UI.section 'Performing post-installation steps' do
65
+ should_perform_post_install = if installer.respond_to?(:generated_aggregate_targets) # CocoaPods 1.7.0
66
+ !installer.generated_aggregate_targets.empty?
67
+ else
68
+ true
69
+ end
70
+ perform_post_install_steps(open_app_project, installer) if should_perform_post_install
71
+ end
72
+
73
+ print_post_install_message
74
+ installer
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,25 @@
1
+
2
+ require 'cocoapods'
3
+
4
+ module Pod
5
+ class Installer
6
+ class InstallationOptions
7
+ def self.env_option(key, default = true)
8
+ option key, ENV[key.to_s].nil? ? default : ENV[key.to_s] == 'true'
9
+ end
10
+
11
+ # 不同 source 存在相同 spec 名时,默认不警告
12
+ defaults.delete('warn_for_multiple_pod_sources')
13
+ env_option :warn_for_multiple_pod_sources, false
14
+
15
+ # 是否警告不安全 source (如 http )
16
+ env_option :warn_for_unsecure_source, false
17
+
18
+ # 是否多线程执行 install_pod_sources
19
+ env_option :install_with_multi_threads, false
20
+
21
+ # 是否多进程执行 update_repositories
22
+ env_option :update_source_with_multi_processes, false
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,135 @@
1
+ require 'cocoapods/installer/project_cache/target_metadata.rb'
2
+ require 'parallel'
3
+ require 'cocoapods'
4
+ require 'xcodeproj'
5
+ require 'cocoapods-mtxx-bin/native/pod_source_installer'
6
+
7
+ module Pod
8
+ class Installer
9
+ alias old_create_pod_installer create_pod_installer
10
+ def create_pod_installer(pod_name)
11
+ installer = old_create_pod_installer(pod_name)
12
+ installer.installation_options = installation_options
13
+ installer
14
+ end
15
+
16
+ alias old_install_pod_sources install_pod_sources
17
+ def install_pod_sources
18
+ if installation_options.install_with_multi_threads
19
+ if Pod.match_version?('~> 1.4.0')
20
+ install_pod_sources_for_version_in_1_4_0
21
+ elsif Pod.match_version?('~> 1.5')
22
+ install_pod_sources_for_version_above_1_5_0
23
+ else
24
+ old_install_pod_sources
25
+ end
26
+ else
27
+ old_install_pod_sources
28
+ end
29
+ end
30
+
31
+ # rewrite install_pod_sources
32
+ def install_pod_sources_for_version_in_1_4_0
33
+ @installed_specs = []
34
+ pods_to_install = sandbox_state.added | sandbox_state.changed
35
+ title_options = { verbose_prefix: '-> '.green }
36
+ Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
37
+ if pods_to_install.include?(spec.name)
38
+ if sandbox_state.changed.include?(spec.name) && sandbox.manifest
39
+ previous = sandbox.manifest.version(spec.name)
40
+ title = "Installing #{spec.name} #{spec.version} (was #{previous})"
41
+ else
42
+ title = "Installing #{spec}"
43
+ end
44
+ UI.titled_section(title.green, title_options) do
45
+ install_source_of_pod(spec.name)
46
+ end
47
+ else
48
+ UI.titled_section("Using #{spec}", title_options) do
49
+ create_pod_installer(spec.name)
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def install_pod_sources_for_version_above_1_5_0
56
+ @installed_specs = []
57
+ pods_to_install = sandbox_state.added | sandbox_state.changed
58
+ title_options = { verbose_prefix: '-> '.green }
59
+ # 多进程下载,多线程时 log 会显著交叉,多进程好点,但是多进程需要利用文件锁对 cache 进行保护
60
+ # in_processes: 10
61
+ Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
62
+ if pods_to_install.include?(spec.name)
63
+ if sandbox_state.changed.include?(spec.name) && sandbox.manifest
64
+ current_version = spec.version
65
+ previous_version = sandbox.manifest.version(spec.name)
66
+ has_changed_version = current_version != previous_version
67
+ current_repo = analysis_result.specs_by_source.detect do |key, values|
68
+ break key if values.map(&:name).include?(spec.name)
69
+ end
70
+ current_repo &&= current_repo.url || current_repo.name
71
+ previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
72
+ has_changed_repo = !previous_spec_repo.nil? && current_repo && (current_repo != previous_spec_repo)
73
+ title = "Installing #{spec.name} #{spec.version}"
74
+ if has_changed_version && has_changed_repo
75
+ title += " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
76
+ end
77
+ if has_changed_version && !has_changed_repo
78
+ title += " (was #{previous_version})"
79
+ end
80
+ if !has_changed_version && has_changed_repo
81
+ title += " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
82
+ end
83
+ else
84
+ title = "Installing #{spec}"
85
+ end
86
+ UI.titled_section(title.green, title_options) do
87
+ install_source_of_pod(spec.name)
88
+ end
89
+ else
90
+ UI.titled_section("Using #{spec}", title_options) do
91
+ create_pod_installer(spec.name)
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ alias old_write_lockfiles write_lockfiles
98
+ def write_lockfiles
99
+ old_write_lockfiles
100
+ if File.exist?('Podfile_local')
101
+
102
+ project = Xcodeproj::Project.open(config.sandbox.project_path)
103
+ #获取主group
104
+ group = project.main_group
105
+ group.set_source_tree('SOURCE_ROOT')
106
+ #向group中添加 文件引用
107
+ file_ref = group.new_reference(config.sandbox.root + '../Podfile_local')
108
+ #podfile_local排序
109
+ podfile_local_group = group.children.last
110
+ group.children.pop
111
+ group.children.unshift(podfile_local_group)
112
+ #保存
113
+ project.save
114
+ end
115
+ end
116
+ end
117
+
118
+ module Downloader
119
+ class Cache
120
+ # 多线程锁
121
+ @@lock = Mutex.new
122
+
123
+ # 后面如果要切到进程的话,可以在 cache root 里面新建一个文件
124
+ # 利用这个文件 lock
125
+ # https://stackoverflow.com/questions/23748648/using-fileflock-as-ruby-global-lock-mutex-for-processes
126
+
127
+ # rmtree 在多进程情况下可能 Directory not empty @ dir_s_rmdir 错误
128
+ # old_ensure_matching_version 会移除不是同一个 CocoaPods 版本的组件缓存
129
+ alias old_ensure_matching_version ensure_matching_version
130
+ def ensure_matching_version
131
+ @@lock.synchronize { old_ensure_matching_version }
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,26 @@
1
+
2
+
3
+ require 'cocoapods-mtxx-bin/native/specification'
4
+
5
+ module Pod
6
+ class Specification
7
+ class Linter
8
+ # !@group Lint steps
9
+
10
+ # Checks that the spec's root name matches the filename.
11
+ #
12
+ # @return [void]
13
+ #
14
+ def validate_root_name
15
+ if spec.root.name && file
16
+ acceptable_names = Specification::VALID_EXTNAME.map { |extname| "#{spec.root.name}#{extname}" }
17
+ names_match = acceptable_names.include?(file.basename.to_s)
18
+ unless names_match
19
+ results.add_error('name', 'The name of the spec should match the ' \
20
+ 'name of the file.')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,33 @@
1
+
2
+
3
+ require 'cocoapods-mtxx-bin/native/specification'
4
+
5
+ module Pod
6
+ module ExternalSources
7
+ # Provides support for fetching a specification file from a path local to
8
+ # the machine running the installation.
9
+ #
10
+ class PathSource < AbstractExternalSource
11
+ def normalized_podspec_path(declared_path)
12
+ extension = File.extname(declared_path)
13
+
14
+ if extension == '.podspec' || extension == '.json'
15
+ path_with_ext = declared_path
16
+ else
17
+ # 默认先从 binary podspec 找起,因为 binary podspec 的 subspec 可能比 code podspec 多
18
+ # 这里可能出现 code subspec 和 binary subspec 对应不上的情况,导致 lint 失败
19
+ # 所以不要在 code podspec 同一目录下保留 binary podspec
20
+ path_with_ext = Specification::VALID_EXTNAME
21
+ .map { |extname| "#{declared_path}/#{name}#{extname}" }
22
+ .find { |file| File.exist?(file) } || "#{declared_path}/#{name}.podspec"
23
+ end
24
+
25
+ UI.message "获取的 podspec 路径为 `#{path_with_ext}`"
26
+
27
+ podfile_dir = File.dirname(podfile_path || '')
28
+
29
+ File.expand_path(path_with_ext, podfile_dir)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+
2
+
3
+ require 'cocoapods-mtxx-bin/native/installation_options'
4
+
5
+ module Pod
6
+ class Installer
7
+ class PodSourceInstaller
8
+ attr_accessor :installation_options
9
+
10
+ alias old_verify_source_is_secure verify_source_is_secure
11
+ def verify_source_is_secure(root_spec)
12
+ # http source 默认不警告
13
+ if installation_options.warn_for_unsecure_source?
14
+ old_verify_source_is_secure(root_spec)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,94 @@
1
+ module Pod
2
+ class Installer
3
+ class Xcode
4
+ class PodsProjectGenerator
5
+ # Creates the target for the Pods libraries in the Pods project and the
6
+ # relative support files.
7
+ #
8
+ class PodTargetInstaller < TargetInstaller
9
+ require 'cocoapods/installer/xcode/pods_project_generator/app_host_installer'
10
+
11
+ # Adds a shell script phase, intended only for library targets that contain swift,
12
+ # to copy the ObjC compatibility header (the -Swift.h file that the swift compiler generates)
13
+ # to the built products directory. Additionally, the script phase copies the module map, appending a `.Swift`
14
+ # submodule that references the (moved) compatibility header. Since the module map has been moved, the umbrella header
15
+ # is _also_ copied, so that it is sitting next to the module map. This is necessary for a successful archive build.
16
+ #
17
+ # @param [PBXNativeTarget] native_target
18
+ # the native target to add the Swift static library script phase into.
19
+ #
20
+ # @return [Void]
21
+ #
22
+ alias old_add_swift_library_compatibility_header_phase add_swift_library_compatibility_header_phase
23
+
24
+ def add_swift_library_compatibility_header_phase(native_target)
25
+ UI.puts "====== swift add_swift_library_compatibility_header_phase ======".yellow
26
+ if $ARGV[1] == "auto"
27
+ UI.puts "====== auto swift add_swift_library_compatibility_header_phase ======".yellow
28
+
29
+ if custom_module_map
30
+ raise Informative, 'Using Swift static libraries with custom module maps is currently not supported. ' \
31
+ "Please build `#{target.label}` as a framework or remove the custom module map."
32
+ end
33
+
34
+ build_phase = native_target.new_shell_script_build_phase('Copy generated compatibility header')
35
+
36
+ relative_module_map_path = target.module_map_path.relative_path_from(target.sandbox.root)
37
+ relative_umbrella_header_path = target.umbrella_header_path.relative_path_from(target.sandbox.root)
38
+
39
+ build_phase.shell_script = <<-SH.strip_heredoc
40
+ COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
41
+ MODULE_MAP_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap"
42
+
43
+ ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${COMPATIBILITY_HEADER_PATH}"
44
+ ditto "${PODS_ROOT}/#{relative_module_map_path}" "${MODULE_MAP_PATH}"
45
+ ditto "${PODS_ROOT}/#{relative_umbrella_header_path}" "${BUILT_PRODUCTS_DIR}"
46
+
47
+ COPY_PATH="${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}"
48
+ UMBRELLA_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}-umbrella.h"
49
+ SWIFTMODULE_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.swiftmodule"
50
+
51
+ ditto "${MODULE_MAP_PATH}" "${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}.modulemap"
52
+ ditto "${COMPATIBILITY_HEADER_PATH}" "${COPY_PATH}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
53
+ ditto "${COMPATIBILITY_HEADER_PATH}" "${COPY_PATH}"
54
+ ditto "${UMBRELLA_PATH}" "${COPY_PATH}"
55
+ ditto "${SWIFTMODULE_PATH}" "${COPY_PATH}/${PRODUCT_MODULE_NAME}.swiftmodule"
56
+ ditto "${SWIFTMODULE_PATH}" "${COPY_PATH}/${PRODUCT_MODULE_NAME}.swiftmodule"
57
+
58
+ if [ ${PRODUCT_MODULE_NAME} != ${PRODUCT_NAME} ] ; then
59
+ ditto "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}-umbrella.h" "${COPY_PATH}"
60
+ ditto "${COPY_PATH}" "${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_NAME}"
61
+ fi
62
+
63
+ MODULE_MAP_SEARCH_PATH = "${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}.modulemap"
64
+
65
+ if [${MODULE_MAP_PATH} != ${MODULE_MAP_SEARCH_PATH}] ; then
66
+ printf "\\n\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\n header \\"${COPY_PATH}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h\\"\\n requires objc\\n}\\n" >> "${MODULE_MAP_SEARCH_PATH}"
67
+ fi
68
+
69
+ printf "\\n\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\n header \\"${COMPATIBILITY_HEADER_PATH}\\"\\n requires objc\\n}\\n" >> "${MODULE_MAP_PATH}"
70
+
71
+ SH
72
+ build_phase.input_paths = %W(
73
+ ${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h
74
+ ${PODS_ROOT}/#{relative_module_map_path}
75
+ ${PODS_ROOT}/#{relative_umbrella_header_path}
76
+ )
77
+ build_phase.output_paths = %W(
78
+ ${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap
79
+ ${BUILT_PRODUCTS_DIR}/#{relative_umbrella_header_path.basename}
80
+ ${BUILT_PRODUCTS_DIR}/Swift\ Compatibility\ Header/${PRODUCT_MODULE_NAME}-Swift.h
81
+ )
82
+ else
83
+ UI.puts "====== null swift add_swift_library_compatibility_header_phase ======".yellow
84
+ old_add_swift_library_compatibility_header_phase(native_target)
85
+ end
86
+
87
+ end
88
+
89
+ #-----------------------------------------------------------------------#
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,91 @@
1
+
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-mtxx-bin/native/podfile_env'
5
+
6
+ module Pod
7
+ class Podfile
8
+ # TREAT_DEVELOPMENTS_AS_NORMAL = 'treat_developments_as_normal'.freeze
9
+
10
+ module DSL
11
+ def allow_prerelease!
12
+ set_internal_hash_value(ALLOW_PRERELEASE, true)
13
+ end
14
+
15
+ def use_binaries!(flag = true)
16
+ set_internal_hash_value(USE_BINARIES, flag)
17
+ end
18
+
19
+ def use_binaries_with_spec_selector!(&block)
20
+ raise Informative, '必须提供选择需要二进制组件的 block !' unless block_given?
21
+
22
+ set_internal_hash_value(USE_BINARIES_SELECTOR, block)
23
+ end
24
+
25
+ def set_use_source_pods(pods)
26
+ hash_pods_use_source = get_internal_hash_value(USE_SOURCE_PODS) || []
27
+ hash_pods_use_source += Array(pods)
28
+ set_internal_hash_value(USE_SOURCE_PODS, hash_pods_use_source)
29
+ end
30
+
31
+ # 0 dev
32
+ # 1 debug_iphoneos
33
+ # 2 release_iphoneos
34
+ # 需要在podfile_env 先定义 CONFIGURATION_ENV
35
+ def set_configuration_env(env = "dev")
36
+ set_internal_hash_value(CONFIGURATION_ENV, env)
37
+ end
38
+ end
39
+
40
+ alias old_plugins plugins
41
+ def plugins
42
+ if ENV[USE_PLUGINS]
43
+ env_plugins = ENV[USE_PLUGINS].split(',').each_with_object({}) do |name, result|
44
+ result[name] = {}
45
+ end
46
+ env_plugins.merge!(old_plugins)
47
+ else
48
+ old_plugins
49
+ end
50
+ end
51
+
52
+ def use_binaries_selector
53
+ get_internal_hash_value(USE_BINARIES_SELECTOR, nil)
54
+ end
55
+
56
+ def allow_prerelease?
57
+ get_internal_hash_value(ALLOW_PRERELEASE, false) || ENV[ALLOW_PRERELEASE] == 'true'
58
+ end
59
+
60
+ def use_binaries?
61
+ get_internal_hash_value(USE_BINARIES, false) || ENV[USE_BINARIES] == 'true'
62
+ end
63
+
64
+ def use_source_pods
65
+ get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
66
+ end
67
+
68
+ def configuration_env
69
+ get_internal_hash_value(CONFIGURATION_ENV, "dev") || ENV[CONFIGURATION_ENV] == "dev"
70
+ end
71
+
72
+ private
73
+
74
+ def valid_bin_plugin
75
+ unless plugins.keys.include?('cocoapods-mtxx-bin')
76
+ raise Pod::Informative, 'You should add `plugin \'cocoapods-mtxx-bin\'` before using its DSL'
77
+ end
78
+ end
79
+
80
+ # set_hash_value 有 key 限制
81
+ def set_internal_hash_value(key, value)
82
+ valid_bin_plugin
83
+
84
+ internal_hash[key] = value
85
+ end
86
+
87
+ def get_internal_hash_value(key, default = nil)
88
+ internal_hash.fetch(key, default)
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,37 @@
1
+
2
+
3
+ module Pod
4
+ class Podfile
5
+ USE_BINARIES = 'use_binaries'
6
+ USE_SOURCE_PODS = 'use_source_pods'
7
+ USE_BINARIES_SELECTOR = 'use_binaries_selector'
8
+ ALLOW_PRERELEASE = 'allow_prerelease'
9
+ USE_PLUGINS = 'use_plugins'
10
+ CONFIGURATION_ENV = 'configuration_env'
11
+
12
+ module ENVExecutor
13
+ def execute_with_bin_plugin(&block)
14
+ execute_with_key(USE_PLUGINS, -> { 'cocoapods-mtxx-bin' }, &block)
15
+ end
16
+
17
+ def execute_with_allow_prerelease(allow_prerelease, &block)
18
+ execute_with_key(ALLOW_PRERELEASE, -> { allow_prerelease ? 'true' : 'false' }, &block)
19
+ end
20
+
21
+ def execute_with_use_binaries(use_binaries, &block)
22
+ execute_with_key(USE_BINARIES, -> { use_binaries ? 'true' : 'false' }, &block)
23
+ end
24
+
25
+ def execute_with_key(key, value_returner)
26
+ origin_value = ENV[key]
27
+ ENV[key] = value_returner.call
28
+
29
+ yield if block_given?
30
+
31
+ ENV[key] = origin_value
32
+ end
33
+ end
34
+
35
+ extend ENVExecutor
36
+ end
37
+ end