cocoapods-devtool 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e85c5624b1fa9744bb08e3eb64a68a3084d64b4ad6b4abe594812fd443dfaff1
4
- data.tar.gz: c8d41e59bdd7b1caab5e8c71145e902226318f2d7a7e6325592044a891b088ce
3
+ metadata.gz: 78f4003d754e89615f27cc8ad44bf00b2aae4e436d0d7ed8020945a08975346d
4
+ data.tar.gz: 5561bdca5db0de1892eae3d3d787969378d9ad824ffeea0ecde2f553329c7789
5
5
  SHA512:
6
- metadata.gz: 1787a8892f1b66c397d08266cb56968874e9770d5b2b6f15ad65fc0b52418a652c43b02350332dc597e0dd954aa1a528aec7e94f8fbdaa09c2fdb52aa83de141
7
- data.tar.gz: 474962053ef2ae7df6e32c30d94cafa30f9fe33a05c3f7e3c3e6391c62fb77f06f713ddada7c72eae6137ff59f154eb8a8348274c9ab28ce65b92d5358addee4
6
+ metadata.gz: 9f63b52d8d784302dbdec9b850fd4c0a73d0ee73d906f0e045bd4ce00d439973803b8f717321cc06a0a413918a8ebe7ade6ea244754315958224393a850978b3
7
+ data.tar.gz: bbcb978681a53ff9de9c17153dffdb25de5c57306b4ac88ccc3ae381d3d3545486059b1fdbe3542a88844a3624d6c13c211c5955d71b2d5bb00234f931a2a955
@@ -0,0 +1,141 @@
1
+
2
+
3
+ require 'rubygems'
4
+ require 'xcodeproj'
5
+ require_relative '../setting/user_setting_tool'
6
+ require_relative '../setting/project_setting_tool'
7
+
8
+ module Pod
9
+ class Command
10
+ class Sign < DevCommand
11
+ self.summary = '修改签名'
12
+ self.description = <<-DESC
13
+ 1. 用于修改项目签名,团队等配置的工具
14
+ DESC
15
+
16
+ @ori_value_not_exit = "ori_value_not_exit"
17
+
18
+ def initialize(argv)
19
+ @change = argv.flag?("change",false)
20
+ super
21
+ end
22
+
23
+ def validate!
24
+ super
25
+ settingTool = UserSetting::Setting.new()
26
+ help! "请先用pod devtool setting设置change_bundle_pre和dev_team" if settingTool.dev_team.empty? || settingTool.change_bundle_pre.empty?
27
+ end
28
+
29
+ def run
30
+ self.change_project
31
+ end
32
+
33
+ private
34
+
35
+ def change_project
36
+ settingTool = UserSetting::Setting.new()
37
+ settingTool.readSettingData()
38
+
39
+ curdir = Dir.pwd()
40
+
41
+ projectPaths = Dir[curdir+"/**/*.{xcodeproj}"]
42
+ podProjectPath = ""
43
+
44
+ projectPaths.delete(podProjectPath) unless podProjectPath.nil?
45
+ unless projectPaths.size > 0
46
+ puts "没有工程需要修改"
47
+ else
48
+ if @change
49
+ puts "开始修改以下项目签名"
50
+ else
51
+ puts "开始恢复以下项目签名"
52
+ end
53
+ projectPaths.each do |path|
54
+ if File.exist?(path)
55
+ puts path
56
+ project = Xcodeproj::Project.open(path)
57
+ if @change
58
+ self.change_setting(project,path)
59
+ else
60
+ self.un_change_setting(project,path)
61
+ end
62
+ end
63
+ end
64
+ puts "完成修改项目签名"
65
+ end
66
+
67
+ end
68
+
69
+ def set_config(project_setting,path,target,config,key,value)
70
+ ori_value = config.build_settings[key]
71
+ ori_value = "ori_value_not_exit" if ori_value.nil?
72
+ project_setting.set_project_setting(path,target.display_name,config.display_name,key,ori_value)
73
+ config.build_settings[key] = value
74
+
75
+ end
76
+
77
+ def change_setting(project,path)
78
+ settingTool = UserSetting::Setting.new()
79
+ project_ori_setting = UserSetting::ProjectSetting.new();
80
+ project.targets.each do |target|
81
+ target.build_configurations.each do |config|
82
+ has_bundle_id = !config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'].nil?
83
+
84
+ if has_bundle_id
85
+ value = config.build_settings['PRODUCT_BUNDLE_IDENTIFIER']
86
+ has_bundle_id_pre = value.start_with?(settingTool.change_bundle_pre)
87
+ if !has_bundle_id_pre
88
+ set_config(project_ori_setting,path,target,config,"CODE_SIGN_ENTITLEMENTS","")
89
+ set_config(project_ori_setting,path,target,config,"DEVELOPMENT_TEAM",settingTool.dev_team)
90
+ set_config(project_ori_setting,path,target,config ,"DEVELOPMENT_TEAM[sdk=iphoneos*]",settingTool.dev_team)
91
+ set_config(project_ori_setting,path,target,config ,"PRODUCT_BUNDLE_IDENTIFIER",settingTool.change_bundle_pre + "." + config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'])
92
+ set_config(project_ori_setting,path,target,config ,"CODE_SIGN_STYLE","Automatic")
93
+ set_config(project_ori_setting,path,target,config ,"PROVISIONING_PROFILE","")
94
+ set_config(project_ori_setting,path,target,config ,"PROVISIONING_PROFILE_SPECIFIER","")
95
+ set_config(project_ori_setting,path,target,config ,"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]","")
96
+ set_config(project_ori_setting,path,target,config ,"CODE_SIGN_IDENTITY","Apple Development")
97
+ set_config(project_ori_setting,path,target,config ,"CODE_SIGN_IDENTITY[sdk=iphoneos*]","Apple Development")
98
+ set_config(project_ori_setting,path,target,config ,"ProvisioningStyle","Automatic")
99
+ end
100
+
101
+ end
102
+ end
103
+ end
104
+ project_ori_setting.save
105
+ project.save
106
+ end
107
+
108
+ def un_change_setting(project,path)
109
+ project_ori_setting = UserSetting::ProjectSetting.new();
110
+ project.targets.each do |target|
111
+ target.build_configurations.each do |config|
112
+
113
+ array = ["CODE_SIGN_ENTITLEMENTS","DEVELOPMENT_TEAM","DEVELOPMENT_TEAM[sdk=iphoneos*]","PRODUCT_BUNDLE_IDENTIFIER","CODE_SIGN_STYLE","PROVISIONING_PROFILE",
114
+ "PROVISIONING_PROFILE_SPECIFIER","PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]","CODE_SIGN_IDENTITY","CODE_SIGN_IDENTITY[sdk=iphoneos*]","ProvisioningStyle",]
115
+ array.each do |key|
116
+ next unless project_ori_setting.has_project_setting(path,target.display_name,config.display_name,key)
117
+ ori_value = project_ori_setting.get_project_setting(path,target.display_name,config.display_name,key)
118
+ if ori_value.nil?
119
+ config.build_settings.delete(key)
120
+ elsif ori_value == "ori_value_not_exit"
121
+ config.build_settings.delete(key)
122
+ project_ori_setting.set_project_setting(path,target.display_name,config.display_name,key,nil )
123
+ else
124
+ config.build_settings[key] = ori_value
125
+ project_ori_setting.set_project_setting(path,target.display_name,config.display_name,key,nil )
126
+ end
127
+
128
+ end
129
+
130
+ end
131
+ end
132
+ project_ori_setting.save
133
+ project.save
134
+ end
135
+
136
+
137
+
138
+
139
+ end
140
+ end
141
+ end
@@ -1,3 +1,3 @@
1
1
  require 'cocoapods-devtool/command/devtool'
2
2
  require 'cocoapods-devtool/command/setting'
3
- require 'cocoapods-devtool/command/change'
3
+ require 'cocoapods-devtool/command/sign'
@@ -1,3 +1,3 @@
1
1
  module CocoapodsDevtool
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,39 @@
1
+ require 'json'
2
+ module UserSetting
3
+ class ProjectSetting
4
+
5
+ def initialize
6
+ @jsonPath = '../../../setting/project_setting.json'
7
+ path = File.expand_path(@jsonPath, __FILE__)
8
+ data = File.open(path) do |f|
9
+ JSON.load(f)
10
+ end
11
+ @settingData = data
12
+ @settingData = {} if data.nil?
13
+ end
14
+
15
+ def has_project_setting(path,target,config,key)
16
+ real_key = "#{path}_#{target}_#{config}_#{key}"
17
+ return @settingData.has_key?(real_key)
18
+ end
19
+
20
+ def get_project_setting(path,target,config,key)
21
+ real_key = "#{path}_#{target}_#{config}_#{key}"
22
+ return @settingData[real_key]
23
+ end
24
+
25
+ def set_project_setting(path, target,config,key, value)
26
+ real_key = "#{path}_#{target}_#{config}_#{key}"
27
+ if value.nil?
28
+ @settingData.delete(real_key)
29
+ else
30
+ @settingData[real_key] = value
31
+ end
32
+ end
33
+ def save
34
+ path = File.expand_path(@jsonPath, __FILE__)
35
+ json = JSON.generate(@settingData)
36
+ File.write(path,json)
37
+ end
38
+ end
39
+ end
@@ -4,7 +4,7 @@ module UserSetting
4
4
  attr_accessor :change_bundle_pre, :dev_team, :modes
5
5
 
6
6
  def initialize
7
- @jsonPath = '../../../user_setting.json'
7
+ @jsonPath = '../../../setting/user_setting.json'
8
8
  path = File.expand_path(@jsonPath, __FILE__)
9
9
  data = File.open(path) do |f|
10
10
  JSON.load(f)
@@ -24,6 +24,7 @@ module UserSetting
24
24
  end
25
25
 
26
26
  def save()
27
+ return if @settingData.nil?
27
28
  path = File.expand_path(@jsonPath, __FILE__)
28
29
  json = JSON.generate(@settingData)
29
30
  File.write(path,json)
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {"change_bundle_pre":"","dev_team":"","modes":["Debug","Release","Distubution"]}
@@ -1 +1 @@
1
- {"change_bundle_pre":"3","dev_team":"33","modes":["Debug","Release","Distubution"]}
1
+ {"change_bundle_pre":"dsf","dev_team":"YS6XZ45737","modes":["Debug","Release","Distubution"]}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-devtool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-30 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -47,12 +47,15 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - lib/cocoapods-devtool.rb
49
49
  - lib/cocoapods-devtool/command.rb
50
- - lib/cocoapods-devtool/command/change.rb
51
50
  - lib/cocoapods-devtool/command/devtool.rb
52
51
  - lib/cocoapods-devtool/command/setting.rb
52
+ - lib/cocoapods-devtool/command/sign.rb
53
53
  - lib/cocoapods-devtool/gem_version.rb
54
+ - lib/cocoapods-devtool/setting/project_setting_tool.rb
54
55
  - lib/cocoapods-devtool/setting/user_setting_tool.rb
55
56
  - lib/cocoapods_plugin.rb
57
+ - lib/setting/project_setting.json
58
+ - lib/setting/user_setting.json
56
59
  - lib/user_setting.json
57
60
  homepage: https://github.com/samstring/cocoapods-devtool
58
61
  licenses:
@@ -1,80 +0,0 @@
1
-
2
-
3
- require 'rubygems'
4
- require 'xcodeproj'
5
- require_relative '../setting/user_setting_tool'
6
-
7
- module Pod
8
- class Command
9
- class Change < DevCommand
10
- self.summary = '修改签名'
11
- self.description = <<-DESC
12
- 1. 将目录下所有的工程改成setting
13
- DESC
14
-
15
- def initialize(argv)
16
- super
17
- end
18
-
19
- def validate!
20
- super
21
- settingTool = UserSetting::Setting.new()
22
- help! "请先用pod devtool setting设置change_bundle_pre和dev_team" if settingTool.dev_team.empty? || settingTool.change_bundle_pre.empty?
23
- end
24
-
25
- def run
26
- self.change_project
27
- end
28
-
29
- private
30
-
31
- def change_project
32
- settingTool = UserSetting::Setting.new()
33
- settingTool.readSettingData()
34
-
35
- curdir = Dir.pwd()
36
-
37
- projectPaths = Dir[curdir+"/**/*.{xcodeproj}"]
38
- podProjectPath = ""
39
-
40
- projectPaths.delete(podProjectPath) unless podProjectPath.nil?
41
- unless projectPaths.size > 0
42
- puts "没有工程需要修改"
43
- else
44
- puts "开始修改以下项目签名"
45
- projectPaths.each do |path|
46
- if File.exist?(path)
47
- puts path
48
- project = Xcodeproj::Project.open(path)
49
- self.change_setting(project)
50
- end
51
- end
52
- puts "完成修改项目签名"
53
- end
54
-
55
- end
56
-
57
- def change_setting(project)
58
- settingTool = UserSetting::Setting.new()
59
- project.targets.each do |target|
60
- target.build_configurations.each do |config|
61
- config.build_settings['CODE_SIGN_ENTITLEMENTS'] = ""
62
- config.build_settings['DEVELOPMENT_TEAM'] = settingTool.dev_team
63
- config.build_settings['DEVELOPMENT_TEAM[sdk=iphoneos*]'] = settingTool.dev_team
64
- config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = settingTool.change_bundle_pre + "."+ config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] unless config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] .nil?
65
- config.build_settings['CODE_SIGN_STYLE'] = "Automatic"
66
- config.build_settings['PROVISIONING_PROFILE'] = ""
67
- config.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = ""
68
- config.build_settings['PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]'] = ""
69
- config.build_settings['CODE_SIGN_IDENTITY'] = "Apple Development"
70
- config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = "Apple Development"
71
- config.build_settings['ProvisioningStyle'] = "Automatic"
72
- end
73
- end
74
- project.save
75
- end
76
-
77
-
78
- end
79
- end
80
- end