1- .PHONY : lint format
1+ # Copyright (C) 2025 Tommy van der Vorst
2+ #
3+ # This Source Code Form is subject to the terms of the Mozilla Public
4+ # License, v. 2.0. If a copy of the MPL was not distributed with this file,
5+ # You can obtain one at https://mozilla.org/MPL/2.0/.
6+ .PHONY : lint format ipa clean build
7+
8+ build : core ipa
29
310format : Sushitrain/* .swift
411 swift-format format -r -i .
512
613lint : Sushitrain/* .swift
7- swift-format lint -r .
14+ swift-format lint -r .
15+
16+ BUILD_DIR =$(shell pwd) /Build
17+ KEYCHAIN_PATH =$(BUILD_DIR ) /keychain.db
18+ CODESIGN_IDENTITY ="Apple Development: Tommy van der Vorst (NG3J47D2S7)"
19+ KEYCHAIN_PASSWORD ="not so secret"
20+
21+ # Apple developer team ID (must match certificate and provisioning profile)
22+ TEAM_ID =2N89DJPQ2P
23+
24+ # UUID of Assets/synctrain-ios-ci.mobileprovision
25+ # PROVISIONING_PROFILE_SPECIFIER="589483bc-da9c-4fda-a64f-8dc02e1491a1"
26+
27+ PROVISIONING_PROFILE_UUID =$(shell security cms -D -i ./Assets/synctrain-ios-ci.mobileprovision | plutil -extract UUID raw -)
28+ PROVISIONING_PROFILE_PATH =~/Library/MobileDevice/Provisioning\ Profiles/$(PROVISIONING_PROFILE_UUID ) .mobileprovision
29+
30+ clean :
31+ rm -rf $(BUILD_DIR )
32+ cd SushitrainCore && make clean
33+
34+ core :
35+ cd SushitrainCore && make deps
36+ cd SushitrainCore && make
37+
38+ ipa : core
39+ ifndef P12_PASSWORD
40+ echo You need to set 'P12_PASSWORD' to the password of the .p12 certificate.
41+ exit 1
42+ endif
43+ echo $(PROVISIONING_PROFILE_UUID) $(PROVISIONING_PROFILE_PATH)
44+ mkdir -p $(BUILD_DIR)
45+
46+ # Set up a keychain
47+ security create-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
48+ security set-keychain-settings -lut 21600 $(KEYCHAIN_PATH)
49+ security unlock-keychain -p $(KEYCHAIN_PASSWORD) $(KEYCHAIN_PATH)
50+
51+ # Import WWDR root certificate
52+ # See https://www.apple.com/certificateauthority/
53+ security import ./Assets/AppleWWDRCAG3.cer -A -t cert -k $(KEYCHAIN_PATH)
54+
55+ # Import developer certificate
56+ security import ./Assets/developer-certificate.p12 -P $(P12_PASSWORD) -A -t cert -f pkcs12 -k $(KEYCHAIN_PATH)
57+ security list-keychain -d user -s $(KEYCHAIN_PATH)
58+
59+ # Import provisioning profile
60+ mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
61+ cp ./Assets/synctrain-ios-ci.mobileprovision $(PROVISIONING_PROFILE_PATH)
62+ ls -la ~/Library/MobileDevice/Provisioning\ Profiles
63+
64+ # Build archive
65+ xcodebuild -scheme "Synctrain release" \
66+ -archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
67+ -sdk iphoneos \
68+ -configuration Release \
69+ -destination generic/platform=iOS \
70+ CODE_SIGN_IDENTITY=$(CODESIGN_IDENTITY) \
71+ OTHER_CODE_SIGN_FLAGS="--keychain $(KEYCHAIN_PATH)" \
72+ PROVISIONING_PROFILE_SPECIFIER=$(PROVISIONING_PROFILE_UUID) \
73+ DEVELOPMENT_TEAM=$(TEAM_ID) \
74+ CODE_SIGN_STYLE="Manual" \
75+ clean archive
76+
77+ # Export ipa
78+ xcodebuild \
79+ -exportArchive \
80+ -exportOptionsPlist ./Assets/ExportOptions.plist \
81+ -archivePath "$(BUILD_DIR)/synctrain-ios.xcarchive" \
82+ -exportPath $(BUILD_DIR)
83+
84+ # Clean up
85+ security delete-keychain $(KEYCHAIN_PATH)
86+ rm $(PROVISIONING_PROFILE_PATH)
0 commit comments