-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
276 lines (241 loc) · 7.88 KB
/
Makefile
File metadata and controls
276 lines (241 loc) · 7.88 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
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
# OpenMind iOS App Makefile
# Professional build automation for mind mapping application
.PHONY: help setup build test clean release docs lint format analyze
# Configuration
PROJECT_NAME = OpenMind
WORKSPACE = $(PROJECT_NAME).xcworkspace
PROJECT = $(PROJECT_NAME).xcodeproj
SCHEME = $(PROJECT_NAME)
CONFIGURATION = Debug
DEVICE_NAME = iPhone 15
PLATFORM = iOS Simulator
# Paths
BUILD_DIR = build
DERIVED_DATA = $(BUILD_DIR)/DerivedData
ARCHIVE_PATH = $(BUILD_DIR)/$(PROJECT_NAME).xcarchive
IPA_PATH = $(BUILD_DIR)/$(PROJECT_NAME).ipa
# Colors for output
RED = \033[0;31m
GREEN = \033[0;32m
YELLOW = \033[1;33m
NC = \033[0m # No Color
# Default target
help:
@echo "$(GREEN)OpenMind Build System$(NC)"
@echo "Available targets:"
@echo " $(YELLOW)setup$(NC) - Initial project setup"
@echo " $(YELLOW)build$(NC) - Build the app for simulator"
@echo " $(YELLOW)device$(NC) - Build the app for device"
@echo " $(YELLOW)test$(NC) - Run all tests"
@echo " $(YELLOW)clean$(NC) - Clean build artifacts"
@echo " $(YELLOW)lint$(NC) - Run SwiftLint"
@echo " $(YELLOW)format$(NC) - Format code with SwiftFormat"
@echo " $(YELLOW)analyze$(NC) - Run static analysis"
@echo " $(YELLOW)docs$(NC) - Generate documentation"
@echo " $(YELLOW)archive$(NC) - Create release archive"
@echo " $(YELLOW)release$(NC) - Build for App Store release"
@echo ""
@echo "Advanced targets:"
@echo " $(YELLOW)ci$(NC) - Run full CI pipeline"
@echo " $(YELLOW)coverage$(NC) - Generate coverage report"
@echo " $(YELLOW)deadcode$(NC) - Find unused code"
@echo " $(YELLOW)deps$(NC) - Update dependencies"
@echo " $(YELLOW)fastlane$(NC) - Run fastlane commands"
@echo " $(YELLOW)generate$(NC) - Generate project with XcodeGen"
# Setup development environment
setup:
@echo "$(GREEN)Setting up OpenMind development environment...$(NC)"
# Check for Xcode
@if ! xcode-select -p &> /dev/null; then \
echo "$(RED)Error: Xcode not found. Please install Xcode from the App Store.$(NC)"; \
exit 1; \
fi
# Install tools if needed
@if ! command -v swiftlint &> /dev/null; then \
echo "$(YELLOW)Installing SwiftLint...$(NC)"; \
brew install swiftlint; \
fi
@if ! command -v swiftformat &> /dev/null; then \
echo "$(YELLOW)Installing SwiftFormat...$(NC)"; \
brew install swiftformat; \
fi
# Create necessary directories
@mkdir -p $(BUILD_DIR)
@mkdir -p Resources/Assets.xcassets
@mkdir -p Resources/Preview\ Content
# Resolve Swift Package dependencies
@echo "$(YELLOW)Resolving package dependencies...$(NC)"
@xcodebuild -resolvePackageDependencies -project $(PROJECT)
@echo "$(GREEN)Setup complete!$(NC)"
# Build for simulator
build: clean
@echo "$(GREEN)Building OpenMind for simulator...$(NC)"
@xcodebuild build \
-project $(PROJECT) \
-scheme $(SCHEME) \
-configuration $(CONFIGURATION) \
-destination "platform=$(PLATFORM),name=$(DEVICE_NAME)" \
-derivedDataPath $(DERIVED_DATA) \
ONLY_ACTIVE_ARCH=YES \
| xcbeautify || true
# Build for device
device: clean
@echo "$(GREEN)Building OpenMind for device...$(NC)"
@xcodebuild build \
-project $(PROJECT) \
-scheme $(SCHEME) \
-configuration Release \
-destination generic/platform=iOS \
-derivedDataPath $(DERIVED_DATA) \
| xcbeautify || true
# Run tests
test:
@echo "$(GREEN)Running tests...$(NC)"
@xcodebuild test \
-project $(PROJECT) \
-scheme $(SCHEME) \
-destination "platform=$(PLATFORM),name=$(DEVICE_NAME)" \
-enableCodeCoverage YES \
-resultBundlePath $(BUILD_DIR)/TestResults.xcresult \
| xcbeautify || true
# Clean build artifacts
clean:
@echo "$(YELLOW)Cleaning build artifacts...$(NC)"
@rm -rf $(BUILD_DIR)
@rm -rf ~/Library/Developer/Xcode/DerivedData/OpenMind-*
@xcodebuild clean -project $(PROJECT) -scheme $(SCHEME) -quiet || true
# Run SwiftLint
lint:
@echo "$(GREEN)Running SwiftLint...$(NC)"
@if command -v swiftlint &> /dev/null; then \
swiftlint lint --strict; \
else \
echo "$(RED)SwiftLint not installed. Run 'make setup' first.$(NC)"; \
fi
# Format code
format:
@echo "$(GREEN)Formatting code...$(NC)"
@if command -v swiftformat &> /dev/null; then \
swiftformat . --swiftversion 5.9; \
else \
echo "$(RED)SwiftFormat not installed. Run 'make setup' first.$(NC)"; \
fi
# Static analysis
analyze:
@echo "$(GREEN)Running static analysis...$(NC)"
@xcodebuild analyze \
-project $(PROJECT) \
-scheme $(SCHEME) \
-configuration $(CONFIGURATION) \
| xcbeautify || true
# Generate documentation
docs:
@echo "$(GREEN)Generating documentation...$(NC)"
@if command -v jazzy &> /dev/null; then \
jazzy \
--clean \
--author "OpenMind Team" \
--module $(PROJECT_NAME) \
--source-directory . \
--output docs \
--theme apple; \
else \
echo "$(YELLOW)Jazzy not installed. Install with: gem install jazzy$(NC)"; \
fi
# Create archive
archive: clean
@echo "$(GREEN)Creating release archive...$(NC)"
@xcodebuild archive \
-project $(PROJECT) \
-scheme $(SCHEME) \
-configuration Release \
-archivePath $(ARCHIVE_PATH) \
-destination generic/platform=iOS \
| xcbeautify || true
# Build for release
release: archive
@echo "$(GREEN)Exporting for App Store...$(NC)"
@xcodebuild -exportArchive \
-archivePath $(ARCHIVE_PATH) \
-exportPath $(BUILD_DIR) \
-exportOptionsPlist Scripts/ExportOptions.plist \
| xcbeautify || true
@echo "$(GREEN)Release build complete! IPA available at: $(IPA_PATH)$(NC)"
# Quick development build
dev: format lint build
@echo "$(GREEN)Development build complete!$(NC)"
# Run the app in simulator
run: build
@echo "$(GREEN)Launching OpenMind in simulator...$(NC)"
@xcrun simctl boot "$(DEVICE_NAME)" || true
@xcrun simctl install "$(DEVICE_NAME)" $(DERIVED_DATA)/Build/Products/$(CONFIGURATION)-iphonesimulator/$(PROJECT_NAME).app
@xcrun simctl launch "$(DEVICE_NAME)" com.openmind.app
# Show build settings
settings:
@xcodebuild -project $(PROJECT) -scheme $(SCHEME) -showBuildSettings
# Advanced targets
# Run full CI pipeline
ci:
@echo "$(GREEN)Running CI pipeline...$(NC)"
@./Scripts/ci.sh Release "iOS Simulator" "iPhone 15"
# Generate coverage report
coverage: test
@echo "$(GREEN)Generating coverage report...$(NC)"
@if command -v xcov &> /dev/null; then \
xcov --project $(PROJECT) \
--scheme $(SCHEME) \
--output_directory $(BUILD_DIR)/coverage \
--minimum_coverage_percentage 70.0; \
else \
xcrun xccov view --report $(BUILD_DIR)/TestResults.xcresult; \
fi
# Find dead code
deadcode:
@echo "$(GREEN)Searching for dead code...$(NC)"
@if command -v periphery &> /dev/null; then \
periphery scan \
--project $(PROJECT) \
--schemes $(SCHEME) \
--format xcode; \
else \
echo "$(YELLOW)Periphery not installed. Install with: brew install peripheryapp/periphery/periphery$(NC)"; \
fi
# Update dependencies
deps:
@echo "$(GREEN)Updating dependencies...$(NC)"
@xcodebuild -resolvePackageDependencies -project $(PROJECT)
@if [ -f "Gemfile" ]; then bundle update; fi
@if [ -f "Brewfile" ]; then brew bundle; fi
# Fastlane shortcuts
fastlane:
@if [ -f "Gemfile" ]; then \
bundle exec fastlane $(filter-out $@,$(MAKECMDGOALS)); \
else \
echo "$(RED)Fastlane not configured. Run 'make setup' first.$(NC)"; \
fi
# Generate project with XcodeGen
generate:
@echo "$(GREEN)Generating Xcode project...$(NC)"
@if command -v xcodegen &> /dev/null; then \
xcodegen generate; \
else \
echo "$(YELLOW)XcodeGen not installed. Install with: brew install xcodegen$(NC)"; \
fi
# Install Git hooks
hooks:
@echo "$(GREEN)Installing Git hooks...$(NC)"
@cp Scripts/hooks/* .git/hooks/ 2>/dev/null || true
@chmod +x .git/hooks/* 2>/dev/null || true
# SwiftUI previews
preview:
@echo "$(GREEN)Building for SwiftUI previews...$(NC)"
@xcodebuild build \
-project $(PROJECT) \
-scheme $(SCHEME) \
-destination "platform=iOS Simulator,name=iPhone 15" \
-derivedDataPath $(DERIVED_DATA) \
-configuration Debug \
ENABLE_PREVIEWS=YES
# Catch-all for fastlane commands
%:
@: