forked from Jasonette/JASONETTE-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup
executable file
·409 lines (348 loc) · 13.6 KB
/
Setup
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#!/bin/sh
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "${DIR}"
bundleidentifier(){
formatted=(`echo $1 | sed 's/http[s]*:\/\///g' | sed 's/www\.//g' | sed 's/\.json$//g' | sed 's/\//./g' | sed 's/[^a-zA-Z0-9.-]/./g' | sed 's/\.\.+/./g'`)
OLDIFS=$IFS
IFS=.
set -f
array=($formatted)
str=""
IFS=$OLDIFS
for (( i=${#array[@]}-1 ; i>=0 ; i-- )) ; do
str+="${array[i]}"
str+="."
done
new_bundle_id=(`echo $str | sed 's/\.$//g'`)
sed -i '' "s/PRODUCT_BUNDLE_IDENTIFIER[^;]*;/PRODUCT_BUNDLE_IDENTIFIER\ =\ $new_bundle_id;/g" app/Jasonette.xcodeproj/project.pbxproj
set +f
}
settingsplist(){
cat > app/Jasonette/settings.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>client_id</key>
<string></string>
<key>client_secret</key>
<string></string>
<key>url</key>
<string>$1</string>
<key>loading</key>
<false/>
<key>launch</key>
<string>file://preload.json</string>
<key>debug</key>
<false/>
</dict>
</plist>
EOF
}
infoplist(){
# same as bundleidentifier()
cat > app/Jasonette/Info.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>used to access photo library</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>NSMicrophoneUsageDescription</key>
<string>used to access microphone api</string>
<key>NSAppleMusicUsageDescription</key>
<string>used to access media library</string>
<key>NSContactsUsageDescription</key>
<string>used to access contacts api</string>
<key>NSCameraUsageDescription</key>
<string>used to access camera api</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>used to access location api</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>\$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>\$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$1</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>$3</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string></string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
EOF
}
generate_iconset(){
local full_icon="$1"
local type=`file -b ${full_icon}`
if [[ $type =~ JPEG ]]
then
cp "$full_icon" Icon-20.jpg &> /dev/null
sips -z 29 29 Icon-20.jpg &> /dev/null
sips -s format png Icon-20.jpg --out Icon-20.png &> /dev/null
cp "$full_icon" Icon-Small.jpg &> /dev/null
sips -z 29 29 Icon-Small.jpg &> /dev/null
sips -s format png Icon-Small.jpg --out Icon-Small.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 58 58 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 87 87 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" Icon-Small-50.jpg &> /dev/null
sips -z 50 50 Icon-Small-50.jpg &> /dev/null
sips -s format png Icon-Small-50.jpg --out Icon-Small-50.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 100 100 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" Icon.jpg &> /dev/null
sips -z 57 57 Icon.jpg &> /dev/null
sips -s format png Icon.jpg --out Icon.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 114 114 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 40 40 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" Icon-40.jpg &> /dev/null
sips -z 40 40 Icon-40.jpg &> /dev/null
sips -s format png Icon-40.jpg --out Icon-40.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 60 60 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 80 80 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 120 120 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 120 120 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 180 180 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" Icon-72.jpg &> /dev/null
sips -z 72 72 Icon-72.jpg &> /dev/null
sips -s format png Icon-72.jpg --out Icon-72.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 144 144 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" Icon-76.jpg &> /dev/null
sips -z 76 76 Icon-76.jpg &> /dev/null
sips -s format png Icon-76.jpg --out Icon-76.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 152 152 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 167 167 [email protected] &> /dev/null
sips -s format png [email protected] --out [email protected] &> /dev/null
cp "$full_icon" Icon-1024.jpg &> /dev/null
sips -z 1024 1024 Icon-1024.jpg &> /dev/null
sips -s format png Icon-1024.jpg --out Icon-1024.png &> /dev/null
rm Icon-20.jpg
rm Icon-Small.jpg
rm Icon-Small-50.jpg
rm Icon.jpg
rm Icon-40.jpg
rm Icon-72.jpg
rm Icon-76.jpg
rm Icon-1024.jpg
else
cp "$full_icon" Icon-20.png &> /dev/null
sips -z 20 20 Icon-20.png &> /dev/null
cp "$full_icon" Icon-Small.png &> /dev/null
sips -z 29 29 Icon-Small.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 40 40 [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 58 58 [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 60 60 [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 87 87 [email protected] &> /dev/null
cp "$full_icon" Icon-Small-50.png &> /dev/null
sips -z 50 50 Icon-Small-50.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 100 100 [email protected] &> /dev/null
cp "$full_icon" Icon.png &> /dev/null
sips -z 57 57 Icon.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 114 114 [email protected] &> /dev/null
cp "$full_icon" Icon-40.png &> /dev/null
sips -z 40 40 Icon-40.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 80 80 [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 120 120 [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 120 120 [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 180 180 [email protected] &> /dev/null
cp "$full_icon" Icon-72.png &> /dev/null
sips -z 72 72 Icon-72.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 144 144 [email protected] &> /dev/null
cp "$full_icon" Icon-76.png &> /dev/null
sips -z 76 76 Icon-76.png &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 152 152 [email protected] &> /dev/null
cp "$full_icon" [email protected] &> /dev/null
sips -z 167 167 [email protected] &> /dev/null
cp "$full_icon" Icon-1024.png &> /dev/null
sips -z 1024 1024 Icon-1024.png &> /dev/null
fi
mv Icon-20.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon-20.png &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv Icon-Small.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon-Small.png &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv Icon-Small-50.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon-Small-50.png &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv Icon.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon.png &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv Icon-40.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon-40.png &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv Icon-72.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon-72.png &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv Icon-76.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon-76.png &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv [email protected] app/Jasonette/Media.xcassets/AppIcon.appiconset/[email protected] &> /dev/null
mv Icon-1024.png app/Jasonette/Media.xcassets/AppIcon.appiconset/Icon-1024.png &> /dev/null
}
clear
RED='\033[0;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;94m'
NONE='\033[00m'
echo "${RED}WELCOME TO JASONETTE!"
echo ""
echo "${GREEN}1. Try the demo app (Recommended if you're new)"
echo "2. Create a new app"
echo "3. Continue working on the existing app${NONE}"
echo ""
read -p "Select 1, 2, or 3 and press enter: (1) " option
if ((option == 2))
then
read -p "[NAME] App name: " name
read -p "[NAME] HOME JSON URL if you have one: (or press Enter to create one): " url
url_scheme=(`echo -n $url | openssl sha1`)
url_scheme="J${url_scheme}"
if [ ${#url} -gt 0 ]
then
settingsplist "$url"
infoplist "$name" "$url" "$url_scheme"
bundleidentifier "$url"
else
echo ""
echo "${LIGHTBLUE}Opening Jasonbase.com .."
echo "Jasonbase is a free JSON hosting site."
echo "Try writing one, save it, and come back with a URL, I'll wait.${NONE}"
echo ""
open https://www.jasonbase.com
read -p "[URL] Enter the JSON URL: " url
while [ ${#url} -eq 0 ]
do
read -p "[URL] Enter the JSON URL: " url
done
settingsplist "$url"
infoplist "$name" "$url" "$url_scheme"
bundleidentifier "$url"
fi
read -p "[ICON] Add a PNG or JPG image to the 'icon' folder and press Enter.." -r e
for file in icon/*.{jpg,jpeg,JPG,JPEG,png,PNG}; do
[ -e "$file" ] && generate_iconset "$file" && break
done
echo "${GREEN}* URL Scheme: ${url_scheme}://"
echo "* OAuth redirect uri: ${url_scheme}://oauth${GREEN}"
echo "Opening XCode workspace. Please wait..."
open app/Jasonette.xcworkspace
sleep 10
elif ((option == 3))
then
echo "Opening XCode workspace. Please wait..."
open app/Jasonette.xcworkspace
sleep 10
else
new_bundle_id=`uuidgen`
settingsplist https://jasonette.github.io/Jasonpedia/hello.json
bundleidentifier "com.jasonette.seed.${new_bundle_id}"
echo ""
echo "You can view the JSON for the included demo app at:"
echo "https://github.com/Jasonette/Jasonpedia"
echo ""
echo "Opening XCode workspace. Please wait..."
open app/Jasonette.xcworkspace
echo ""
echo ""
sleep 10
fi