-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupHelper.sh
More file actions
executable file
·155 lines (121 loc) · 3.9 KB
/
setupHelper.sh
File metadata and controls
executable file
·155 lines (121 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#! /bin/bash
SRC_HOME=`pwd`
#外部传入参数
paramterFromOut=$1
#镜像代码片段
function codeSnippetFun(){
sniPath='Library/Developer/Xcode/UserData/CodeSnippets'
cd ~
curSniFullPath=$(pwd)/$sniPath
if [ ! -x "$curSniFullPath" ];then
mkdir -p $curSniFullPath
fi
cd $SRC_HOME
#强行镜像
ln -sf $curSniFullPath ${SRC_HOME}/CodeSnippets
}
#镜像代码模板
function codeTemplateFun(){
#改IFS 为 \n ,要不无法创建带空格的目录名哦
IFS=$'\n'
templatePath='Library/Developer/Xcode/Templates/File Templates/QYFileTemplate'
cd ~
curTemplatePath=$(pwd)/$templatePath
if [ ! -x "$curTemplatePath" ];then
mkdir -p $curTemplatePath
fi
#切到项目目录
cd $SRC_HOME
#强行镜像
ln -sf ${SRC_HOME}/QYFileTemplate $curTemplatePath
}
#安装依赖工具包
function install_Depend(){
#是否安装Homebrew
which -s brew
if [[ $? != 0 ]] ; then
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit
fi
brew install clang-format #|| exit
brew install uncrustify #|| exit
# xctool 在 xcode8 下暂不可用,等待官方解决
# brew install xctool || exit
cfFileName='.clang-format'
ufFileName='.uncrustify.cfg'
#cfg path
cd ~
cfFilePath=$(pwd)/$cfFileName
ufFilePath=$(pwd)/$ufFileName
#copy
cd $SRC_HOME
cp ${SRC_HOME}/Formate_cfg/$cfFileName $cfFilePath
cp ${SRC_HOME}/Formate_cfg/$ufFileName $ufFilePath
}
#updatePlist
function updatePlist(){
cd $SRC_HOME
#plist name
plist="QYXcodePlugIn-Info.plist"
#finde plist file path
for plistPath in `find ${SRC_HOME} -name "$plist" -print`
do
plist=${plistPath}
break
done
#读取
plugInGitPath=`/usr/libexec/PlistBuddy -c "Print :QYXcodePlugInGitPath" "$plist"`
#是否存在
if [ -z "$plugInGitPath" ];
then
#不存在
plugInGitPath=${SRC_HOME}
/usr/libexec/PlistBuddy -c "Add :QYXcodePlugInGitPath string $plugInGitPath@@$plist" "$plist"
else
#存在
/usr/libexec/PlistBuddy -c "Delete :QYXcodePlugInGitPath" "$plist"
fi
}
#bulide Release
function bulide_Release(){
cd $SRC_HOME
#先更新下依赖的第三方库
pod install --verbose --no-repo-update
xcodebuild -configuration Release -workspace QYXcodePlugIn.xcworkspace -scheme ShortcutRecorder.framework || exit
xcodebuild -configuration Release -workspace QYXcodePlugIn.xcworkspace -scheme PTHotKey.framework || exit
xcodebuild -configuration Release -workspace QYXcodePlugIn.xcworkspace -scheme QYXcodePlugIn || exit
# xctool 在 xcode8 下暂不可用,等待官方解决
# xctool -configuration Release -workspace QYXcodePlugIn.xcworkspace -scheme ShortcutRecorder.framework || exit
#
# xctool -configuration Release -workspace QYXcodePlugIn.xcworkspace -scheme PTHotKey.framework || exit
#
# xctool -configuration Release -workspace QYXcodePlugIn.xcworkspace -scheme QYXcodePlugIn || exit
}
#call Function
#安装依赖
install_Depend
#安装代码片段
codeSnippetFun
#安装代码模板
codeTemplateFun
#写入工程路径
updatePlist
#安装插件
bulide_Release
#fix 升级XCode 没有用
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID`
#判断是否传入外部参数(是否更新)
if [ -z "$paramterFromOut" ];
then
#重启XCode
pkill -9 -x Xcode
#fix LSOpenURLsWithRole() failed with error on OSX Yosemite
sleep 0.5
open /Applications/Xcode.app
else
#用python启动进程,并执行shell。
python rtXcode.py
fi
#编译成功,清理plist
updatePlist
echo " 🎉 🎉 🎉 🚀 🚀 🚀 Enjoy.Go! 🍻 🍻 🍻 "