wsauto 0.4

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 (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/wsauto +142 -0
  3. data/lib/wsauto.rb +2 -0
  4. metadata +60 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b7e4dd11eb08b154e3ee96ea7755fe226d54931c
4
+ data.tar.gz: aecb49823551da28d694d40586e51d6bb109f1d2
5
+ SHA512:
6
+ metadata.gz: 96d19f8362dfef98563bc688164985e7f53ff1a87aec9b2c76036ba5fc6d84360503d870d0d6e100001a4c2733a2887ff359b5ef5943f97a50a3ed68baafc354
7
+ data.tar.gz: 034cfe5ba6839470a9b13d52f900513504825d5cf142aff96f36bc71e525c93f66e775c12b89c61144ac2bd738e25bd5786bfdd5e4dda0fc9855278277040ce0
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'xcodeproj'
4
+
5
+ def printHelp()
6
+ puts "【功能】\n 自动将Xcode项目配置成自动签名模式,方便设备调试。"
7
+ puts "\n【使用方式】\n wsauto [项目根目录] [新BundelID] [DevelopmentTeam]"
8
+ puts "\n【如何获取 DevelopmentTeam?】\n 使用Xcode打开任意一个项目,勾选 Automatically manage signing,接着选择一个Team, 然后在 BuildSetting 选中 DevelopmentTeam 为你自己账号的那一行,ctrl+c将配置拷贝出来,从拷贝出来的字符串中可以看到 DevelopmentTeam 具体的值,将 DevelopmentTeam 记录下来,以后便可以直接使用了。"
9
+ puts ""
10
+ end
11
+
12
+ def redPrint(msg)
13
+ puts "\033[31m#{msg}\033[0m"
14
+ end
15
+
16
+ def greenPrint(msg)
17
+ puts "\033[32m#{msg}\033[0m"
18
+ end
19
+
20
+ if ARGV.count != 3
21
+ printHelp()
22
+ exit 1
23
+ end
24
+
25
+ uPrjDir = ARGV[0]
26
+ uNewBundelID = ARGV[1]
27
+ uDevelopmentTeam = ARGV[2]
28
+
29
+ projectPath = "#{uPrjDir}/microvision.xcodeproj"
30
+ entitlementsPath = "#{uPrjDir}/microvision-Debug.entitlements"
31
+ mainAppTargetName = "microvision"
32
+ toDelTargetNames = Array["notificationservice.appex","notificationcontent.appex","today.appex"]
33
+
34
+ if !FileTest::exist?(uPrjDir)
35
+ redPrint "项目文件: #{projectPath} 不存在"
36
+ exit 1
37
+ end
38
+
39
+ if !FileTest::exist?(entitlementsPath)
40
+ redPrint "entitlements文件: #{projectPath} 不存在"
41
+ exit 1
42
+ end
43
+
44
+ # ---- main logic ----
45
+ project = Xcodeproj::Project.open(projectPath)
46
+ if project == nil
47
+ redPrint "项目文件解析失败"
48
+ exit 1
49
+ end
50
+ toDelTargetNamesWithOutSuffix = toDelTargetNames.map{|item| item.gsub(/\..*/, "")}
51
+ mainTarget = nil
52
+ project.targets.each do |target|
53
+ if target.name == mainAppTargetName
54
+ mainTarget = target
55
+ break
56
+ end
57
+ end
58
+ if mainTarget == nil
59
+ redPrint "获取主target失败"
60
+ exit 1
61
+ end
62
+
63
+ puts ">> 删除 BuildSetting -> Dependencies"
64
+ toDelDeps = Array.new
65
+ for dependency in mainTarget.dependencies
66
+ if dependency.target != nil && toDelTargetNamesWithOutSuffix.include?(dependency.target.name)
67
+ toDelDeps << dependency
68
+ end
69
+ end
70
+ for dep in toDelDeps
71
+ greenPrint " 删除 #{dep.target.name}"
72
+ dep.remove_from_project()
73
+ end
74
+
75
+
76
+ puts ">> 删除 BuildSetting -> Embed App Extensions"
77
+ toDelCopyFiles = Array.new
78
+ for copyFilesBuildPhase in mainTarget.copy_files_build_phases
79
+ for copyFile in copyFilesBuildPhase.files
80
+ if toDelTargetNames.include?(copyFile.file_ref.path)
81
+ toDelCopyFiles << copyFile
82
+ end
83
+ end
84
+ end
85
+ for copyFile in toDelCopyFiles
86
+ greenPrint " 删除 #{copyFile.file_ref.path}"
87
+ copyFile.remove_from_project()
88
+ end
89
+
90
+
91
+ toDelTargets = Array.new
92
+ puts ">> 删除 TARGETS 列表"
93
+ for target in project.targets
94
+ if toDelTargetNamesWithOutSuffix.include?(target.name)
95
+ toDelTargets << target
96
+ end
97
+ end
98
+ for target in toDelTargets
99
+ greenPrint " 删除 #{target.name}"
100
+ target.remove_from_project()
101
+ end
102
+
103
+
104
+
105
+ puts ">> 修改bundleID -> #{uNewBundelID}"
106
+ mainTarget.build_settings("Debug")["PRODUCT_BUNDLE_IDENTIFIER"] = uNewBundelID
107
+ greenPrint " 修改 Debug BuidlSettings->PRODUCT_BUNDLE_IDENTIFIER"
108
+
109
+ puts ">> 开启 AutoSign"
110
+ mainTarget.build_settings("Debug")["CODE_SIGN_STYLE"] = "Automatic"
111
+ greenPrint " 修改 Debug BuidlSettings -> CODE_SIGN_STYLE value to 'Automatic'"
112
+ mainTarget.build_settings("Debug")["CODE_SIGN_IDENTITY"] = "Apple Development"
113
+ mainTarget.build_settings("Debug")["CODE_SIGN_IDENTITY[sdk=iphoneos*]"] = "Apple Development"
114
+ greenPrint " 修改 Debug BuidlSettings -> CODE_SIGN_IDENTITY value to 'Apple Development'"
115
+ mainTarget.build_settings("Debug")["DEVELOPMENT_TEAM"] = uDevelopmentTeam
116
+ greenPrint " 修改 Debug BuidlSettings -> DEVELOPMENT_TEAM value to 'uDevelopmentTeam'"
117
+ mainTarget.build_settings("Debug")["PROVISIONING_PROFILE_SPECIFIER"] = ""
118
+ greenPrint " 修改 Debug BuidlSettings -> PROVISIONING_PROFILE_SPECIFIER value to empty"
119
+
120
+
121
+ puts ">> 删除 Capabilities"
122
+ emptyEntitlements = '
123
+ <?xml version="1.0" encoding="UTF-8"?>
124
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
125
+ <plist version="1.0">
126
+ <dict/>
127
+ </plist>
128
+ '
129
+ File.open(entitlementsPath,"w") do |f|
130
+ f.puts emptyEntitlements
131
+ end
132
+ greenPrint " 清空 microvision-Debug.entitlements 文件"
133
+
134
+ for buildFile in mainTarget.frameworks_build_phase.files
135
+ if buildFile.file_ref.path.match(/.*StoreKit.framework$/)
136
+ buildFile.remove_from_project()
137
+ greenPrint " 删除 Link Binary 中的 'StoreKit.framework' (为了移除 In-App Purchase Capabilities)"
138
+ break
139
+ end
140
+ end
141
+
142
+ project.save(projectPath)
@@ -0,0 +1,2 @@
1
+ class wsauto
2
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wsauto
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.4'
5
+ platform: ruby
6
+ authors:
7
+ - jerry
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcodeproj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: wsauto
28
+ email: cjsliuj@163.com
29
+ executables:
30
+ - wsauto
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/wsauto
35
+ - lib/wsauto.rb
36
+ homepage: https://rubygems.org/gems/wsauto
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.5.2.3
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: wsauto
60
+ test_files: []