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.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cocoapods-mPaaS/baselineTools.rb +493 -0
  3. data/lib/cocoapods-mPaaS/checkUpdateTools.rb +42 -0
  4. data/lib/cocoapods-mPaaS/cocoapods_hook.rb +929 -0
  5. data/lib/cocoapods-mPaaS/command/mPaaS.rb +44 -0
  6. data/lib/cocoapods-mPaaS/command/mpaas/dev.rb +17 -0
  7. data/lib/cocoapods-mPaaS/command/mpaas/info.rb +170 -0
  8. data/lib/cocoapods-mPaaS/command/mpaas/init.rb +112 -0
  9. data/lib/cocoapods-mPaaS/command/mpaas/local_command.rb +49 -0
  10. data/lib/cocoapods-mPaaS/command/mpaas/open.rb +17 -0
  11. data/lib/cocoapods-mPaaS/command/mpaas/update.rb +223 -0
  12. data/lib/cocoapods-mPaaS/command/mpaas/version.rb +32 -0
  13. data/lib/cocoapods-mPaaS/command.rb +1 -0
  14. data/lib/cocoapods-mPaaS/dsl.rb +498 -0
  15. data/lib/cocoapods-mPaaS/gem_version.rb +5 -0
  16. data/lib/cocoapods-mPaaS/installNew.rb +303 -0
  17. data/lib/cocoapods-mPaaS/locales/en.yml +140 -0
  18. data/lib/cocoapods-mPaaS/locales/zh-Hans.yml +144 -0
  19. data/lib/cocoapods-mPaaS/localization.rb +238 -0
  20. data/lib/cocoapods-mPaaS/logTools.rb +67 -0
  21. data/lib/cocoapods-mPaaS/mPaaSPodfile.rb +117 -0
  22. data/lib/cocoapods-mPaaS/module_config.rb +298 -0
  23. data/lib/cocoapods-mPaaS/podfileTools.rb +48 -0
  24. data/lib/cocoapods-mPaaS/post_install_hook_processor.rb +61 -0
  25. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.h +13 -0
  26. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.m +43 -0
  27. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/Contents.json +6 -0
  28. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/Contents.json +22 -0
  29. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@2x.png +0 -0
  30. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@3x.png +0 -0
  31. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/Contents.json +22 -0
  32. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@2x.png +0 -0
  33. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@3x.png +0 -0
  34. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/Contents.json +22 -0
  35. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@2x.png +0 -0
  36. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@3x.png +0 -0
  37. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/Contents.json +22 -0
  38. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@2x.png +0 -0
  39. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@3x.png +0 -0
  40. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/Contents.json +22 -0
  41. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@2x.png +0 -0
  42. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@3x.png +0 -0
  43. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/Contents.json +22 -0
  44. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@2x.png +0 -0
  45. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@3x.png +0 -0
  46. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/Contents.json +22 -0
  47. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@2x.png +0 -0
  48. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@3x.png +0 -0
  49. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/Contents.json +22 -0
  50. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@2x.png +0 -0
  51. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@3x.png +0 -0
  52. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.h +10 -0
  53. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.m +43 -0
  54. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.h +8 -0
  55. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.m +135 -0
  56. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.h +10 -0
  57. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.m +43 -0
  58. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.h +16 -0
  59. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.m +86 -0
  60. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.h +21 -0
  61. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.m +104 -0
  62. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.h +10 -0
  63. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.m +91 -0
  64. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.h +8 -0
  65. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.m +25 -0
  66. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.h +10 -0
  67. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.m +43 -0
  68. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.h +8 -0
  69. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.m +27 -0
  70. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.h +8 -0
  71. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.m +19 -0
  72. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MobileRuntime.plist +26 -0
  73. data/lib/cocoapods-mPaaS/write_info_list_mPaaSApp.rb +125 -0
  74. data/lib/cocoapods-mPaaS/xcode_helper.rb +334 -0
  75. data/lib/cocoapods-mPaaS.rb +41 -0
  76. data/lib/cocoapods_plugin.rb +15 -0
  77. metadata +160 -0
@@ -0,0 +1,43 @@
1
+ //
2
+ // MPDrawerLauncherAppDelegate.m
3
+
4
+ #import "MPNavigationLauncherAppDelegate.h"
5
+ #import "MPNavigationController.h"
6
+
7
+ @interface MPNavigationLauncherAppDelegate ()
8
+
9
+ @property (nonatomic, strong) UIViewController* rootController;
10
+ @property (nonatomic, strong) MPNavigationController* controller;
11
+
12
+ @end
13
+
14
+ @implementation MPNavigationLauncherAppDelegate
15
+
16
+ - (id)init
17
+ {
18
+ self = [super init];
19
+ if (self)
20
+ {
21
+ _controller = [[MPNavigationController alloc] init];
22
+ self.rootController = self.controller;
23
+ }
24
+ return self;
25
+ }
26
+
27
+
28
+ - (UIViewController *)rootControllerInApplication:(DTMicroApplication *)application
29
+ {
30
+ return self.rootController;
31
+ }
32
+
33
+ - (void)application:(DTMicroApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
34
+ {
35
+
36
+ }
37
+
38
+ - (void)application:(DTMicroApplication *)application willResumeWithOptions:(NSDictionary *)launchOptions
39
+ {
40
+
41
+ }
42
+
43
+ @end
@@ -0,0 +1,8 @@
1
+ //
2
+ // MPTabBarController.h
3
+
4
+ #import <UIKit/UIKit.h>
5
+
6
+ @interface MPTabBarController : UITabBarController <UITabBarControllerDelegate>
7
+
8
+ @end
@@ -0,0 +1,27 @@
1
+ //
2
+ // MPTabBarController.m
3
+
4
+ #import "MPTabBarController.h"
5
+
6
+ @interface MPTabBarController ()
7
+
8
+ @end
9
+
10
+ @implementation MPTabBarController
11
+
12
+ - (void)loadView
13
+ {
14
+ [super loadView];
15
+ self.delegate = self;
16
+ }
17
+
18
+ - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
19
+ {
20
+ self.title = viewController.title;
21
+ self.navigationItem.leftBarButtonItem = viewController.navigationItem.leftBarButtonItem;
22
+ self.navigationItem.leftBarButtonItems = viewController.navigationItem.leftBarButtonItems;
23
+ self.navigationItem.rightBarButtonItem = viewController.navigationItem.rightBarButtonItem;
24
+ self.navigationItem.rightBarButtonItems = viewController.navigationItem.rightBarButtonItems;
25
+ }
26
+
27
+ @end
@@ -0,0 +1,8 @@
1
+ //
2
+ // MPViewController.h
3
+
4
+ #import <UIKit/UIKit.h>
5
+
6
+ @interface MPViewController : DTViewController
7
+
8
+ @end
@@ -0,0 +1,19 @@
1
+ //
2
+ // MPViewController.m
3
+
4
+ #import "MPViewController.h"
5
+
6
+ @interface MPViewController()
7
+
8
+ @end
9
+
10
+ @implementation MPViewController
11
+
12
+ - (void)viewDidLoad
13
+ {
14
+ [super viewDidLoad];
15
+
16
+ self.title = @"主页";
17
+ }
18
+
19
+ @end
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>Launcher</key>
6
+ <string>Launcher</string>
7
+ <key>Services</key>
8
+ <array/>
9
+ <key>Applications</key>
10
+ <array>
11
+ <dict>
12
+ <key>delegate</key>
13
+ <string>MPLauncherAppDelegate</string>
14
+ <key>description</key>
15
+ <string>Launcher</string>
16
+ <key>name</key>
17
+ <string>Launcher</string>
18
+ </dict>
19
+ </array>
20
+ <key>ServicesMap</key>
21
+ <dict>
22
+ <key>[AUTOSTART]</key>
23
+ <array/>
24
+ </dict>
25
+ </dict>
26
+ </plist>
@@ -0,0 +1,125 @@
1
+ def runWriteInfoList(arr, pods_path)
2
+ if arr.length > 18
3
+ project_path = arr[0]
4
+ target_name = arr[1]
5
+ productIdKey = arr[2]
6
+ productIdValue = arr[3]
7
+ productVersionKey = arr[4]
8
+ productVersionValue = arr[5]
9
+ mpaasProperties = arr[6]
10
+ workspaceIdKey = arr[7]
11
+ workspaceIdValue = arr[8]
12
+ appIdKey = arr[9]
13
+ appIdValue = arr[10]
14
+ mpaasGatewayKey = arr[11]
15
+ mpaasGatewayValue = arr[12]
16
+ platformKey = "Platform"
17
+ platformValue = "IOS"
18
+ bundleIdValue = arr[13]
19
+ mPaaSInternal = arr[14]
20
+ syncPortKey = arr[15]
21
+ syncPortValue = arr[16]
22
+ syncServerKey = arr[17]
23
+ syncServerValue = arr[18]
24
+ # workspaceIdKey = arr[6]
25
+ # workspaceIdValue = arr[7]
26
+ # appIdKey = arr[8]
27
+ # appIdValue = arr[9]
28
+
29
+ appTransportSecurityKey = "NSAppTransportSecurity"
30
+ appTransportSecurityValue = "NSAllowsArbitraryLoads"
31
+
32
+ xcproj = Xcodeproj::Project.open(project_path)
33
+ if xcproj == nil
34
+ LogTools.p_red "Cannot find open project '#{project_path}'."
35
+ exit 1
36
+ end
37
+
38
+ target = find_target(target_name, xcproj)
39
+ if target == nil
40
+ LogTools.p_red "Cannot find target '#{target_name}'."
41
+ exit 1
42
+ end
43
+
44
+ plist_files = Array[]
45
+ target.build_configuration_list.build_configurations.each do |config|
46
+ if !plist_files.include?(config.build_settings["INFOPLIST_FILE"])
47
+ plist_files << config.build_settings["INFOPLIST_FILE"]
48
+ end
49
+ end
50
+
51
+ plist_files.each do |f|
52
+ path = File::dirname(project_path) + "/#{f}"
53
+
54
+ # 默认不输出原始产生的日志
55
+ nolog = " 2> /dev/null"
56
+ if LogTools.verbose?
57
+ # 不屏蔽原始日志
58
+ nolog = ""
59
+ end
60
+
61
+ # 10.1.32适配 如果有埋点或者rpc不添加且删除
62
+ if mPaaS_lib_has_adapter?(pods_path, "APRemoteLogging") || mPaaS_lib_has_adapter?(pods_path, "APMobileNetwork")
63
+ system "/usr/libexec/PlistBuddy -c \"Delete :\'#{productIdKey}\'\" \"#{path}\"" + nolog
64
+ LogTools.v "Delete '#{productIdKey}' of value '#{productIdValue}' into '#{path}'."
65
+ else
66
+ # 注释历史逻辑,不兼容了
67
+ # system "/usr/libexec/PlistBuddy -c \"Add :\'#{productIdKey}\' string #{productIdValue}\" \"#{path}\"" + nolog
68
+ # LogTools.v "Write '#{productIdKey}' of value '#{productIdValue}' into '#{path}'."
69
+ end
70
+
71
+ system "/usr/libexec/PlistBuddy -c \"Add :\'#{productVersionKey}\' string #{productVersionValue}\" \"#{path}\"" + nolog
72
+ LogTools.v "Write '#{productVersionKey}' of value '#{productVersionValue}' into '#{path}'."
73
+ # system "/usr/libexec/PlistBuddy -c \"Add :\'#{workspaceIdKey}\' string #{workspaceIdValue}\" \"#{path}\""
74
+ # LogTools.v "Write '#{workspaceIdKey}' of value '#{workspaceIdValue}' into '#{path}'."
75
+ # system "/usr/libexec/PlistBuddy -c \"Add :\'#{appIdKey}\' string #{appIdValue}\" \"#{path}\""
76
+ # LogTools.v "Write '#{appIdKey}' of value '#{appIdValue}' into '#{path}'."
77
+
78
+ # 先添加key值
79
+ system "/usr/libexec/PlistBuddy -c 'Add :\'#{appTransportSecurityKey}\' dict' \"#{path}\"" + nolog
80
+ # 添加value值,
81
+ system "/usr/libexec/PlistBuddy -c 'Add :\'#{appTransportSecurityKey}\':\'#{appTransportSecurityValue}\' bool true' \"#{path}\"" + nolog
82
+
83
+ # 10.1.32适配 如果有rpc不添加且删除
84
+ if mPaaS_lib_has_adapter?(pods_path, "APMobileNetwork")
85
+ system "/usr/libexec/PlistBuddy -c \"Delete :\'#{mpaasProperties}\'\" \"#{path}\"" + nolog
86
+ LogTools.v "Delete '#{mpaasProperties}' into '#{path}'."
87
+ else
88
+ # 注释历史逻辑,不兼容了
89
+ # # 先添加key值:mpaas
90
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mpaasProperties}\' dict' \"#{path}\"" + nolog
91
+ # # 添加字典value:WorkspaceId和UniformGateway
92
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mpaasProperties}\':\'#{workspaceIdKey}\' string #{workspaceIdValue}' \"#{path}\"" + nolog
93
+ # LogTools.v "Write '#{workspaceIdKey}' of value '#{workspaceIdValue}' into '#{path}'."
94
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mpaasProperties}\':\'#{mpaasGatewayKey}\' string #{mpaasGatewayValue}' \"#{path}\"" + nolog
95
+ # LogTools.v "Write '#{mpaasGatewayKey}' of value '#{mpaasGatewayValue}' into '#{path}'."
96
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mpaasProperties}\':\'#{appIdKey}\' string #{appIdValue}' \"#{path}\"" + nolog
97
+ # LogTools.v "Write '#{appIdKey}' of value '#{appIdValue}' into '#{path}'."
98
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mpaasProperties}\':\'#{platformKey}\' string #{platformValue}' \"#{path}\"" + nolog
99
+ # LogTools.v "Write '#{platformKey}' of value '#{platformValue}' into '#{path}'."
100
+ end
101
+
102
+ # 10.1.32适配 如果有sync不添加且删除
103
+ if mPaaS_lib_has_adapter?(pods_path, "APLongLinkService")
104
+ system "/usr/libexec/PlistBuddy -c \"Delete :\'#{mPaaSInternal}\'\" \"#{path}\"" + nolog
105
+ LogTools.v "Delete '#{mPaaSInternal}' into '#{path}'."
106
+ else
107
+ # 注释历史逻辑,不兼容了
108
+ # # 先添加key值:mPaaSInternal
109
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mPaaSInternal}\' dict' \"#{path}\"" + nolog
110
+ # # 添加字典value:WorkspaceId和UniformGateway
111
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mPaaSInternal}\':\'#{syncPortKey}\' string #{syncPortValue}' \"#{path}\"" + nolog
112
+ # LogTools.v "Write '#{syncPortKey}' of value '#{syncPortValue}' into '#{path}'."
113
+ # system "/usr/libexec/PlistBuddy -c 'Add :\'#{mPaaSInternal}\':\'#{syncServerKey}\' string #{syncServerValue}' \"#{path}\"" + nolog
114
+ # LogTools.v "Write '#{syncServerKey}' of value '#{syncServerValue}' into '#{path}'."
115
+ end
116
+
117
+ #修改Bundle Id
118
+ system "/usr/libexec/PlistBuddy -c 'Set :CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER)' \"#{path}\"" + nolog
119
+ LogTools.v "Write Bundle Identifier of value $(PRODUCT_BUNDLE_IDENTIFIER) into '#{path}'."
120
+ end
121
+ end
122
+ end
123
+
124
+ # writeInfoListParameter = ARGV
125
+ # runWriteInfoList(writeInfoListParameter)
@@ -0,0 +1,334 @@
1
+ require "rubygems"
2
+ require "xcodeproj"
3
+ require "fileutils"
4
+ require "json"
5
+
6
+ def get_current_user()
7
+ author = `whoami`
8
+ if author[author.length - 1] == "\n"
9
+ author.chop!
10
+ end
11
+ return author
12
+ end
13
+
14
+ def find_target(name, xcproj)
15
+ xcproj.targets.each do |target|
16
+ if target.name == name
17
+ return target
18
+ end
19
+ end
20
+ return nil
21
+ end
22
+
23
+ def do_with_target(name, xcproj)
24
+ xcproj.targets.each do |target|
25
+ if target.name == name
26
+ yield(target)
27
+ break
28
+ end
29
+ end
30
+ end
31
+
32
+ def is_target_executable(name, xcproj)
33
+ target = find_target(name, xcproj)
34
+ if target != nil
35
+ target.build_configuration_list.build_configurations.each do |config|
36
+ mach_o = config.build_settings["MACH_O_TYPE"]
37
+ if mach_o == nil || mach_o == "mh_execute"
38
+ return true
39
+ end
40
+ break
41
+ end
42
+ end
43
+ return false
44
+ end
45
+
46
+ def add_script_build_phase(name, script, target_name, xcproj)
47
+ do_with_target(target_name, xcproj) { |target|
48
+ LogTools.p "Add '#{name}' to build phase of target '#{target}'."
49
+ phase = target.new_shell_script_build_phase(name)
50
+ phase.shell_script = script
51
+ phase.show_env_vars_in_log = "0"
52
+ target.build_phases.delete(phase)
53
+ target.build_phases.insert(0, phase)
54
+ }
55
+ end
56
+
57
+ def remove_script_build_phase(name, target_name, xcproj)
58
+ do_with_target(target_name, xcproj) { |target|
59
+ deleted = Array[]
60
+ target.build_phases.each do |phase|
61
+ if "#{phase}".downcase == name.downcase
62
+ deleted << phase
63
+ end
64
+ end
65
+
66
+ deleted.each do |phase|
67
+ LogTools.p "Remove '#{phase}' from build phase of target '#{target}'."
68
+ target.build_phases.delete(phase)
69
+ end
70
+ }
71
+ end
72
+
73
+ def add_framework_search_path(path, target_name, xcproj)
74
+ do_with_target(target_name, xcproj) { |target|
75
+ target.build_configuration_list.build_configurations.each do |config|
76
+ LogTools.p "Add '#{path}' to 'Framework Search Paths' build settings of target '#{target}'."
77
+ search_paths = config.build_settings["FRAMEWORK_SEARCH_PATHS"]
78
+ if search_paths == nil
79
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"] = Array[path]
80
+ elsif search_paths.is_a?(String)
81
+ if search_paths != path
82
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"] = Array[search_paths, path]
83
+ end
84
+ elsif !search_paths.include?(path)
85
+ search_paths << path
86
+ end
87
+ end
88
+ }
89
+ end
90
+
91
+ def remove_framework_search_path_general(path, target_name, xcproj)
92
+ do_with_target(target_name, xcproj) { |target|
93
+ target.build_configuration_list.build_configurations.each do |config|
94
+ search_paths = config.build_settings["FRAMEWORK_SEARCH_PATHS"]
95
+ if search_paths != nil
96
+ LogTools.p "Remove '#{path}' from 'Framework Search Paths' build settings of target '#{target}'."
97
+ if search_paths.is_a?(String)
98
+ if search_paths.include?(path)
99
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"] = Array[]
100
+ end
101
+ else
102
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"].delete_if { |item|
103
+ item.include? path
104
+ }
105
+ # config.build_settings['FRAMEWORK_SEARCH_PATHS'].delete(path)
106
+ # config.build_settings['FRAMEWORK_SEARCH_PATHS'].delete("#{path}/**")
107
+ end
108
+ end
109
+ end
110
+ }
111
+ end
112
+
113
+ def remove_framework_search_path(path, target_name, xcproj)
114
+ do_with_target(target_name, xcproj) { |target|
115
+ target.build_configuration_list.build_configurations.each do |config|
116
+ search_paths = config.build_settings["FRAMEWORK_SEARCH_PATHS"]
117
+ if search_paths != nil
118
+ LogTools.p "Remove '#{path}' from 'Framework Search Paths' build settings of target '#{target}'."
119
+ if search_paths.is_a?(String)
120
+ if search_paths.include?(path)
121
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"] = Array[]
122
+ end
123
+ else
124
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"].delete(path)
125
+ config.build_settings["FRAMEWORK_SEARCH_PATHS"].delete("#{path}/**")
126
+ end
127
+ end
128
+ end
129
+ }
130
+ end
131
+
132
+ def add_framework_ref(parent_ref, path, xcproj, absolute_path)
133
+ ref = parent_ref.new_reference(path)
134
+ ref.set_source_tree("<group>")
135
+ if absolute_path
136
+ # ref添加后会自动使用相对路径,但我们不希望这样
137
+ ref.path = path
138
+ end
139
+ return ref
140
+ end
141
+
142
+ def add_framework_to_build_phase(ref, target_name, xcproj)
143
+ do_with_target(target_name, xcproj) { |target|
144
+ target.build_phases.each do |phase|
145
+ if "#{phase}".include? "FrameworksBuild"
146
+ LogTools.p "Add '#{File::basename(ref.path)}' to 'Link Binary With Libraries' build phase of target '#{target}'."
147
+ phase.add_file_reference(ref, true)
148
+ break
149
+ end
150
+ end
151
+ }
152
+ end
153
+
154
+ def remove_framework(name, target_name, xcproj)
155
+ do_with_target(target_name, xcproj) { |target|
156
+ target.build_phases.each do |phase|
157
+ if "#{phase}".include? "FrameworksBuild"
158
+ refs = phase.files_references
159
+ refs.each do |r|
160
+ if r.name == name || (File::basename(r.path) == name)
161
+ LogTools.p "Remove '#{name}' from 'Link Binary With Libraries' build phase of target '#{target}'."
162
+ phase.remove_file_reference(r)
163
+ end
164
+ end
165
+ break
166
+ end
167
+ end
168
+ }
169
+ end
170
+
171
+ def add_non_source_file(parent_ref, path, xcproj)
172
+ LogTools.v "Add file '#{File::basename(path)}' to project. path: #{path}"
173
+ LogTools.v "Add file 1'#{parent_ref} , #{parent_ref.class}' to project. path: #{path}"
174
+
175
+ return parent_ref.new_reference(path)
176
+ end
177
+
178
+ def add_source_file(parent_ref, path, target_name, xcproj)
179
+ LogTools.v "Add source file '#{File::basename(path)}' to project."
180
+ ref = parent_ref.new_reference(path)
181
+ do_with_target(target_name, xcproj) { |target|
182
+ target.build_phases.each do |phase|
183
+ if "#{phase}".include? "SourcesBuild"
184
+ LogTools.p "Add '#{File::basename(path)}' to 'Compile Sources' build phase of target '#{target}'."
185
+ phase.add_file_reference(ref, true)
186
+ break
187
+ end
188
+ end
189
+ }
190
+ return ref
191
+ end
192
+
193
+ def remove_from_project(ref)
194
+ LogTools.p "remove_from_project #{ref}"
195
+ return ref.remove_from_project
196
+ end
197
+
198
+ def delete_source_file(parent_ref, path, target_name, xcproj)
199
+ LogTools.p "Delete source file '#{File::basename(path)}' to project."
200
+ ref = parent_ref.new_reference(path)
201
+ do_with_target(target_name, xcproj) { |target|
202
+ target.build_phases.each do |phase|
203
+ if "#{phase}".include? "SourcesBuild"
204
+ LogTools.p "Delete '#{File::basename(path)}' to 'Compile Sources' build phase of target '#{target}'."
205
+ phase.remove_file_reference(ref)
206
+ break
207
+ end
208
+ end
209
+ }
210
+ return ref
211
+ end
212
+
213
+ def add_resource_ref(parent_ref, path, xcproj)
214
+ ref = nil
215
+ if File::directory?(path)
216
+ basename = File::basename(path)
217
+ if basename =~ /\w+\.bundle/
218
+ LogTools.p "Add '#{basename}' to project."
219
+ ref = parent_ref.new_bundle(File::basename(path, ".bundle"))
220
+ ref.set_source_tree("<group>")
221
+ end
222
+ else
223
+ ref = add_non_source_file(parent_ref, File::basename(path), xcproj)
224
+ end
225
+ return ref
226
+ end
227
+
228
+ def add_resource_to_build_phase(ref, target_name, xcproj)
229
+ do_with_target(target_name, xcproj) { |target|
230
+ target.build_phases.each do |phase|
231
+ if "#{phase}".include? "ResourcesBuild"
232
+ LogTools.p "Add '#{File::basename(ref.path)}' to 'Copy Bundle Resources' build phase of target '#{target}'."
233
+ phase.add_file_reference(ref, true)
234
+ break
235
+ end
236
+ end
237
+ }
238
+ end
239
+
240
+ def remove_resource(name, target_name, xcproj)
241
+ do_with_target(target_name, xcproj) { |target|
242
+ target.build_phases.each do |phase|
243
+ if "#{phase}".include? "ResourcesBuild"
244
+ refs = phase.files_references
245
+ refs.each do |r|
246
+ if r && r.path != nil
247
+ # LogTools.p_red r.path
248
+ basename = File::basename(r.path)
249
+ if basename == name
250
+ LogTools.p "Remove '#{name}' from 'Copy Bundle Resources' build phase of target '#{target}'."
251
+ phase.remove_file_reference(r)
252
+ end
253
+ end
254
+ end
255
+ break
256
+ end
257
+ end
258
+ }
259
+ end
260
+
261
+ def find_pch_file(target_name, xcproj)
262
+ result = Array[]
263
+ do_with_target(target_name, xcproj) { |target|
264
+ target.build_configuration_list.build_configurations.each do |config|
265
+ pch = config.build_settings["GCC_PREFIX_HEADER"]
266
+ if pch != nil and pch != ""
267
+ if !result.include?(pch)
268
+ result << pch
269
+ end
270
+ end
271
+ end
272
+ }
273
+ return result
274
+ end
275
+
276
+ def add_pch_file(project_directory, target_name, xcproj, pch_array)
277
+ # pch文件与Info.plist放到同一个目录
278
+ do_with_target(target_name, xcproj) { |target|
279
+ target.build_configuration_list.build_configurations.each do |config|
280
+ info_plist_path = config.build_settings["INFOPLIST_FILE"]
281
+ if info_plist_path == nil
282
+ next
283
+ else
284
+ pch_file_path = "#{File::dirname(info_plist_path)}/#{target_name}-Prefix.pch"
285
+ config.build_settings["GCC_PRECOMPILE_PREFIX_HEADER"] = "YES"
286
+ config.build_settings["GCC_PREFIX_HEADER"] = pch_file_path
287
+ if File::exist?("#{project_directory}/#{pch_file_path}")
288
+ next
289
+ end
290
+
291
+ author = get_current_user
292
+ time_str = Time.new.strftime("%Y/%m/%d")
293
+ pch_file = File.new("#{project_directory}/#{pch_file_path}", "w")
294
+ pch_file.puts "//"
295
+ pch_file.puts "// #{target_name}-Prefix.pch"
296
+ pch_file.puts "// #{target_name}"
297
+ pch_file.puts "//"
298
+ pch_file.puts "// Created by #{author} on #{time_str}."
299
+ pch_file.puts ""
300
+ pch_file.close
301
+
302
+ if !pch_array.include?(pch_file_path)
303
+ pch_array << pch_file_path
304
+ end
305
+ end
306
+ end
307
+ }
308
+ end
309
+
310
+ def check_other_link_flags(target_name, xcproj)
311
+ do_with_target(target_name, xcproj) { |target|
312
+ def_flags = Array["-ObjC", "-lz", "-lsqlite3", "-lxml2", "-lc++", "-lbz2"]
313
+
314
+ target.build_configuration_list.build_configurations.each do |config|
315
+ flags = config.build_settings["OTHER_LDFLAGS"]
316
+ if flags == nil
317
+ flags = def_flags
318
+ else
319
+ if flags.is_a?(String) # 有可能是string
320
+ flags = Array[flags]
321
+ end
322
+
323
+ flags.each do |f|
324
+ def_flags.delete(f) # 已经有的删除
325
+ end
326
+ def_flags.each do |f|
327
+ flags << f
328
+ end
329
+ end
330
+ LogTools.p "Modify 'Other Linker Flags' of target '#{target}'."
331
+ config.build_settings["OTHER_LDFLAGS"] = flags
332
+ end
333
+ }
334
+ end
@@ -0,0 +1,41 @@
1
+ require "cocoapods-mPaaS/gem_version"
2
+ require 'singleton'
3
+ require 'cocoapods-mPaaS/localization'
4
+ module CocoapodsmPaaS
5
+ MPAAS_LOCAL_PATH = "/Users/Shared/.mPaaSCocoaPodsPlugin"
6
+ MPAAS_TEMPLATES_PATH = File.expand_path("cocoapods-mPaaS/templates", __dir__)
7
+ MPAAS_IOS_PATH_PREFIX = "https://mpaas-ios.oss-cn-hangzhou.aliyuncs.com"
8
+ MPAAS_IOS_TEST_PATH_PREFIX = "https://mpaas-ios-test.oss-cn-hangzhou.aliyuncs.com"
9
+ MPAAS_REPO_URL = "https://gitee.com/mpaas/podspecs.git"
10
+ MPAAS_REPO_NAME = "gitee-mpaas-podspecs"
11
+ REPORT_LOG = false
12
+ MPAAS_IOS_ANT_GUARD_URL = "https://pre-mappcenter.mpaas.cn-hangzhou.aliyuncs.com/webapi/mpaas/mobileapp/component/conf/downloadConf"
13
+
14
+ MPAAS_REPO_URL_DEV = "git@code.alipay.com:mpaas_group/Specs_DEV.git"
15
+ MPAAS_REPO_URL_DEV_HTTP = "https://code.alipay.com/mpaas_group/Specs_DEV.git"
16
+
17
+ MPAAS_REPO_NAME_DEV = "alipay-mpaas_group-specs_dev"
18
+ MPAAS_IOS_TEST_PATH_PREFIX_DEV = "https://antsys-publish-platform-temp.cn-heyuan-alipay-office.oss-alipay.aliyuncs.com"
19
+ end
20
+
21
+
22
+ class MPaaSCocoapodShare
23
+ include Singleton
24
+
25
+ attr_accessor :usedMpaasTarget
26
+ attr_accessor :unuseMpaasTarget
27
+ #存储不自动添加 header 引用的 target (一处所有的 target 都会移除)
28
+ attr_accessor :igenore_headers
29
+ #针对 target 忽略
30
+ attr_accessor :targetmap_igenore_headers
31
+
32
+
33
+ def initialize
34
+ @usedMpaasTarget = Set.new
35
+ @unuseMpaasTarget = Set.new
36
+ @igenore_headers = Set.new
37
+ @targetmap_igenore_headers = Hash.new { |h, k| h[k] = Set.new }
38
+ end
39
+ end
40
+
41
+ Pod::MPAAS::Localization.set_language(Pod::MPAAS::Localization.current_language)
@@ -0,0 +1,15 @@
1
+ require "cocoapods-mPaaS"
2
+ require "cocoapods-mPaaS/logTools"
3
+ require "cocoapods-mPaaS/xcode_helper"
4
+ require "cocoapods-mPaaS/installNew"
5
+ require "cocoapods-mPaaS/cocoapods_hook"
6
+ require "cocoapods-mPaaS/dsl"
7
+
8
+ require "cocoapods-mPaaS/command/mPaaS"
9
+ require "cocoapods-mPaaS/command/mpaas/init"
10
+ require "cocoapods-mPaaS/command/mpaas/update"
11
+ require "cocoapods-mPaaS/command/mpaas/open"
12
+ require "cocoapods-mPaaS/command/mpaas/info"
13
+ require "cocoapods-mPaaS/command/mpaas/dev"
14
+ require "cocoapods-mPaaS/command/mpaas/version"
15
+ require 'cocoapods-mPaaS/command/mpaas/local_command'