cocoapods-bb-PodAssistant 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +48 -0
  4. data/lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb +129 -0
  5. data/lib/cocoapods-bb-PodAssistant/babybus/helpers/babybus_info_plist_helper.rb +92 -0
  6. data/lib/cocoapods-bb-PodAssistant/babybus/installer/post_install_hooks.rb +111 -0
  7. data/lib/cocoapods-bb-PodAssistant/command/PodAssistant.rb +44 -0
  8. data/lib/cocoapods-bb-PodAssistant/command/linkline/linkline.rb +68 -0
  9. data/lib/cocoapods-bb-PodAssistant/command/linkline/target-linkline.rb +9 -0
  10. data/lib/cocoapods-bb-PodAssistant/command/linkline/targetValidator-linkline.rb +25 -0
  11. data/lib/cocoapods-bb-PodAssistant/command/linkline/targetdefinition-linkline.rb +37 -0
  12. data/lib/cocoapods-bb-PodAssistant/command/stable/podfile-linkline.rb +9 -0
  13. data/lib/cocoapods-bb-PodAssistant/command/stable/stable.rb +168 -0
  14. data/lib/cocoapods-bb-PodAssistant/command.rb +9 -0
  15. data/lib/cocoapods-bb-PodAssistant/config/cache_path.rb +16 -0
  16. data/lib/cocoapods-bb-PodAssistant/config/source_manager.rb +389 -0
  17. data/lib/cocoapods-bb-PodAssistant/config/stable_source.rb +7 -0
  18. data/lib/cocoapods-bb-PodAssistant/config/stable_specs.rb +27 -0
  19. data/lib/cocoapods-bb-PodAssistant/gem_version.rb +3 -0
  20. data/lib/cocoapods-bb-PodAssistant/helpers/git_cmd_helper.rb +73 -0
  21. data/lib/cocoapods-bb-PodAssistant/helpers/pod_module_helper.rb +246 -0
  22. data/lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb +128 -0
  23. data/lib/cocoapods-bb-PodAssistant/helpers/stable_env_helper.rb +36 -0
  24. data/lib/cocoapods-bb-PodAssistant/helpers/stable_manager_helper.rb +85 -0
  25. data/lib/cocoapods-bb-PodAssistant/helpers/yaml_files_helper.rb +72 -0
  26. data/lib/cocoapods-bb-PodAssistant/helpers.rb +6 -0
  27. data/lib/cocoapods-bb-PodAssistant/podfile.rb +392 -0
  28. data/lib/cocoapods-bb-PodAssistant/source_provider_hook.rb +335 -0
  29. data/lib/cocoapods-bb-PodAssistant.rb +1 -0
  30. data/lib/cocoapods_plugin.rb +9 -0
  31. data/spec/command/PodAssistant_spec.rb +12 -0
  32. data/spec/spec_helper.rb +50 -0
  33. metadata +132 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b51e74ff613bc48453d0b937997988c53f5afb9d510ff03a9d749c574f5400e5
4
+ data.tar.gz: 4473eeab305c9d52b40fe3964c2ab2e00daced64a6f67189b257b9ebf5f25a3e
5
+ SHA512:
6
+ metadata.gz: 5f8dfd78e3ed158208d41d15ec6258c58e0679c39e4132ff6d93cba459984de7f6b2ecf200c8db80042176b8559616388de18d62266ae5d6b630867655937846
7
+ data.tar.gz: c48dd116047320c6d2ab0ad045aa138682a00fa31752cedff4b48f02889cd65560d8cb71b8363792b1d93d2c5e3b88bf9a60fa7f14946d0d6ee67eab9b90cee0
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2023 humin <humin-ios@babybus.com>
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,48 @@
1
+ # cocoapods-bb-PodAssistant
2
+
3
+ A description of cocoapods-bb-PodAssistant.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-bb-PodAssistant
8
+
9
+ ## stale使用
10
+ 拉取稳定lock配置插件。利用版本比对进行更新配置实现对组件版本控制管理。
11
+
12
+ ```ruby
13
+ pod stable --help
14
+ ```
15
+
16
+ * 初始化本地lock文件
17
+ ```
18
+ pod stable --init
19
+ ```
20
+
21
+ * 同步lock文件
22
+ ```
23
+ pod stable
24
+ ```
25
+
26
+ ## linkline使用
27
+ 支持动态/静态库
28
+
29
+ * Build the component and all child inherit dependencies with dynamic framework
30
+ ```
31
+ pod 'xxx', :linkages => :dynamic
32
+ ```
33
+
34
+ * Build the component itself with a dynamic framework
35
+
36
+ ```
37
+ pod 'xxx', :linkage => :dynamic
38
+ ```
39
+
40
+ * Build the component and all child inherit dependencies with static framework
41
+ ```
42
+ pod 'xxx', :linkages => :static
43
+ ```
44
+
45
+ * Build the component itself with a static framework
46
+ ```
47
+ pod 'xxx', :linkage => :static
48
+ ```
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/ruby
2
+ # Author = Min Hu
3
+
4
+ require 'cocoapods-bb-PodAssistant/babybus/helpers/babybus_info_plist_helper'
5
+
6
+ class BabybusInstallEnv
7
+ #https://v3.bbcloud.babybus.com/team/184/wiki/11667
8
+ #使用工程目录下的BBPlistMacro 文件替换掉./Pods/BBBaseSDK/Pod/Classes/Macros/Macros/BBPlistMacro (为了工程新拉下来时候不用手动替换该文件)
9
+ #注意点1:BBPlistMacro 和BBBaseSDK下存在差异时,如果工程已打开的情况需要重启工程文件才能被Xcode识别到
10
+ #注意点2:BBPlistMacro 有任何的改动,都需要即使同步到 ../<包名>_BBPlistMacro.h 下面
11
+ def copyPlistMacro
12
+ puts "===拷贝PlistMacro文件操作===>".yellow
13
+ rootPath = getProjectRootPath
14
+ bundleIdentifier = getProjectBundleIdentifier
15
+ path = File.join(rootPath, "Configs", "#{bundleIdentifier}/BBPlistMacro.h")
16
+ if !File.file?(path)
17
+ path = File.join(rootPath, "Configs/PlistMacro", "#{bundleIdentifier}/BBPlistMacro.h")
18
+ if !File.file?(path)
19
+ path = File.join(rootPath, "Configs/PlistMacro", "#{bundleIdentifier}_BBPlistMacro.h")
20
+ if !File.file?(path)
21
+ path = File.join(rootPath, "Configs/PlistMacro", "BBPlistMacro.h")
22
+ end
23
+ end
24
+ end
25
+ if File.file?(path)
26
+ replaceFilePath = "./Pods/BBBaseSDK/Pod/Classes/Macros/Macros/BBPlistMacro.h"
27
+ system "chmod 755 #{replaceFilePath}"
28
+ system "cp -avf #{path} #{replaceFilePath}"
29
+ puts "替换PlistMacro文件成功".yellow
30
+ else
31
+ puts "找不到PlistMacro配置文件,替换失败path:#{path}".red
32
+ end
33
+ end
34
+ # 3D 打包res src 被删除但索引未删除需要重新添加文件夹
35
+ def createCocosResource
36
+ resPath = cocosResPath
37
+ srcPath = cocosSrcPath
38
+ if (File.exist?(resPath)) then
39
+ # system "rm -rf #{resPath}/* #{srcPath}/*"
40
+ puts "已存在 删除res src内容"
41
+ else
42
+ # 避免untify产物删除资源,工程依赖异常
43
+ system "mkdir -p #{resPath}"
44
+ system "mkdir -p #{srcPath}"
45
+ puts "生成res src资源文件夹"
46
+ end
47
+ end
48
+ # 3D替换产物
49
+ def copyUnityFramework
50
+ puts "===拷贝3D产物文件操作===>".yellow
51
+ rootPath = getProjectRootPath
52
+ bundleIdentifier = getProjectBundleIdentifier
53
+ path = File.join(rootPath, "Configs", "#{bundleIdentifier}/UnityFramework.framework")
54
+ if !File.file?(path)
55
+ path = File.join(rootPath, "Configs/UnityFramework", "#{bundleIdentifier}/UnityFramework.framework")
56
+ if !File.directory?(path)
57
+ path = File.join(rootPath, "Configs/UnityFramework", "#{bundleIdentifier}_UnityFramework.framework")
58
+ if !File.directory?(path)
59
+ path = File.join(rootPath, "Configs/UnityFramework", "UnityFramework.framework")
60
+ end
61
+ end
62
+ end
63
+ if File.directory?(path)
64
+ replaceFilePath = "./Pods/BBUnityFramework/UnityFramework.framework"
65
+ # step.1 获取原目录下没有资源
66
+ system "cp -af #{replaceFilePath}/Info.plist #{path}/Info.plist"
67
+ oldModules = "#{replaceFilePath}/Modules"
68
+ newModules = "#{path}/Modules"
69
+ if !File.directory?(newModules)
70
+ system "cp -af #{oldModules} #{newModules}"
71
+ end
72
+ oldheaders = "#{replaceFilePath}/Headers"
73
+ newHeaders = "#{path}/Headers"
74
+ if !File.directory?(newHeaders)
75
+ system "cp -af #{oldheaders} #{newHeaders}"
76
+ end
77
+ system "chmod 755 #{replaceFilePath}"
78
+ system "rm -rf #{replaceFilePath}; cp -af #{path} #{replaceFilePath}"
79
+ puts "替换UnityFramework文件成功".yellow
80
+ else
81
+ puts "找不到UnityFramework配置文件,替换失败path:#{path}".red
82
+ end
83
+ end
84
+ # 2D母包替换
85
+ def copyCocosPackage
86
+ puts "===拷贝Cocos母包文件操作===>".yellow
87
+ rootPath = getProjectRootPath
88
+ bundleIdentifier = getProjectBundleIdentifier
89
+ cocosResName
90
+ cocosSrcName
91
+ sourceRespath = File.join(rootPath, "Configs", "#{bundleIdentifier}/#{cocosResName}")
92
+ sourceSrcpath = File.join(rootPath, "Configs", "#{bundleIdentifier}/#{cocosSrcName}")
93
+ if !File.directory?(sourceRespath) || !File.directory?(sourceSrcpath)
94
+ sourceRespath = File.join(rootPath, "Configs/Cocos", "#{bundleIdentifier}/#{cocosResName}")
95
+ sourceSrcpath = File.join(rootPath, "Configs/Cocos", "#{bundleIdentifier}/#{cocosSrcName}")
96
+ if !File.directory?(sourceRespath) || !File.directory?(sourceSrcpath)
97
+ sourceRespath = File.join(rootPath, "Configs/Cocos", "#{cocosResName}")
98
+ sourceSrcpath = File.join(rootPath, "Configs/Cocos", "#{cocosSrcName}")
99
+ if !File.directory?(sourceRespath) || !File.directory?(sourceSrcpath)
100
+ sourceRespath = File.join(rootPath, "game_package/develop", "#{cocosResName}")
101
+ sourceSrcpath = File.join(rootPath, "game_package/develop", "#{cocosSrcName}")
102
+ end
103
+ end
104
+ end
105
+ if File.directory?(sourceRespath) && File.directory?(sourceSrcpath)
106
+ puts "link cocos res path:#{sourceRespath}\r\nsrc path:#{sourceSrcpath}"
107
+ descResPath = cocosResPath
108
+ desrcSrcPath = cocosSrcPath
109
+ link(sourceRespath, descResPath)
110
+ link(sourceSrcpath, desrcSrcPath)
111
+ puts "替换cocos母包文件成功".yellow
112
+ end
113
+ end
114
+ private def cocosResPath
115
+ return File.join(getProjectRootPath, cocosResName)
116
+ end
117
+ private def cocosSrcPath
118
+ return File.join(getProjectRootPath, cocosSrcName)
119
+ end
120
+ private def cocosResName
121
+ return "res"
122
+ end
123
+ private def cocosSrcName
124
+ return "src"
125
+ end
126
+ private def link(sourcePath, descPath)
127
+ system "rm -rf #{descPath} ; ln -s #{sourcePath} #{descPath}"
128
+ end
129
+ end
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/ruby
2
+ # Author = Min Hu
3
+
4
+ require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
5
+
6
+ # 是否儿童应用
7
+ def childrenApp
8
+ isChildrenValue = BB::PodUtils.getValueFromInfoPlist("Children")
9
+ return isChildrenValue === "true"
10
+ end
11
+ # 是否添加激励广告
12
+ def addRewardAd
13
+ flag = BB::PodUtils.getValueFromInfoPlist("AddRewardAd")
14
+ return flag === "true"
15
+ end
16
+ # 是否重置配置
17
+ def releaseConfig
18
+ appEnvValue = BB::PodUtils.getValueFromInfoPlist("APP_Environment")
19
+ adhocValue = BB::PodUtils.getValueFromInfoPlist("ADHOC")
20
+ return appEnvValue === "1" && adhocValue != "true"
21
+ end
22
+ # 是否显示调试工具(小白点)
23
+ def forceAddDebugTool
24
+ forceAddDebugTool = BB::PodUtils.getValueFromInfoPlist("ForceAddDebugTool")
25
+ return forceAddDebugTool === "true"
26
+ end
27
+ # 是否3d产品
28
+ def isUnity3DApp
29
+ isU3dValue = BB::PodUtils.getValueFromInfoPlist("Unity3D")
30
+ return isU3dValue === "true"
31
+ end
32
+
33
+ # 是否需要第三方支付sdk
34
+ def isThirdPaySdk
35
+ value = BB::PodUtils.getValueFromInfoPlist("Third_Purcharse")
36
+ return value === "true"
37
+ end
38
+ # 是否支持多引擎
39
+ def multiEngine
40
+ val = BB::PodUtils.getValueFromInfoPlist("MultiEngine")
41
+ return val === "true"
42
+ end
43
+ # 是否使用插件
44
+ def usePlugin(key)
45
+ val = BB::PodUtils.getValueFromInfoPlist("Plugins")
46
+ plugins = val.split("|")
47
+ plugins.each do |plugin|
48
+ if plugin.eql?(key)
49
+ return true
50
+ end
51
+ end
52
+ return false
53
+ end
54
+
55
+ # 获取工程包名
56
+ def getProjectBundleIdentifier
57
+ return BB::PodUtils.getProjectBundleIdentifier
58
+ end
59
+ # 获取工程根目录路径
60
+ def getProjectRootPath
61
+ return BB::PodUtils.getProjectRootPath
62
+ end
63
+ # 获取工程路径
64
+ def getProjectPath
65
+ return BB::PodUtils.getProjectPath
66
+ end
67
+
68
+ # 是否汉字产品
69
+ def isHanZiApp
70
+ bundleId = getProjectBundleIdentifier()
71
+ return bundleId === "com.sinyee.babybus.homeland"
72
+ end
73
+
74
+ # 是否奇妙屋产品
75
+ def isQMWApp
76
+ bundleId = getProjectBundleIdentifier()
77
+ return bundleId === "com.sinyee.babybus.talk2kiki"
78
+ end
79
+
80
+ # 是否拼音产品
81
+ def isPinyinAppp
82
+ bundleId = getProjectBundleIdentifier()
83
+ return bundleId === "com.sinyee.babybus.voicerecognition" || bundleId === "com.sinyee.babybus.read.ios" || bundleId === "com.sinyee.babybus.stroke"
84
+ end
85
+
86
+ # 是否矩阵产品
87
+ def isMatrixApp
88
+ if (isHanZiApp || isQMWApp || isPinyinAppp) then
89
+ return false
90
+ end
91
+ return true
92
+ end
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/ruby
2
+ # Author = Min Hu
3
+
4
+ require 'xcodeproj'
5
+ require 'cocoapods-bb-PodAssistant/babybus/helpers/babybus_info_plist_helper'
6
+ require 'cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment'
7
+ require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
8
+
9
+ class PodPostInstaller
10
+ def initialize(lib, deployment_target="11.0", unity_deployment_target="11.0")
11
+ @lib = lib
12
+ @deployment_target = deployment_target
13
+ @unity_deployment_target = unity_deployment_target
14
+ end
15
+ def run
16
+ env = BabybusInstallEnv.new()
17
+ is_xcode15 = BB::PodUtils.compare_xcode_15_version
18
+ # 是否Untify项目
19
+ isUnityProject = isUnity3DApp
20
+
21
+ # Untify项目需要移除cocos项目res/src目录
22
+ if (isUnityProject) then
23
+ env.createCocosResource
24
+ end
25
+ ios_deployment_target = isUnityProject ? @unity_deployment_target : @deployment_target
26
+ puts "当前工程最低支持iOS系统===>#{ios_deployment_target.to_s.send(:red)}".green
27
+ @lib.aggregate_targets.first.user_project.save # 解决Xcode13 pod update操作出现failed to save pods.xcodeproj问题 by hm 21/11/8
28
+ project = Xcodeproj::Project.open(BB::PodUtils.getXcodeprojPath)
29
+ project.targets.each do |target|
30
+ target.build_configurations.each do |config|
31
+ if config.name.include? 'Debug' # 只有debug环境才进行替换操作,其它环境交由打包机处理
32
+ puts "[#{target.name}/#{config.name}] 环境替换PlistMacro文件操作!!!开发者debug环境自行打开👇替换操作,禁止提交版本控制,谢谢🙏"
33
+ env.copyPlistMacro # 开发自行打开不能提交到版本控制,避免test包出现配置不正确情况 by hm 22/5/17
34
+ end
35
+ # iOS17适配添加ld64
36
+ if (is_xcode15 == true) then
37
+ config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -lxml2 -lz -ObjC -lstdc++ -ld64"
38
+ else
39
+ config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -lxml2 -lz -ObjC -lstdc++"
40
+ end
41
+ end
42
+ end
43
+ # projects.config
44
+ @lib.pod_target_subprojects.each do |project|
45
+ project.build_configurations.each do |config|
46
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ios_deployment_target
47
+ if (isUnityProject) then
48
+ config.build_settings['ARCHS'] = 'arm64'
49
+ else
50
+ config.build_settings['ARCHS'] = '$(ARCHS_STANDARD)'
51
+ end
52
+ end
53
+ end
54
+ # project.targets.config
55
+ @lib.pod_target_subprojects.flat_map { |p| p.targets }.each do |target|
56
+ target.build_configurations.each do |config|
57
+ # pod 1.13.0兼容故去除,避免
58
+ # 适配xcode 15 动态库报错: Error 'DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead'
59
+ # if (is_xcode15 == true) then
60
+ # xcconfig_path = config.base_configuration_reference.real_path
61
+ # xcconfig = File.read(xcconfig_path)
62
+ # xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
63
+ # File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
64
+ # end
65
+
66
+ config.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
67
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ios_deployment_target
68
+ if (isUnityProject) then
69
+ config.build_settings['ARCHS'] = 'arm64'
70
+ else
71
+ config.build_settings['ARCHS'] = '$(ARCHS_STANDARD)'
72
+ end
73
+ # fix xcode14手动签名问题 https://github.com/CocoaPods/CocoaPods/issues/11402
74
+ # config.build_settings["DEVELOPMENT_TEAM"] = "#{teamid}"
75
+ # Fix Xcode14 bundle need sign
76
+ # https://github.com/CocoaPods/CocoaPods/issues/11402#issuecomment-1201464693
77
+ if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
78
+ config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
79
+ end
80
+ # 编译器优化
81
+ config.build_settings['WARNING_CFLAGS'] = '-Wno-documentation -Wno-nullability-completeness -Wno-macro-redefined -Wno-property-attribute-mismatch -Wno-strict-prototypes -Wno-incompatible-pointer-types'
82
+ config.build_settings['ASSETCATALOG_COMPILER_OPTIMIZATION'] = 'space'
83
+ config.build_settings['ENABLE_BITCODE'] = 'NO'
84
+ config.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
85
+ if config.name.include? 'Debug'
86
+ config.build_settings['SWIFT_COMPILATION_MODE'] = 'Incremental'
87
+ config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
88
+ config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
89
+ else
90
+ config.build_settings['SWIFT_COMPILATION_MODE'] = 'wholemodule'
91
+ config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Osize'
92
+ config.build_settings['GCC_OPTIMIZATION_LEVEL'] = 'z'
93
+ end
94
+ # C++支持@import (工程中带mm类需要进行控制)
95
+ if (target.name.include? 'matrix-wechat') || (target.name.include? 'Sentry')
96
+ # 三方库不支持modulemap
97
+ config.build_settings['OTHER_CPLUSPLUSFLAGS'] = "$(inherited) $(OTHER_CFLAGS)"
98
+ else
99
+ config.build_settings['OTHER_CPLUSPLUSFLAGS'] = "$(inherited) $(OTHER_CFLAGS) -fmodules -fcxx-modules"
100
+ end
101
+
102
+ end
103
+ # 修复警告 Run script build phase '[CP] Copy Pods Resources' will be run during every build because it does not specify any outputs
104
+ fix_phases = target.shell_script_build_phases.find { |x| x.name == '[CP] Copy XCFrameworks' || 'Create Symlinks to Header Folders' }
105
+ if fix_phases
106
+ fix_phases.always_out_of_date = "1"
107
+ end
108
+ project.save
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,44 @@
1
+ module Pod
2
+ class Command
3
+ # This is an example of a cocoapods plugin adding a top-level subcommand
4
+ # to the 'pod' command.
5
+ #
6
+ # You can also create subcommands of existing or new commands. Say you
7
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
8
+ # (e.g. `pod list deprecated`), there are a few things that would need
9
+ # to change.
10
+ #
11
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
12
+ # the class to exist in the the Pod::Command::List namespace
13
+ # - change this class to extend from `List` instead of `Command`. This
14
+ # tells the plugin system that it is a subcommand of `list`.
15
+ # - edit `lib/cocoapods_plugins.rb` to require this file
16
+ #
17
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
18
+ # in the `plugins.json` file, once your plugin is released.
19
+ #
20
+ class Podassistant < Command
21
+ self.summary = 'Short description of cocoapods-bb-PodAssistant.'
22
+
23
+ self.description = <<-DESC
24
+ Longer description of cocoapods-bb-PodAssistant.
25
+ DESC
26
+
27
+ # self.arguments = 'NAME'
28
+
29
+ def initialize(argv)
30
+ # @name = argv.shift_argument
31
+ super
32
+ end
33
+
34
+ def validate!
35
+ super
36
+ # help! 'A Pod name is required.' unless @name
37
+ end
38
+
39
+ def run
40
+ UI.puts "Add your implementation for the cocoapods-bb-PodAssistant plugin in #{__FILE__}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,68 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods/user_interface'
3
+
4
+ class Pod::Installer::Analyzer
5
+ alias_method :ll_original_generate_pod_targets, :generate_pod_targets
6
+ def generate_pod_targets(resolver_specs_by_target, target_inspections)
7
+ targets = ll_original_generate_pod_targets(resolver_specs_by_target, target_inspections)
8
+ targets.each { |target|
9
+ ll_rebuild_linkage(target,target)
10
+ } unless installation_options.skip_linkline_on_local? && $ll_has_local_path
11
+ targets
12
+ end
13
+
14
+ def ll_rebuild_linkage(pod_target,root_pod_target)
15
+ ll_linkage,is_linkage_all = ll_fetch_linkage_from(pod_target)
16
+ if ll_linkage
17
+ build_type = ll_create_build_type_from(pod_target,ll_linkage)
18
+ is_need_rewrite = ll_is_need_rewrite_build_type(pod_target,ll_linkage)
19
+ pod_target.ll_rewrite_build_type(build_type) if is_need_rewrite
20
+ ll_rebuild_linkage_in_dependencies(pod_target,root_pod_target,build_type) if is_linkage_all
21
+ end
22
+ end
23
+
24
+ def ll_rebuild_linkage_in_dependencies(pod_target,root_pod_target,build_type)
25
+ return if pod_target.dependencies.empty?
26
+ pod_target.dependent_targets.each { |sub_pod_target|
27
+ ll_rebuild_linkage_sub(sub_pod_target,root_pod_target,build_type)
28
+ }
29
+ end
30
+
31
+ def ll_rebuild_linkage_sub(pod_target,root_pod_target,build_type)
32
+ exit -9090 if !build_type
33
+ ll_linkage,a = ll_fetch_linkage_from(pod_target)
34
+ if ll_linkage && ll_linkage != build_type.linkage
35
+ err_msg = "- Error: [#{pod_target.pod_name}] is define :linkage => #{ll_linkage} confict to it's parent [#{root_pod_target.pod_name}] :linkage => #{build_type}"
36
+ # raise Informative, err_msg
37
+ Pod::UI.puts "#{err_msg}".send(:red)
38
+ exit -9090
39
+ else
40
+ is_need_rewrite = ll_is_need_rewrite_build_type(pod_target,build_type.linkage)
41
+ pod_target.ll_rewrite_build_type(build_type) if is_need_rewrite
42
+ ll_rebuild_linkage_in_dependencies(pod_target,root_pod_target,build_type)
43
+ end
44
+ end
45
+
46
+ def ll_fetch_linkage_from(pod_target)
47
+ linkage = pod_target.target_definitions.map { |t| t.ll_linkages(false)[pod_target.pod_name] }.compact.first
48
+ is_linkage_all = false
49
+ if !linkage
50
+ linkage = pod_target.target_definitions.map { |t| t.ll_linkages(true)[pod_target.pod_name] }.compact.first
51
+ is_linkage_all = true if linkage
52
+ end
53
+ [linkage,is_linkage_all]
54
+ end
55
+
56
+ def ll_create_build_type_from(pod_target,linkage)
57
+ return nil if !linkage
58
+ if pod_target.build_as_framework?
59
+ Pod::BuildType.new(:linkage => linkage, :packaging => :framework)
60
+ else
61
+ Pod::BuildType.new(:linkage => linkage, :packaging => :library)
62
+ end
63
+ end
64
+
65
+ def ll_is_need_rewrite_build_type(pod_target,linkage)
66
+ ((linkage == :static && pod_target.build_as_dynamic?) || (linkage == :dynamic && pod_target.build_as_static?))
67
+ end
68
+ end
@@ -0,0 +1,9 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods/user_interface'
3
+ class Pod::Target
4
+ #define a func to rewrite target build_type, the build_type property is private
5
+ def ll_rewrite_build_type(build_type)
6
+ Pod::UI.puts "#{name} rebuild :linkage => #{build_type}"
7
+ @build_type = build_type
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ module Pod
2
+ class Installer
3
+
4
+ # extension new option :skip_verify_static_framework, defalut false
5
+ class InstallationOptions
6
+ # Whether to skip verify dynimic framework linked static frameworks. defalut is verify
7
+ option :skip_verify_static_framework, false
8
+
9
+ # Whether to disable linkline framework on local
10
+ option :skip_linkline_on_local, false
11
+ end
12
+
13
+ class Xcode
14
+ class TargetValidator
15
+
16
+ alias_method :ll_verify_no_static_framework_transitive_dependencies, :verify_no_static_framework_transitive_dependencies
17
+ def verify_no_static_framework_transitive_dependencies
18
+ # if skip_verify_static_framework is true, skip verify!
19
+ ll_verify_no_static_framework_transitive_dependencies unless installation_options.skip_verify_static_framework?
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods-core'
3
+
4
+ module Pod
5
+ class Podfile
6
+ class TargetDefinition
7
+
8
+ # linklines is a array to save data if you directy define :linkage => static or :linkage => dynimic
9
+ def ll_expedition_linkages(name, requirements,key)
10
+ linklines ||= {}
11
+ options = requirements.last || {}
12
+ linklines[Specification.root_name(name)] = options[key] if options.is_a?(Hash) && options[key]
13
+ options.delete(key) if options.is_a?(Hash)
14
+ requirements.pop if options.empty?
15
+ linklines
16
+ end
17
+
18
+ def ll_linkages(is_linkage_all)
19
+ pod_linkage = (is_linkage_all == true ? @linkages : @linkage) || {}
20
+ pod_linkage.merge!(parent.ll_linkages(is_linkage_all)) { |key, v1, v2| v1 } if !parent.nil? && parent.is_a?(TargetDefinition)
21
+ pod_linkage
22
+ end
23
+
24
+ ll_original_parse_inhibit_warnings = instance_method(:parse_inhibit_warnings)
25
+ define_method(:parse_inhibit_warnings) do |name, requirements|
26
+ if (requirements.last.is_a? Hash) && requirements.last.has_key?(:path)
27
+ $ll_has_local_path = true
28
+ end
29
+ @linkage ||= {}
30
+ @linkages ||= {}
31
+ @linkage = @linkage.merge(ll_expedition_linkages(name, requirements,:linkage))
32
+ @linkages = @linkages.merge(ll_expedition_linkages(name, requirements,:linkages))
33
+ ll_original_parse_inhibit_warnings.bind(self).call(name, requirements)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ module Pod
2
+ class Podfile
3
+ module DSL
4
+ #a func define to avoid pod command error
5
+ def stable!(source, options = {})
6
+ end
7
+ end
8
+ end
9
+ end