cocoapods-taobao-environment 1.0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1bb1dadb505f13c9ce8a3fc2246b6ed4454b54d
4
+ data.tar.gz: 44fb048eab17e4989dd2a33595755cc5fd2cb1ad
5
+ SHA512:
6
+ metadata.gz: d0e26f214f39ef8f91a5e48eb888086631ac959c492fb6c7f23ab56acf35bcbfded63b3fab74cd77d2415f8865e9624a47e6b609f5978a964409fe5a687b7dba
7
+ data.tar.gz: 0b25f6d731c25804827f886026ecca388feae01d5adefe6f9cc543861d291735c901fe5a0c747251d26134e616f88c52c999cfb4593479de45f522e24635356f
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ vendor
24
+ .idea
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "XCodeScript"]
2
+ path = XCodeScript
3
+ url = git@gitlab.alibaba-inc.com:PodEnv/XCodeScript.git
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://gems.ruby-china.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-taobao-environment.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 梅忘
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Cocoapods::Taobao::Environment
2
+
3
+ 手机淘宝 iOS 统一开发环境
4
+
5
+ 使用 CocoaPods 0.39.0 版本作为基础依赖管理工具,进行一定的 Patch,并根据手淘特殊的开发环境,做了适配。仅供内部使用。
6
+
7
+ 目前提供以下功能:
8
+ 1. 统一 CocoaPods 版本为 0.39.0
9
+ - 自动使用 alipods 和 mirror 作为 spec 源
10
+ - 支持 iOS7 使用动态链接库
11
+ - 修复源码依赖时的版本依赖冲突
12
+ - 默认启用 inhibit_all_warnings!
13
+ - 增加 Framework 头文件搜索路径从 Framework/Headers 起始
14
+ - 添加在线下载集成区依赖环境脚本
15
+
16
+ ## Installation
17
+
18
+ 该项目不再提供独立安装方式,已集成到 TaobaoEnv 项目中,如需使用,请访问 http://gitlab.alibaba-inc.com/wireless/package-taobao-environment
19
+
20
+ ## Usage
21
+
22
+ 1. 去除 Podfile 里面相关脚本,包括 Header Search Path 修复脚本
23
+ - 去除 source 字段
24
+ - 去除 `inhibit_all_warnings!` 设置
25
+ - 去除集成区依赖,使用以下函数代替:
26
+ ```
27
+ cocoapods_sync_dependencies(:branch=>"集成区分支名", :exclude=>"需要排除的依赖,例如当前项目")
28
+ ```
29
+
30
+
31
+ 例子:
32
+
33
+ ```
34
+ target 'TBMainClient' do
35
+ platform :ios, '7.0'
36
+ pod 'WeAppSDK', :path=>"../ios_weapp_sdk"
37
+ cocoapods_sync_dependencies(:branch=>"dev_20160318", :exclude=>"TBShop")
38
+ end
39
+ ```
40
+
41
+ 该 Podfile 将会从集成区下载所有依赖,除了`WeAppSDK`和`TBShop`!!
42
+
43
+ 该例子中不仅使用`exclude`排除了 TBShop 项目,同时在前面也指明了 WeAppSDK 的本地版本,因此同步依赖的时候会自动排除这两个依赖,不使用线上版本,而使用本地指明的版本。
44
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require 'Xcodeproj'
5
+ require 'fileutils'
6
+
7
+ Encoding.default_external = Encoding::UTF_8
8
+ Encoding.default_internal = Encoding::UTF_8
9
+
10
+ current_target_name = ENV["TARGET_NAME"]
11
+ project = Xcodeproj::Project.open(ENV["PROJECT_FILE_PATH"])
12
+
13
+ # 分析环境变量参数
14
+ def parse_args(args)
15
+ index = 0
16
+ arg_list = []
17
+ while args && args.length > 0 && args.length > index
18
+ space_index = args.index(" ", index)
19
+ space_index = -1 if space_index.nil?
20
+ arg = args[0..space_index]
21
+ if arg.count("\"") % 2 == 0 && arg.count("'") % 2 == 0
22
+ arg_list << arg.strip
23
+ args = space_index >= 0 ? args[space_index+1..-1] : nil
24
+ index = 0
25
+ end
26
+ end
27
+ arg_list
28
+ end
29
+
30
+ def find_key(array, key)
31
+ for dic in array
32
+ if dic.keys[0] == key
33
+ return dic[key]
34
+ end
35
+ end
36
+ end
37
+
38
+ current_target = project.targets.find { |target| target.name == current_target_name }
39
+
40
+ frameworks = current_target.frameworks_build_phases.files.map{|file| file.file_ref.nil? ? "" : File.basename(file.file_ref.path) }.select { |x| File.extname(x) == ".framework"}
41
+
42
+ FRAMEWORK_SEARCH_PATHS = []
43
+ parse_args(ENV['FRAMEWORK_SEARCH_PATHS']).each { |arg| FRAMEWORK_SEARCH_PATHS << arg.gsub("\"", "") }
44
+
45
+ for framework in frameworks
46
+ FRAMEWORK_SEARCH_PATHS.each do |path|
47
+ framework_path = File.join(path, framework)
48
+ if File.directory?(framework_path)
49
+ ignore_list = ["Info.plist", ".DS_Store"]
50
+ if File.directory?(File.join(framework_path, "Resources"))
51
+ list = Dir.glob(File.join(framework_path, "Resources/*"))
52
+ else
53
+ ignore_list += [File.basename(framework, '.framework'), "Headers", "PrivateHeaders", "Modules", "Versions", "_CodeSignature"]
54
+ list = Dir.glob(File.join(framework_path, "*"))
55
+ end
56
+ list.reject!{|entry| ignore_list.include?(File.basename(entry)) }
57
+ list.each { |file| puts file}
58
+ FileUtils.cp_r list, File.join(ENV["TARGET_BUILD_DIR"], ENV["UNLOCALIZED_RESOURCES_FOLDER_PATH"])
59
+ break
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods/taobao/environment/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cocoapods-taobao-environment"
8
+ spec.version = Cocoapods::Taobao::Environment::VERSION
9
+ spec.authors = ["梅忘"]
10
+ spec.email = ["chijing.zcj@alibaba-inc.com"]
11
+ spec.summary = %q{淘宝 CocoaPods Hook.}
12
+ spec.description = %q{根据 CocoaPods 0.39.0 做一定的 hook.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0") << "XCodeScript/CopyFrameworkResources/copy-framework-resources.rb"
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency 'cocoapods', '>= 0.39.0'
25
+ end
@@ -0,0 +1,17 @@
1
+ require "cocoapods/taobao/environment/version"
2
+
3
+ if PodVersion(">= 0.39")
4
+ require "cocoapods/taobao/environment/alibaba_source.rb"
5
+ require "cocoapods/taobao/environment/integrate_copy_framework_resouces_script.rb"
6
+ require "cocoapods/taobao/environment/cocoapods_sync_dependencies.rb"
7
+ require "cocoapods/taobao/environment/inhibit_pod_warning.rb"
8
+ require "cocoapods/taobao/environment/dynamic_dependency_for_ios_7.rb"
9
+ require "cocoapods/taobao/environment/fix_dependency_conflict.rb"
10
+ if PodVersion("~> 1.0")
11
+ require "cocoapods/taobao/environment/fix_framework_search_path_1.0.rb"
12
+ require "cocoapods/taobao/environment/deintegrate_pods_for_framework_1.0.rb"
13
+ else
14
+ require "cocoapods/taobao/environment/fix_framework_search_path_0.39.rb"
15
+ require "cocoapods/taobao/environment/deintegrate_pods_for_framework_0.39.rb"
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+
2
+ module AlibabaSource
3
+ def initialize(defined_in_file = nil, internal_hash = {}, &block)
4
+ super
5
+ ENV["COCOAPODS_DISABLE_STATS"] = "1"
6
+ source 'git@gitlab.alibaba-inc.com:alipods/specs.git'
7
+ source 'git@gitlab.alibaba-inc.com:alipods/specs-mirror.git'
8
+ end
9
+ end
10
+
11
+ module Pod
12
+ class Podfile
13
+ prepend AlibabaSource
14
+ end
15
+ end
@@ -0,0 +1,187 @@
1
+ # 同步taobao4iphone的podfile
2
+
3
+ $config = {}
4
+
5
+ module Pod
6
+ class Podfile
7
+ class TargetDefinition
8
+ def pods
9
+ if PodVersion('~> 0.39')
10
+ get_hash_value('dependencies', [])
11
+ else
12
+ if exclusive?
13
+ pod_dependencies
14
+ else
15
+ pod_dependencies + parent.pods
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ # dependency
24
+ def solve_podfile(file_path)
25
+ json = {"dependencies"=>{}}
26
+ target_definitions = Pod::Podfile.from_ruby(Pathname.new(file_path), nil).target_definitions
27
+ target_definition = nil
28
+ if target_definitions.count == 1
29
+ target_definition = target_definitions.values.first
30
+ elsif target_definitions.include?($config[:targetName])
31
+ target_definition = target_definitions[$config[:targetName]]
32
+ else
33
+ raise StandardError, "#{$config[:projectId].gsub("%2E", ".")} 的 #{$config[:fileName]} 不包含名为 #{$config[:targetName]} 的 Target!"
34
+ end
35
+ target_definition.dependencies.each do |dependency|
36
+ json["dependencies"][dependency.name] = dependency.requirement.to_s
37
+ end
38
+ json["configurations"] = target_definition.__send__(:configuration_pod_whitelist)
39
+ json
40
+ end
41
+
42
+ def solve_dependency(file_path)
43
+ return unless File.exists?(file_path)
44
+
45
+ if $config[:fileName].include?("json")
46
+ body = File.open(file_path, 'r:utf-8', &:read)
47
+ {"dependencies" => JSON.parse(body)["dependencies"] }
48
+ elsif $config[:fileName].include?("Podfile")
49
+ solve_podfile(file_path)
50
+ elsif $config[:fileName].include?("podspec")
51
+ raise StandardError, "podspec格式暂不支持"
52
+ end
53
+ end
54
+
55
+ def download_dependencies(file_path)
56
+ if cache_valid?(file_path)
57
+ Pod::UI.info "使用本地缓存依赖: #{relative_path(file_path)}"
58
+ return
59
+ end
60
+
61
+ if $config[:token].blank?
62
+ setup_git_private_token
63
+ raise StandardError, "本地缓存不存在,且未设置 Gitlab Private Token,无法获取在线依赖!\n请将本地缓存文件 #{relative_path(file_path)} 加入 Git 并 Push !"
64
+ end
65
+
66
+ require 'net/http'
67
+ require 'open-uri'
68
+ url = "#{$config[:gitlab]}/api/v3/projects/#{$config[:projectId]}/repository/blobs/#{$config[:branch]}?filepath=#{$config[:fileName]}&private_token=#{$config[:token]}"
69
+ Pod::UI.message "正在下载主工程最新依赖..."
70
+ url = URI.parse(url)
71
+ req = Net::HTTP::Get.new(url.to_s)
72
+ res = Net::HTTP.start(url.host, url.port) { |http|
73
+ http.request(req)
74
+ }
75
+ save_cache(res.body.force_encoding("UTF-8"), file_path)
76
+ end
77
+
78
+ # cache
79
+ def relative_path(path)
80
+ Pathname.new(path).relative_path_from(Pathname.new($config[:projectPath])).to_s
81
+ end
82
+
83
+ def cache_path
84
+ string = "#{$config[:gitlab]}/#{$config[:projectId]}"
85
+ md5 = Digest::MD5.hexdigest(string)
86
+ "#{$config[:projectPath]}/#{$config[:dependencyDir]}/#{md5}/#{$config[:fileName]}"
87
+ end
88
+
89
+ def save_cache(data, file_path)
90
+ require 'fileutils'
91
+ FileUtils.rm_rf(File.dirname(file_path))
92
+ FileUtils::mkdir_p(File.dirname(file_path))
93
+ Pod::UI.info "缓存路径-> #{relative_path(file_path)}"
94
+ File.open(file_path,"w") do |f|
95
+ f.write(data)
96
+ end
97
+ end
98
+
99
+ def cache_valid?(file_path)
100
+ use_cache = File.exists?(file_path)
101
+ if use_cache
102
+ if ARGV.include?("update")
103
+ if $config[:token].blank?
104
+ Pod::UI.notice "如果需要同步最新依赖请设置您的Private Token"
105
+ setup_git_private_token
106
+ else
107
+ use_cache = false
108
+ end
109
+ end
110
+ end
111
+ use_cache
112
+ end
113
+
114
+ def setup_git_private_token()
115
+ Pod::UI.notice "前往 http://gitlab.alibaba-inc.com/profile/account 查看您的 Private Token"
116
+ Pod::UI.notice "编辑 ~/.#{File.basename(ENV["SHELL"])}rc 和 ~/.#{File.basename(ENV["SHELL"])}_profile 添加您的 Private Token:"
117
+ Pod::UI.notice "\texport ALIBABA_GITLAB_PRIVATE_TOKEN=Private Token"
118
+ end
119
+
120
+ # config
121
+ def init_config
122
+ $config = {
123
+ :gitlab => "http://gitlab.alibaba-inc.com",
124
+ :projectId => "wireless/taobao4iphone",
125
+ :targetName => "Taobao4iPhone",
126
+ :fileName => "Podfile",
127
+ :branch => "master",
128
+ :dependencyDir => "PodMainDependencies",
129
+ :configFileName => "config.json",
130
+ :projectPath => Dir.pwd,
131
+ :exclude => nil,
132
+ :configurations => ["Debug", "Release"],
133
+ :token => ENV["ALIBABA_GITLAB_PRIVATE_TOKEN"]
134
+ }
135
+ end
136
+
137
+ def load_config_file
138
+ file_path = "#{$config[:projectPath]}/#{$config[:dependencyDir]}/#{$config[:configFileName]}"
139
+ if File.exists?(file_path)
140
+ file = File.open(file_path, 'r:utf-8', &:read)
141
+ config = JSON.parse(file)[current_target_definition.name]
142
+ config = Hash[config.map{ |k, v| [k.to_sym, v] }]
143
+ $config.merge!(config)
144
+ end
145
+ end
146
+
147
+ def prepare_config(config)
148
+ init_config
149
+ load_config_file
150
+ $config.merge!(config)
151
+ end
152
+
153
+ # public method
154
+ def cocoapods_sync_dependencies(config)
155
+ prepare_config(config)
156
+ Pod::UI.titled_section("正在同步主工程 #{$config[:projectId]} 依赖") do
157
+ $config[:projectId] = CGI.escape($config[:projectId]).gsub(".", "%2E")
158
+ $config[:branch] = CGI.escape($config[:branch]).gsub(".", "%2E")
159
+
160
+ download_dependencies(cache_path)
161
+ json = solve_dependency(cache_path)
162
+
163
+ exclude = $config[:exclude]
164
+ if PodVersion('~> 0.39')
165
+ excludes = current_target_definition.pods.collect { |pod| pod.class == String ? pod : pod.keys[0]}
166
+ else
167
+ excludes = current_target_definition.pods.map {|pod| pod.name }
168
+ end
169
+ excludes += exclude if exclude.class == Array
170
+ excludes << exclude if exclude.class == String
171
+ excludes.each {|exc| json["dependencies"].delete(exc)}
172
+
173
+ json["dependencies"].to_a.each do |key, value|
174
+ pod(key, value)
175
+ end
176
+
177
+ configurations = []
178
+ configurations << $config[:configurations] if $config[:configurations].class == String
179
+ configurations += $config[:configurations] if $config[:configurations].class == Array
180
+ json["configurations"].to_a.each do |config, pods|
181
+ next if configurations.count > 0 && !configurations.include?(config)
182
+ pods.each do |name|
183
+ current_target_definition.whitelist_pod_for_configuration(name, config)
184
+ end
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,60 @@
1
+
2
+ module Pod
3
+ class Installer
4
+ class UserProjectIntegrator
5
+ class TargetIntegrator
6
+ alias_method :old_update_to_cocoapods_0_39, :update_to_cocoapods_0_39
7
+ def update_to_cocoapods_0_39
8
+ requires_update = old_update_to_cocoapods_0_39
9
+ framework_targets = native_targets.select do |target|
10
+ !EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
11
+ end
12
+ framework_targets.each do |native_target|
13
+ requires_update = remove_pods_library_from_target(native_target) || requires_update
14
+ requires_update = remove_copy_resources_script_phase_from_target(native_target) || requires_update
15
+ end
16
+ requires_update
17
+ end
18
+
19
+ def remove_pods_library_from_target(native_target)
20
+ frameworks = user_project.frameworks_group
21
+ build_phase = native_target.frameworks_build_phase
22
+ new_product_ref = frameworks.files.find { |f| f.path == target.product_name }
23
+ if new_product_ref.present?
24
+ UI.message("Removing Pod product reference #{target.product_name} from project.")
25
+ build_phase.remove_file_reference(new_product_ref)
26
+ frameworks.remove_reference(new_product_ref)
27
+ return true
28
+ end
29
+ false
30
+ end
31
+
32
+ def remove_copy_resources_script_phase_from_target(native_target)
33
+ phase_name = 'Copy Pods Resources'
34
+ resource_build_phase = native_target.shell_script_build_phases.find { |bp| bp.name == phase_name }
35
+ return false unless resource_build_phase.present?
36
+ native_target.build_phases.delete(resource_build_phase)
37
+ true
38
+ end
39
+
40
+ alias_method :old_native_targets_to_integrate, :native_targets_to_integrate
41
+ def native_targets_to_integrate
42
+ unless @native_targets_to_integrate
43
+ old_native_targets_to_integrate
44
+ unless @native_targets_to_integrate.nil?
45
+ targets = native_targets.select do |native_target|
46
+ native_target.shell_script_build_phases.find { |bp| bp.name == "Copy Framework Resources" }.nil?
47
+ end
48
+ @native_targets_to_integrate += targets if targets.present?
49
+ @native_targets_to_integrate.uniq!
50
+ @native_targets_to_integrate = @native_targets_to_integrate.select do |target|
51
+ EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
52
+ end
53
+ end
54
+ end
55
+ @native_targets_to_integrate
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,49 @@
1
+
2
+ module Pod
3
+ class Installer
4
+ class UserProjectIntegrator
5
+ class TargetIntegrator
6
+ alias_method :old_integrate!, :integrate!
7
+ def integrate!
8
+ old_integrate!
9
+ framework_targets = native_targets.select do |target|
10
+ !EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
11
+ end
12
+ framework_targets.each do |native_target|
13
+ remove_pods_library_from_target(native_target)
14
+ remove_copy_resources_script_phase_from_target(native_target)
15
+ end
16
+ end
17
+
18
+ def remove_pods_library_from_target(native_target)
19
+ frameworks = user_project.frameworks_group
20
+ build_phase = native_target.frameworks_build_phase
21
+ new_product_ref = frameworks.files.find { |f| f.path == target.product_name }
22
+ if new_product_ref.present?
23
+ UI.message("Removing Pod product reference #{target.product_name} from project.")
24
+ build_phase.remove_file_reference(new_product_ref)
25
+ frameworks.remove_reference(new_product_ref)
26
+ return true
27
+ end
28
+ false
29
+ end
30
+
31
+ def remove_copy_resources_script_phase_from_target(native_target)
32
+ phase_name = BUILD_PHASE_PREFIX + COPY_PODS_RESOURCES_PHASE_NAME
33
+ resource_build_phase = native_target.shell_script_build_phases.find { |bp| bp.name == phase_name }
34
+ return false unless resource_build_phase.present?
35
+ native_target.build_phases.delete(resource_build_phase)
36
+ true
37
+ end
38
+
39
+ alias_method :old_create_or_update_build_phase, :create_or_update_build_phase
40
+ def create_or_update_build_phase(target, phase_name, phase_class = Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
41
+ if !EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type) and phase_name == COPY_PODS_RESOURCES_PHASE_NAME
42
+ return target.project.new(phase_class)
43
+ end
44
+ old_create_or_update_build_phase(target, phase_name, phase_class)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,46 @@
1
+ module Pod
2
+ module Generator
3
+ module XCConfig
4
+ module XCConfigHelper
5
+ class << XCConfigHelper
6
+ alias_method :old, :add_dynamic_dependency_build_settings
7
+ end
8
+
9
+ def self.add_dynamic_dependency_build_settings(target, xcconfig)
10
+ # 如果目标平台是7.0,则不添加 -framewok xxx 到 xcconfig
11
+ if target.platform.supports_dynamic_frameworks?
12
+ old(target, xcconfig)
13
+ else
14
+ target.file_accessors.each do |file_accessor|
15
+ if file_accessor.vendored_dynamic_frameworks.count >0
16
+ # 输出到日志里,方便查看
17
+ puts "-framework #{target.name} is excluded from OTHER_LDFLAGS"
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ module Pod
29
+ class PodTarget < Target
30
+ alias_method :old_uses_swift?, :uses_swift?
31
+ def uses_swift?
32
+ return true if old_uses_swift?
33
+ # 包含 -Swift.h 的 framework 也需要使用 swift runtime
34
+ file_accessors.any? do |file_accessor|
35
+ file_accessor.vendored_dynamic_frameworks.any? { |sf| Dir[sf+"Headers/*"].any? {|h| h.end_with?("-Swift.h")} }
36
+ end
37
+ end
38
+ end
39
+
40
+ class Installer
41
+ alias_method :old_verify_framework_usage, :verify_framework_usage
42
+ def verify_framework_usage
43
+ # 强制跳过验证
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,35 @@
1
+ module Pod
2
+ class Installer
3
+ class Analyzer
4
+ alias_method :old_verify_no_pods_with_different_sources!, :verify_no_pods_with_different_sources!
5
+ def verify_no_pods_with_different_sources!
6
+ deps_with_different_sources = podfile.dependencies.group_by(&:root_name).
7
+ select { |_root_name, dependencies| dependencies.map(&:external_source).select{|source|!source.nil?}.uniq.count > 1 }
8
+ deps_with_different_sources.each do |root_name, dependencies|
9
+ raise Informative, 'There are multiple dependencies with different ' \
10
+ "sources for `#{root_name}` in #{UI.path podfile.defined_in_file}:" \
11
+ "\n\n- #{dependencies.map(&:to_s).join("\n- ")}"
12
+ end
13
+ end
14
+
15
+ alias_method :old_resolve_dependencies, :resolve_dependencies
16
+ def resolve_dependencies
17
+ duplicate_dependencies = podfile.dependencies.group_by(&:name).
18
+ select { |_name, dependencies| dependencies.select {|dp|!dp.requirement.none?}.count > 1 }
19
+ duplicate_dependencies.each do |name, dependencies|
20
+ UI.warn "There are duplicate dependencies on `#{name}` in #{UI.path podfile.defined_in_file}:\n\n" \
21
+ "- #{dependencies.map(&:to_s).join("\n- ")}"
22
+ end
23
+
24
+ specs_by_target = nil
25
+ UI.section "Resolving dependencies of #{UI.path(podfile.defined_in_file) || 'Podfile'}" do
26
+ resolver = Resolver.new(sandbox, podfile, locked_dependencies, sources)
27
+ specs_by_target = resolver.resolve
28
+ specs_by_target.values.flatten(1).each(&:validate_cocoapods_version)
29
+ end
30
+ specs_by_target
31
+ end
32
+ end
33
+ end
34
+ end
35
+
@@ -0,0 +1,22 @@
1
+ module Pod
2
+ module Generator
3
+ module XCConfig
4
+ # Generates the xcconfigs for the aggregate targets.
5
+ #
6
+ class AggregateXCConfig
7
+ alias_method :old_generate_settings_to_import_pod_targets, :generate_settings_to_import_pod_targets
8
+
9
+ def generate_settings_to_import_pod_targets
10
+ old_generate_settings_to_import_pod_targets
11
+ header_search_paths = pod_targets.map {|t| t.file_accessors.map {|f| f.vendored_frameworks }}.flatten.uniq
12
+ header_search_paths = header_search_paths.map{|fmk| File.join("$(PODS_ROOT)", fmk.relative_path_from(target.sandbox.root), "/Headers") }
13
+ build_settings = {
14
+ # by `#import "…"`
15
+ 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(header_search_paths),
16
+ }
17
+ @xcconfig.merge!(build_settings)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Pod
2
+ module Generator
3
+ module XCConfig
4
+ # Generates the xcconfigs for the aggregate targets.
5
+ #
6
+ class AggregateXCConfig
7
+ alias_method :old_settings_to_import_pod_targets, :settings_to_import_pod_targets
8
+
9
+ def settings_to_import_pod_targets
10
+ settings = old_settings_to_import_pod_targets
11
+ header_search_paths = pod_targets.map {|t| t.file_accessors.map {|f| f.vendored_frameworks }}.flatten.uniq
12
+ header_search_paths = header_search_paths.map{|fmk| File.join("$(PODS_ROOT)", fmk.relative_path_from(target.sandbox.root), "/Headers") }
13
+ build_settings = {
14
+ # by `#import "…"`
15
+ 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(header_search_paths),
16
+ }
17
+ settings.merge!(build_settings)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+
2
+ module PodTargetInhibitWarning
3
+ def initialize(name, parent, internal_hash = nil)
4
+ super
5
+ inhibit_all_warnings = true
6
+ end
7
+ end
8
+
9
+ module Pod
10
+ class Podfile
11
+ class TargetDefinition
12
+ prepend PodTargetInhibitWarning
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,52 @@
1
+ module Pod
2
+ class AggregateTarget < Target
3
+ # @return [Pathname] The absolute path of the copy framewrok resources script.
4
+ #
5
+ def copy_framework_resources_script_path
6
+ support_files_dir + "copy-framework-resources.rb"
7
+ end
8
+
9
+ # @return [String] The path of the copy framework resources script relative to the
10
+ # root of the user project.
11
+ #
12
+ def copy_framework_resources_script_relative_path
13
+ "${SRCROOT}/#{relative_to_srcroot(copy_framework_resources_script_path)}"
14
+ end
15
+ end
16
+ end
17
+
18
+ module Pod
19
+ class Installer
20
+ class AggregateTargetInstaller < TargetInstaller
21
+ alias_method :old_create_copy_resources_script, :create_copy_resources_script
22
+ def create_copy_resources_script
23
+ old_create_copy_resources_script
24
+ path = target.copy_framework_resources_script_path
25
+ script_path = File.expand_path('../../../../../XCodeScript/CopyFrameworkResources/copy-framework-resources.rb', __FILE__)
26
+ FileUtils.cp(script_path, path)
27
+ add_file_to_support_group(path)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ module Pod
34
+ class Installer
35
+ class UserProjectIntegrator
36
+ class TargetIntegrator
37
+ alias_method :old_add_copy_resources_script_phase, :add_copy_resources_script_phase
38
+ def add_copy_resources_script_phase
39
+ old_add_copy_resources_script_phase
40
+ phase_name = 'Copy Framework Resources'
41
+ targets = PodVersion("~>1.0") ? native_targets : native_targets_to_integrate
42
+ targets = targets.select { |t| EMBED_FRAMEWORK_TARGET_TYPES.include?(t.symbol_type) }
43
+ targets.each do |native_target|
44
+ phase = create_or_update_build_phase(native_target, phase_name)
45
+ script_path = target.copy_framework_resources_script_relative_path
46
+ phase.shell_script = %(bash -l -c "ruby \\"#{script_path}\\"")
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,11 @@
1
+ module Cocoapods
2
+ module Taobao
3
+ module Environment
4
+ VERSION = "1.0.0.3"
5
+ end
6
+ end
7
+ end
8
+
9
+ def PodVersion(version)
10
+ Gem::Dependency.new("", version).match?('', Pod::VERSION)
11
+ end
@@ -0,0 +1,3 @@
1
+ require "cocoapods-core"
2
+
3
+ require 'cocoapods/taobao/environment.rb'
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-taobao-environment
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - 梅忘
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cocoapods
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.39.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.39.0
55
+ description: 根据 CocoaPods 0.39.0 做一定的 hook.
56
+ email:
57
+ - chijing.zcj@alibaba-inc.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".gitmodules"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - XCodeScript/CopyFrameworkResources/copy-framework-resources.rb
69
+ - cocoapods-taobao-environment.gemspec
70
+ - lib/cocoapods/taobao/environment.rb
71
+ - lib/cocoapods/taobao/environment/alibaba_source.rb
72
+ - lib/cocoapods/taobao/environment/cocoapods_sync_dependencies.rb
73
+ - lib/cocoapods/taobao/environment/deintegrate_pods_for_framework_0.39.rb
74
+ - lib/cocoapods/taobao/environment/deintegrate_pods_for_framework_1.0.rb
75
+ - lib/cocoapods/taobao/environment/dynamic_dependency_for_ios_7.rb
76
+ - lib/cocoapods/taobao/environment/fix_dependency_conflict.rb
77
+ - lib/cocoapods/taobao/environment/fix_framework_search_path_0.39.rb
78
+ - lib/cocoapods/taobao/environment/fix_framework_search_path_1.0.rb
79
+ - lib/cocoapods/taobao/environment/inhibit_pod_warning.rb
80
+ - lib/cocoapods/taobao/environment/integrate_copy_framework_resouces_script.rb
81
+ - lib/cocoapods/taobao/environment/version.rb
82
+ - lib/cocoapods_plugin.rb
83
+ homepage: ''
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.4
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: 淘宝 CocoaPods Hook.
107
+ test_files: []
108
+ has_rdoc: