cocoapods-mPaaS 1.0.0
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 +7 -0
- data/lib/cocoapods-mPaaS/baselineTools.rb +493 -0
- data/lib/cocoapods-mPaaS/checkUpdateTools.rb +42 -0
- data/lib/cocoapods-mPaaS/cocoapods_hook.rb +929 -0
- data/lib/cocoapods-mPaaS/command/mPaaS.rb +44 -0
- data/lib/cocoapods-mPaaS/command/mpaas/dev.rb +17 -0
- data/lib/cocoapods-mPaaS/command/mpaas/info.rb +170 -0
- data/lib/cocoapods-mPaaS/command/mpaas/init.rb +112 -0
- data/lib/cocoapods-mPaaS/command/mpaas/local_command.rb +49 -0
- data/lib/cocoapods-mPaaS/command/mpaas/open.rb +17 -0
- data/lib/cocoapods-mPaaS/command/mpaas/update.rb +223 -0
- data/lib/cocoapods-mPaaS/command/mpaas/version.rb +32 -0
- data/lib/cocoapods-mPaaS/command.rb +1 -0
- data/lib/cocoapods-mPaaS/dsl.rb +498 -0
- data/lib/cocoapods-mPaaS/gem_version.rb +5 -0
- data/lib/cocoapods-mPaaS/installNew.rb +303 -0
- data/lib/cocoapods-mPaaS/locales/en.yml +140 -0
- data/lib/cocoapods-mPaaS/locales/zh-Hans.yml +144 -0
- data/lib/cocoapods-mPaaS/localization.rb +238 -0
- data/lib/cocoapods-mPaaS/logTools.rb +67 -0
- data/lib/cocoapods-mPaaS/mPaaSPodfile.rb +117 -0
- data/lib/cocoapods-mPaaS/module_config.rb +298 -0
- data/lib/cocoapods-mPaaS/podfileTools.rb +48 -0
- data/lib/cocoapods-mPaaS/post_install_hook_processor.rb +61 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.h +13 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/Contents.json +6 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/Contents.json +22 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@2x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@3x.png +0 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.m +135 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.h +16 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.m +86 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.h +21 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.m +104 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.m +91 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.m +25 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.h +10 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.m +43 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.m +27 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.h +8 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.m +19 -0
- data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MobileRuntime.plist +26 -0
- data/lib/cocoapods-mPaaS/write_info_list_mPaaSApp.rb +125 -0
- data/lib/cocoapods-mPaaS/xcode_helper.rb +334 -0
- data/lib/cocoapods-mPaaS.rb +41 -0
- data/lib/cocoapods_plugin.rb +15 -0
- metadata +160 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# 并返回path
|
|
2
|
+
def write_file_to_path(path, content)
|
|
3
|
+
file = File.new(path, "w")
|
|
4
|
+
file.puts content
|
|
5
|
+
file.close
|
|
6
|
+
return path
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def puts_line_to_string(s, line)
|
|
10
|
+
s.concat(line)
|
|
11
|
+
s.concat("\n")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# 从原始配置中生成为模块配置的.m和.h
|
|
15
|
+
def generate_module_config_source(config, target)
|
|
16
|
+
result = Hash[]
|
|
17
|
+
|
|
18
|
+
class_name = config["class"]
|
|
19
|
+
header = config["header"]
|
|
20
|
+
author = get_current_user
|
|
21
|
+
time_str = Time.new.strftime("%Y/%m/%d")
|
|
22
|
+
|
|
23
|
+
result["source_file"] = "#{class_name}+#{target}.m"
|
|
24
|
+
result["header_file"] = "#{class_name}+#{target}.h"
|
|
25
|
+
|
|
26
|
+
# .m 文件
|
|
27
|
+
m_source = ""
|
|
28
|
+
puts_line_to_string(m_source, "//")
|
|
29
|
+
puts_line_to_string(m_source, "// #{result["source_file"]}")
|
|
30
|
+
puts_line_to_string(m_source, "// #{target}")
|
|
31
|
+
puts_line_to_string(m_source, "//")
|
|
32
|
+
puts_line_to_string(m_source, "// Created by #{author} on #{time_str}. All rights reserved.")
|
|
33
|
+
puts_line_to_string(m_source, "//")
|
|
34
|
+
puts_line_to_string(m_source, "")
|
|
35
|
+
puts_line_to_string(m_source, "#import \"#{result["header_file"]}\"")
|
|
36
|
+
puts_line_to_string(m_source, "")
|
|
37
|
+
puts_line_to_string(m_source, "#pragma clang diagnostic push")
|
|
38
|
+
puts_line_to_string(m_source, "#pragma clang diagnostic ignored \"-Wobjc-protocol-method-implementation\"")
|
|
39
|
+
puts_line_to_string(m_source, "")
|
|
40
|
+
puts_line_to_string(m_source, "@implementation #{class_name} (#{target})")
|
|
41
|
+
puts_line_to_string(m_source, "")
|
|
42
|
+
|
|
43
|
+
# 添加方法实现
|
|
44
|
+
if config["methods"] != nil
|
|
45
|
+
config["methods"].each do |m|
|
|
46
|
+
puts_line_to_string(m_source, m)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
puts_line_to_string(m_source, "@end")
|
|
51
|
+
puts_line_to_string(m_source, "")
|
|
52
|
+
puts_line_to_string(m_source, "#pragma clang diagnostic pop")
|
|
53
|
+
puts_line_to_string(m_source, "")
|
|
54
|
+
|
|
55
|
+
result["source"] = m_source
|
|
56
|
+
|
|
57
|
+
# .h 文件
|
|
58
|
+
h_source = ""
|
|
59
|
+
puts_line_to_string(h_source, "//")
|
|
60
|
+
puts_line_to_string(h_source, "// #{result["header_file"]}")
|
|
61
|
+
puts_line_to_string(h_source, "// #{target}")
|
|
62
|
+
puts_line_to_string(h_source, "//")
|
|
63
|
+
puts_line_to_string(h_source, "// Created by #{author} on #{time_str}. All rights reserved.")
|
|
64
|
+
puts_line_to_string(h_source, "//")
|
|
65
|
+
puts_line_to_string(h_source, "")
|
|
66
|
+
puts_line_to_string(h_source, "#import #{header}")
|
|
67
|
+
puts_line_to_string(h_source, "")
|
|
68
|
+
puts_line_to_string(h_source, "@interface #{class_name} (#{target})")
|
|
69
|
+
puts_line_to_string(h_source, "")
|
|
70
|
+
puts_line_to_string(h_source, "@end")
|
|
71
|
+
puts_line_to_string(h_source, "")
|
|
72
|
+
|
|
73
|
+
result["header"] = h_source
|
|
74
|
+
|
|
75
|
+
return result
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def is_source_file(path)
|
|
79
|
+
path = File::basename(path)
|
|
80
|
+
parts = path.split(".")
|
|
81
|
+
ext = parts.last
|
|
82
|
+
if ext != nil
|
|
83
|
+
return (ext == "m") || (ext == "mm") || (ext == "c") || (ext == "cpp") || (ext == "swift")
|
|
84
|
+
end
|
|
85
|
+
return false
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def find_file_recursively(file, path)
|
|
89
|
+
entries = Dir::entries(path)
|
|
90
|
+
entries.each do |entry|
|
|
91
|
+
if entry[0] != "."
|
|
92
|
+
filePath = path + "/" + entry
|
|
93
|
+
if File::directory?(filePath)
|
|
94
|
+
result = find_file_recursively file, filePath
|
|
95
|
+
if result != nil
|
|
96
|
+
return result
|
|
97
|
+
end
|
|
98
|
+
elsif entry == file
|
|
99
|
+
return filePath
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
return nil
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def execute_source_action(action, resources_path, working_path, ref, target, xcproj)
|
|
107
|
+
if action["files"]
|
|
108
|
+
action["files"].each do |f|
|
|
109
|
+
original_path = "#{resources_path}/#{f}"
|
|
110
|
+
working_file_path = "#{working_path}/#{f}"
|
|
111
|
+
# LogTools.p "#{working_path}"
|
|
112
|
+
if (File::exist?(original_path))
|
|
113
|
+
if !(File::exist?(working_file_path))
|
|
114
|
+
FileUtils.cp_r original_path, working_path
|
|
115
|
+
if is_source_file(f)
|
|
116
|
+
add_source_file(ref, f, target, xcproj)
|
|
117
|
+
else
|
|
118
|
+
add_non_source_file(ref, f, xcproj)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
else
|
|
122
|
+
LogTools.p_red "Required file '#{original_path}' missing."
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def execute_resource_action(action, resources_path, working_path, ref, target, xcproj)
|
|
129
|
+
if action["files"]
|
|
130
|
+
action["files"].each do |f|
|
|
131
|
+
original_path = "#{resources_path}/#{f}"
|
|
132
|
+
working_file_path = "#{working_path}/#{f}"
|
|
133
|
+
# LogTools.p "#{working_path}"
|
|
134
|
+
if File::exist?(original_path)
|
|
135
|
+
if !(File::exist?(working_file_path))
|
|
136
|
+
FileUtils.cp_r original_path, working_path
|
|
137
|
+
res_ref = add_resource_ref(ref, f, xcproj)
|
|
138
|
+
add_resource_to_build_phase(res_ref, target, xcproj)
|
|
139
|
+
end
|
|
140
|
+
else
|
|
141
|
+
LogTools.p_red "Required file '#{original_path}' missing."
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def execute_microapplication_action(action, resources_path, working_path, ref, target, xcproj)
|
|
148
|
+
# 找该target对应的MobileRuntime.plist,只有编译为可执行文件时才做这个action
|
|
149
|
+
if is_target_executable(target, xcproj)
|
|
150
|
+
parent_path = File::dirname(working_path)
|
|
151
|
+
plist_path = "#{parent_path}/MPMobileFramework/MobileRuntime.plist"
|
|
152
|
+
# LogTools.p "A: #{plist_path}"
|
|
153
|
+
if File::exist?(plist_path)
|
|
154
|
+
params = action["params"]
|
|
155
|
+
name = params["name"]
|
|
156
|
+
delegate = params["delegate"]
|
|
157
|
+
description = params["description"]
|
|
158
|
+
|
|
159
|
+
# 在MobileRuntime.plist里添加应用
|
|
160
|
+
LogTools.p "Write micro-application '#{name}' into 'MobileRuntime.plist'."
|
|
161
|
+
system "/usr/libexec/PlistBuddy -c \"Add :Applications:0:name string \\\"#{name}\\\"\" \"#{plist_path}\""
|
|
162
|
+
system "/usr/libexec/PlistBuddy -c \"Add :Applications:0:delegate string \\\"#{delegate}\\\"\" \"#{plist_path}\""
|
|
163
|
+
system "/usr/libexec/PlistBuddy -c \"Add :Applications:0:description string \\\"#{description}\\\"\" \"#{plist_path}\""
|
|
164
|
+
|
|
165
|
+
if params["set_launcher"]
|
|
166
|
+
LogTools.p "Set micro-application '#{name}' as Launcher."
|
|
167
|
+
system "/usr/libexec/PlistBuddy -c \"Set :Launcher \\\"#{name}\\\"\" \"#{plist_path}\""
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def execute_mainuseframework_action(action, resources_path, working_path, ref, target, xcproj)
|
|
174
|
+
# LogTools.p "B"
|
|
175
|
+
if is_target_executable(target, xcproj)
|
|
176
|
+
# 需要到工程的Target对应的目录里找使用的main.m文件
|
|
177
|
+
target_path = File::dirname(working_path)
|
|
178
|
+
targets_path = File::dirname(target_path)
|
|
179
|
+
mpaas_path = File::dirname(targets_path)
|
|
180
|
+
project_path = File::dirname(mpaas_path)
|
|
181
|
+
|
|
182
|
+
target_path = "#{project_path}/#{target}"
|
|
183
|
+
# LogTools.p "B: #{target_path}"
|
|
184
|
+
if File::exist?(target_path)
|
|
185
|
+
main_path = find_file_recursively("main.m", target_path)
|
|
186
|
+
if main_path != nil
|
|
187
|
+
lines = IO.readlines(main_path)
|
|
188
|
+
|
|
189
|
+
# 先判断下是否已经改过,避免重复,todo 效率
|
|
190
|
+
hasAdd = false
|
|
191
|
+
lines.each do |l|
|
|
192
|
+
if l.include?("DFApplication") || l.include?("DFClientDelegate")
|
|
193
|
+
hasAdd = true
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
unless hasAdd
|
|
198
|
+
override = File.new(main_path, "w")
|
|
199
|
+
|
|
200
|
+
lines.each do |l|
|
|
201
|
+
if l =~ /\s*return\s+UIApplicationMain\s*\(.+/
|
|
202
|
+
override.puts "//#{l}" # 把原来的注释掉并写入文件
|
|
203
|
+
override.puts " return UIApplicationMain(argc, argv, @\"DFApplication\", @\"DFClientDelegate\"); // NOW USE MPAAS FRAMEWORK"
|
|
204
|
+
else
|
|
205
|
+
override.puts l
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
override.close
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def execute_mainusecrashreporting_action(action, resources_path, working_path, ref, target, xcproj)
|
|
217
|
+
if is_target_executable(target, xcproj)
|
|
218
|
+
# 需要到工程的Target对应的目录里找使用的main.m文件
|
|
219
|
+
target_path = File::dirname(working_path)
|
|
220
|
+
targets_path = File::dirname(target_path)
|
|
221
|
+
mpaas_path = File::dirname(targets_path)
|
|
222
|
+
project_path = File::dirname(mpaas_path)
|
|
223
|
+
|
|
224
|
+
target_path = "#{project_path}/#{target}"
|
|
225
|
+
LogTools.v_green "execute_mainusecrashreporting_action"
|
|
226
|
+
crash_enable_line = " [MPAnalysisHelper enableCrashReporterService]; // USE MPAAS CRASH REPORTER"
|
|
227
|
+
if File::exist?(target_path)
|
|
228
|
+
main_path = find_file_recursively("main.m", target_path)
|
|
229
|
+
if main_path != nil
|
|
230
|
+
lines = IO.readlines(main_path)
|
|
231
|
+
override = File.new(main_path, "w")
|
|
232
|
+
in_function = false
|
|
233
|
+
lines.each do |l|
|
|
234
|
+
if l =~ /\s*int\s+main\s*\(\s*int\s+argc\s*,\s*char\s*\*\s*argv\s*\[\s*\]\s*\).*/
|
|
235
|
+
override.puts l
|
|
236
|
+
if l =~ /.*\{\s*/
|
|
237
|
+
override.puts "#{crash_enable_line}"
|
|
238
|
+
else
|
|
239
|
+
in_function = true
|
|
240
|
+
end
|
|
241
|
+
else
|
|
242
|
+
if in_function
|
|
243
|
+
override.puts l
|
|
244
|
+
override.puts "#{crash_enable_line}"
|
|
245
|
+
in_function = false
|
|
246
|
+
else
|
|
247
|
+
#做判断是否是" enableCrashReporterService // USE MPAAS CRASH REPORTER"
|
|
248
|
+
if !(l =~ /.*enableCrashReporterService.*/)
|
|
249
|
+
override.puts l
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
override.close
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def execute_module_action(action, resources_path, working_path, ref, target, xcproj)
|
|
261
|
+
if action["type"] == nil
|
|
262
|
+
LogTools.p_red "Invalid action with content '#{action}'."
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
if action["type"] == "source"
|
|
266
|
+
execute_source_action(action, resources_path, working_path, ref, target, xcproj)
|
|
267
|
+
elsif action["type"] == "resource"
|
|
268
|
+
execute_resource_action(action, resources_path, working_path, ref, target, xcproj)
|
|
269
|
+
elsif action["type"] == "micro_application"
|
|
270
|
+
execute_microapplication_action(action, resources_path, working_path, ref, target, xcproj)
|
|
271
|
+
elsif action["type"] == "main_use_framework"
|
|
272
|
+
execute_mainuseframework_action(action, resources_path, working_path, ref, target, xcproj)
|
|
273
|
+
# elsif action["type"] == "main_use_crashreporting"
|
|
274
|
+
# execute_mainusecrashreporting_action(action, resources_path, working_path, ref, target, xcproj)
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
# 读取文件中的模块名,并返回一个集合
|
|
279
|
+
def extract_unique_module_names(file_path)
|
|
280
|
+
module_names = Set.new
|
|
281
|
+
File.foreach(file_path) do |line|
|
|
282
|
+
# 去除注释和行首尾空白
|
|
283
|
+
module_name = line.gsub(/#.*$/, '').strip
|
|
284
|
+
# 如果模块名非空,则添加到集合中
|
|
285
|
+
module_names << module_name unless module_name.empty?
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
return module_names
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# 将数组中的元素追加到文件中
|
|
292
|
+
def append_array_to_file(file_path, array, delimiter="\n")
|
|
293
|
+
# 打开文件,以追加模式写入
|
|
294
|
+
File.open(file_path, 'a') do |file|
|
|
295
|
+
# 将数组中的元素用指定分隔符连接成一个字符串
|
|
296
|
+
file.puts array.join(delimiter)
|
|
297
|
+
end
|
|
298
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class PodfileTools
|
|
2
|
+
def self.writeVersionCode(podfile_path)
|
|
3
|
+
baseline = BaselineTools.getBaselineMatched(podfile_path)
|
|
4
|
+
version_code = BaselineTools.getVersionCodeInLocalByBaseline(baseline)
|
|
5
|
+
# LogTools.p_red version_code.to_s
|
|
6
|
+
|
|
7
|
+
# 先简单文本处理,todo ruby解析或者正则
|
|
8
|
+
io = File::open(podfile_path).readlines
|
|
9
|
+
|
|
10
|
+
# 全局判断不用了
|
|
11
|
+
# io_full = File.read(podfile_path)
|
|
12
|
+
|
|
13
|
+
override = File.new(podfile_path, "w")
|
|
14
|
+
|
|
15
|
+
need_write_in_last = true
|
|
16
|
+
|
|
17
|
+
# 先判断全局有没有
|
|
18
|
+
# if !io_full.include?("mPaaS_version_code")
|
|
19
|
+
# need_write_in_last = true
|
|
20
|
+
# end
|
|
21
|
+
|
|
22
|
+
io.each do |line|
|
|
23
|
+
if line.include?("mPaaS_version_code")
|
|
24
|
+
next
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
override.puts line
|
|
28
|
+
|
|
29
|
+
# 有 mPaaS_baseline 就写在下一行
|
|
30
|
+
if line.include?("mPaaS_baseline")
|
|
31
|
+
need_write_in_last = false
|
|
32
|
+
override.puts("mPaaS_version_code #{version_code} # This line is maintained by MPaaS plugin automatically. Please don't modify.")
|
|
33
|
+
|
|
34
|
+
LogTools.p "write 'mPaaS_version_code #{version_code}' in the Podfile"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# 如果上面 mPaaS_baseline 没加过,就写在最后
|
|
39
|
+
if need_write_in_last
|
|
40
|
+
override.puts("")
|
|
41
|
+
override.puts("mPaaS_version_code #{version_code} # This line is maintained by MPaaS plugin automatically. Please don't modify.")
|
|
42
|
+
|
|
43
|
+
LogTools.p "write 'mPaaS_version_code #{version_code}' in the Podfile"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
override.close
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# lib/cocoapods_mPaaS/post_install_hook_processor.rb
|
|
2
|
+
|
|
3
|
+
module CocoaPodsMPaaS
|
|
4
|
+
class PostInstallHookProcessor
|
|
5
|
+
attr_reader :context
|
|
6
|
+
|
|
7
|
+
def initialize(post_install_context)
|
|
8
|
+
@context = post_install_context
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def apply_excluded_archs_to_pods_project
|
|
12
|
+
LogTools.p "[cocoapods-mPaaS] Applying EXCLUDED_ARCHS to Pods project..."
|
|
13
|
+
@context.pods_project.build_configurations.each do |config|
|
|
14
|
+
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
|
|
15
|
+
end
|
|
16
|
+
@context.pods_project.save
|
|
17
|
+
LogTools.p "[cocoapods-mPaaS] Applied EXCLUDED_ARCHS for simulator to Pods project."
|
|
18
|
+
rescue => e
|
|
19
|
+
LogTools.p_yellow "⚠️ [cocoapods-mPaaS] Failed to apply EXCLUDED_ARCHS to Pods project: #{e.message}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def apply_excluded_archs_to_user_project_targets
|
|
23
|
+
LogTools.p "[cocoapods-mPaaS] Applying EXCLUDED_ARCHS to user project targets..."
|
|
24
|
+
|
|
25
|
+
@context.umbrella_targets.each do |umbrella_target_description|
|
|
26
|
+
user_project = umbrella_target_description.user_project
|
|
27
|
+
|
|
28
|
+
if user_project.nil?
|
|
29
|
+
# 使用 cocoapods_target_label 来唯一标识 umbrella_target_description
|
|
30
|
+
LogTools.p_yellow "⚠️ [cocoapods-mPaaS] Could not find user project for umbrella target: #{umbrella_target_description.cocoapods_target_label}!"
|
|
31
|
+
next
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# 使用 user_project.path.basename 来获取项目名称
|
|
35
|
+
project_name = user_project.path.basename.to_s
|
|
36
|
+
LogTools.v "[cocoapods-mPaaS] Found user project: #{project_name} (Umbrella Target: #{umbrella_target_description.cocoapods_target_label})"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if user_project.targets.empty?
|
|
40
|
+
LogTools.p_yellow "[cocoapods-mPaaS] User project '#{project_name}' has no targets to modify!"
|
|
41
|
+
next
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
user_project.targets.each do |target|
|
|
45
|
+
LogTools.v " - Processing target: #{target.name} in project #{project_name}"
|
|
46
|
+
target.build_configurations.each do |config|
|
|
47
|
+
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
|
|
48
|
+
end
|
|
49
|
+
LogTools.v " - Applied EXCLUDED_ARCHS to target: #{target.name}"
|
|
50
|
+
end
|
|
51
|
+
user_project.save
|
|
52
|
+
LogTools.v " [cocoapods-mPaaS] User project '#{project_name}' targets updated with EXCLUDED_ARCHS for simulator."
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
LogTools.p "✅ [cocoapods-mPaaS] All user project targets (across all umbrella targets) updated with EXCLUDED_ARCHS for simulator."
|
|
56
|
+
rescue => e
|
|
57
|
+
LogTools.p_yellow "⚠️ [cocoapods-mPaaS] Failed to apply EXCLUDED_ARCHS to user project targets: #{e.message}"
|
|
58
|
+
LogTools.p_yellow "⚠️ [cocoapods-mPaaS] Backtrace: #{e.backtrace.join("\n")}"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DemoViewController.m
|
|
3
|
+
// test
|
|
4
|
+
//
|
|
5
|
+
// Created by mPaaS on 16/11/21.
|
|
6
|
+
// Copyright © 2016年 Alibaba. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "DemoViewController.h"
|
|
10
|
+
|
|
11
|
+
@interface DemoViewController ()
|
|
12
|
+
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
@implementation DemoViewController
|
|
16
|
+
|
|
17
|
+
- (void)viewDidLoad {
|
|
18
|
+
[super viewDidLoad];
|
|
19
|
+
// Do any additional setup after loading the view.
|
|
20
|
+
|
|
21
|
+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(130, self.view.bounds.size.height/2-60, self.view.bounds.size.width-60, 40)];
|
|
22
|
+
label.text = @"Hello World!";
|
|
23
|
+
label.font = [UIFont systemFontOfSize:30];
|
|
24
|
+
label.textColor = [UIColor redColor];
|
|
25
|
+
[self.view addSubview:label];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
- (void)didReceiveMemoryWarning {
|
|
29
|
+
[super didReceiveMemoryWarning];
|
|
30
|
+
// Dispose of any resources that can be recreated.
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
#pragma mark - Navigation
|
|
35
|
+
|
|
36
|
+
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
37
|
+
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
38
|
+
// Get the new view controller using [segue destinationViewController].
|
|
39
|
+
// Pass the selected object to the new view controller.
|
|
40
|
+
}
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"scale" : "1x"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"idiom" : "universal",
|
|
9
|
+
"scale" : "2x",
|
|
10
|
+
"filename" : "TabBar_Discovery@2x.png"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idiom" : "universal",
|
|
14
|
+
"scale" : "3x",
|
|
15
|
+
"filename" : "TabBar_Discovery@3x.png"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"info" : {
|
|
19
|
+
"version" : 1,
|
|
20
|
+
"author" : "xcode"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"scale" : "1x"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"idiom" : "universal",
|
|
9
|
+
"scale" : "2x",
|
|
10
|
+
"filename" : "TabBar_Discovery_Sel@2x.png"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idiom" : "universal",
|
|
14
|
+
"scale" : "3x",
|
|
15
|
+
"filename" : "TabBar_Discovery_Sel@3x.png"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"info" : {
|
|
19
|
+
"version" : 1,
|
|
20
|
+
"author" : "xcode"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"scale" : "1x"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"idiom" : "universal",
|
|
9
|
+
"scale" : "2x",
|
|
10
|
+
"filename" : "TabBar_Friends@2x.png"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idiom" : "universal",
|
|
14
|
+
"scale" : "3x",
|
|
15
|
+
"filename" : "TabBar_Friends@3x.png"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"info" : {
|
|
19
|
+
"version" : 1,
|
|
20
|
+
"author" : "xcode"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"scale" : "1x"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"idiom" : "universal",
|
|
9
|
+
"scale" : "2x",
|
|
10
|
+
"filename" : "TabBar_Friends_Sel@2x.png"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idiom" : "universal",
|
|
14
|
+
"scale" : "3x",
|
|
15
|
+
"filename" : "TabBar_Friends_Sel@3x.png"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"info" : {
|
|
19
|
+
"version" : 1,
|
|
20
|
+
"author" : "xcode"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"scale" : "1x"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"idiom" : "universal",
|
|
9
|
+
"filename" : "icon30-line@2x.png",
|
|
10
|
+
"scale" : "2x"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idiom" : "universal",
|
|
14
|
+
"filename" : "icon30-line@3x.png",
|
|
15
|
+
"scale" : "3x"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"info" : {
|
|
19
|
+
"version" : 1,
|
|
20
|
+
"author" : "xcode"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"scale" : "1x"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"idiom" : "universal",
|
|
9
|
+
"filename" : "icon30@2x.png",
|
|
10
|
+
"scale" : "2x"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idiom" : "universal",
|
|
14
|
+
"filename" : "icon30@3x.png",
|
|
15
|
+
"scale" : "3x"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"info" : {
|
|
19
|
+
"version" : 1,
|
|
20
|
+
"author" : "xcode"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"scale" : "1x"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"idiom" : "universal",
|
|
9
|
+
"scale" : "2x",
|
|
10
|
+
"filename" : "TabBar_PublicService@2x.png"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idiom" : "universal",
|
|
14
|
+
"scale" : "3x",
|
|
15
|
+
"filename" : "TabBar_PublicService@3x.png"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"info" : {
|
|
19
|
+
"version" : 1,
|
|
20
|
+
"author" : "xcode"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|