Skip to content

Commit 5b9faef

Browse files
committed
feat: Update spmgen version and example
1 parent f9b6bd6 commit 5b9faef

File tree

13 files changed

+142
-51
lines changed

13 files changed

+142
-51
lines changed

.gitignore

+34-29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# ––––––––––––––––––––––––––––––––– Generated ––––––––––––––––––––––––––––––––––
2+
3+
*.xcodeproj
4+
*.xcworkspace
5+
Sources/**/Resources.generated.swift
6+
iOS/Info.plist
7+
8+
# –––––––––––––––––––––––––––––––– Scripts –––––––––––––––––––––––––––––––––
9+
10+
Scripts/.bin
11+
12+
# ––––––––––––––––––––––––––––––– Swift Package Manager –––––––––––––––––––––––––––––––
13+
14+
Packages/
15+
Package.pins
16+
Package.resolved
17+
.build/
18+
.swiftpm
19+
120
# ––––––––––––––––––––––––––––– Build generated –––––––––––––––––––––––––––––
221

322
build/
@@ -15,40 +34,33 @@ DerivedData/
1534
!default.perspectivev3
1635
xcuserdata/
1736

37+
# –––––––––––––––––––––––––––––––– Fastlane –––––––––––––––––––––––––––––––––
38+
# It is recommended to not store the screenshots in the git repo. Instead,
39+
# use fastlane to re-generate the screenshots whenever they are needed.
40+
# For more information about the recommended setup visit:
41+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
42+
43+
fastlane/report.xml
44+
fastlane/Preview.html
45+
fastlane/screenshots/**/*.png
46+
fastlane/test_output
47+
1848
# ––––––––––––––––––––––––––– Obj-C/Swift specific ––––––––––––––––––––––––––
1949

2050
*.hmap
2151
*.ipa
2252
*.dSYM.zip
2353
*.dSYM
2454

25-
# ––––––––––––––––––––––––––––––– Playgrounds –––––––––––––––––––––––––––––––
26-
27-
timeline.xctimeline
28-
playground.xcworkspace
29-
30-
# Swift Package Manager
31-
32-
Packages/
33-
Package.pins
34-
Package.resolved
35-
.build/
36-
.swiftpm
37-
3855
# –––––––––––––––––––––––––––––––– CocoaPods ––––––––––––––––––––––––––––––––
3956

4057
Pods/
4158

42-
# –––––––––––––––––––––––––––––––– Fastlane –––––––––––––––––––––––––––––––––
43-
# It is recommended to not store the screenshots in the git repo. Instead,
44-
# use fastlane to re-generate the screenshots whenever they are needed.
45-
# For more information about the recommended setup visit:
46-
# https://docs.fastlane.tools/best-practices/source-control/#source-control
59+
# ––––––––––––––––––––––––––––––– Playgrounds –––––––––––––––––––––––––––––––
60+
61+
timeline.xctimeline
62+
playground.xcworkspace
4763

48-
fastlane/report.xml
49-
fastlane/Preview.html
50-
fastlane/screenshots/**/*.png
51-
fastlane/test_output
5264

5365
# –––––––––––––––––––––––––––––––––– Other ––––––––––––––––––––––––––––––––––
5466

@@ -57,10 +69,3 @@ fastlane/test_output
5769
*.xcscmblueprint
5870
.DS_Store
5971
.vscode
60-
61-
# ––––––––––––––––––––––––––––––––– Generated ––––––––––––––––––––––––––––––––––
62-
63-
*.xcodeproj
64-
*.xcworkspace
65-
Sources/Resources/Resources.generated.swift
66-
iOS/Info.plist
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@_exported import DeclarativeConfiguration
22
@_exported import Combine
3-
@_exported import Foundation
3+
@_exported import Foundation

Scripts/.core/constants.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ fi
99

1010
# ––––––––––––––––––––––––––– CONSTANTS –––––––––––––––––––––––––
1111

12-
TOOLS_INSTALL_PATH="${HOME}/.local_cli_tools"
12+
TOOLS_INSTALL_PATH="$( cd "$(dirname "$0")" && pwd )/.bin"
1313
INSTALLERS_PATH="${TOOLS_INSTALL_PATH}/.installers"

Scripts/.core/functions.sh

+17-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ function print_error() {
5454
echo -e "\n❌ ${BOLD}${RED}${1}${RESET}\n"
5555
}
5656

57+
function _print_info() {
58+
echo -e "ℹ️ ${BOLD}${PURPLE}${1}${RESET}"
59+
}
60+
61+
function _print_success() {
62+
echo -e "${BOLD}${GREEN}${1}${RESET}"
63+
}
64+
65+
function _print_warning() {
66+
echo -e "⚠️ ${BOLD}${YELLOW}${1}${RESET}"
67+
}
68+
69+
function _print_error() {
70+
echo -e "${BOLD}${RED}${1}${RESET}"
71+
}
72+
5773
function is_installed() {
5874
[ `command -v "$1"` 2>/dev/null ] && echo true || echo false
5975
}
@@ -69,7 +85,7 @@ function build_swift_product() {
6985
print_error "PRODUCT NAME SHOULD BE PASSED"
7086
return $ERROR_CODE
7187
fi
72-
swift build --product=$product_name -c release --disable-sandbox
88+
swift build --product=$product_name -c release --disable-sandbox --build-path '.build'
7389
}
7490

7591
function force_cd() {

Scripts/generate_resources.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ SCRIPT_DIR_PATH="$( cd "$(dirname "$0")" && pwd )"
55
source "${SCRIPT_DIR_PATH}/.core/functions.sh"
66
source "${SCRIPT_DIR_PATH}/.core/constants.sh"
77

8-
# CONSTANTS
9-
TOOL="${TOOLS_INSTALL_PATH}/spmgen"
8+
# FUNCTIONS
9+
function generate_resources() {
10+
local target_folder_name="$1"
11+
if [ -z "$target_folder_name" ]; then
12+
print_error "PRODUCT NAME SHOULD BE PASSED"
13+
return $ERROR_CODE
14+
fi
15+
${SCRIPT_DIR_PATH}/generate_target_resources.sh ${target_folder_name}
16+
}
1017

11-
# ––––––––––––––––––––––––––– SCRIPT –––––––––––––––––––––––––––
12-
13-
if ! $( is_installed "${TOOL}" ); then "${SCRIPT_DIR_PATH}/install_spmgen.sh"; fi
14-
15-
"$TOOL" resources "${SCRIPT_DIR_PATH}/../Sources/Resources/Resources" \
16-
--output "${SCRIPT_DIR_PATH}/../Sources/Resources/Resources.generated.swift" \
17-
--indentor " " \
18-
--tab-size 2
19-
20-
print_success "Did generate resources"
18+
# RESOURCES GENERATION
19+
generate_resources "Resources"
20+
generate_resources "MainFeature"

Scripts/generate_target_resources.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# IMPORTS
4+
SCRIPT_DIR_PATH="$( cd "$(dirname "$0")" && pwd )"
5+
source "${SCRIPT_DIR_PATH}/.core/functions.sh"
6+
source "${SCRIPT_DIR_PATH}/.core/constants.sh"
7+
8+
# CONSTANTS
9+
TOOL="${TOOLS_INSTALL_PATH}/spmgen"
10+
11+
TARGET_FOLDER_NAME=$1
12+
13+
# ––––––––––––––––––––––––––– SCRIPT –––––––––––––––––––––––––––
14+
15+
if ! $( is_installed "${TOOL}" ); then "${SCRIPT_DIR_PATH}/install_spmgen.sh"; fi
16+
17+
"$TOOL" resources "${SCRIPT_DIR_PATH}/../Sources/${TARGET_FOLDER_NAME}/Resources" \
18+
--output "${SCRIPT_DIR_PATH}/../Sources/${TARGET_FOLDER_NAME}/Resources.generated.swift" \
19+
--indentor " " \
20+
--tab-size 2
21+
22+
echo ""
23+
_print_success "Did generate resources for Sources/${TARGET_FOLDER_NAME}"

Scripts/install_spmgen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ source "${SCRIPT_DIR_PATH}/.core/constants.sh"
1010
# CONFIG
1111
TOOL_NAME="spmgen"
1212
TOOL_OWNER="capturecontext"
13-
TOOL_VERSION="2.0.0"
13+
TOOL_VERSION="2.1.1"
1414

1515
# CONSTANTS
1616
TOOL_INSTALL_PATH="${TOOLS_INSTALL_PATH}/${TOOL_NAME}-tmp"

Sources/AppFeature/Bootstrap/AppDelegate.swift

-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ public class AppDelegate: UIResponder, UIApplicationDelegate {
2626
didDiscardSceneSessions sceneSessions: Set<UISceneSession>
2727
) {}
2828
}
29-

Sources/MainFeature/MainViewController.swift

+26-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,32 @@ public final class MainViewController: UITabBarController {
1010
[
1111
UIHostingController(
1212
rootView: VStack {
13-
Image.resource(.usgsUnsplash)
14-
.resizable()
15-
.aspectRatio(1, contentMode: .fill)
16-
.frame(width: 200, height: 200)
17-
.clipShape(RoundedRectangle(cornerRadius: 20, style: .continuous))
13+
HStack {
14+
Image.resource(.usgsUnsplash)
15+
.resizable()
16+
.aspectRatio(1, contentMode: .fill)
17+
.frame(width: 120, height: 120)
18+
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
19+
.overlay(Color.black.opacity(0.1))
20+
.overlay(
21+
Text("shared\nresource")
22+
.foregroundColor(.white)
23+
.multilineTextAlignment(.center)
24+
.font(.system(size: 12, weight: .regular, design: .monospaced))
25+
)
26+
Image.resource(.usgsUnsplash_2)
27+
.resizable()
28+
.aspectRatio(1, contentMode: .fill)
29+
.frame(width: 120, height: 120)
30+
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
31+
.overlay(Color.black.opacity(0.1))
32+
.overlay(
33+
Text("local\nresource")
34+
.foregroundColor(.white)
35+
.multilineTextAlignment(.center)
36+
.font(.system(size: 12, weight: .regular, design: .monospaced))
37+
)
38+
}
1839
Text("First")
1940
.fontWeight(.semibold)
2041
.foregroundColor(Color.white)

Sources/MainFeature/Resources/Media.xcassets/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "usgs-hoS3dzgpHzw-unsplash-2.jpg",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}

0 commit comments

Comments
 (0)