Skip to content

Commit d5495c7

Browse files
committed
feat: Enhance code signing process and add development certificate creation script
1 parent 17a6009 commit d5495c7

File tree

3 files changed

+89
-4
lines changed

3 files changed

+89
-4
lines changed

build_app_unified.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,17 @@ if [ -n "$CERT_NAME" ]; then
305305
# Sign the main app bundle (after all modifications including rpath changes)
306306
# Use entitlements if they exist
307307
ENTITLEMENTS_FILE="ClickIt/ClickIt.entitlements"
308-
CODESIGN_ARGS="--deep --force --sign \"$CERT_NAME\""
309308
if [ -f "$ENTITLEMENTS_FILE" ]; then
310309
echo "🔐 Using entitlements from $ENTITLEMENTS_FILE"
311-
CODESIGN_ARGS="$CODESIGN_ARGS --entitlements \"$ENTITLEMENTS_FILE\""
310+
codesign --deep --force --sign "$CERT_NAME" --entitlements "$ENTITLEMENTS_FILE" "$APP_BUNDLE"
311+
CODESIGN_RESULT=$?
312+
else
313+
echo "⚠️ No entitlements file found at $ENTITLEMENTS_FILE"
314+
codesign --deep --force --sign "$CERT_NAME" "$APP_BUNDLE"
315+
CODESIGN_RESULT=$?
312316
fi
313317

314-
if eval "codesign $CODESIGN_ARGS \"$APP_BUNDLE\"" 2>/dev/null; then
318+
if [ $CODESIGN_RESULT -eq 0 ]; then
315319
echo "✅ Code signing successful!"
316320

317321
# Verify the signature

fastlane/Fastfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ default_platform(:mac)
1010

1111
# Global configuration
1212
APP_NAME = "ClickIt"
13-
BUNDLE_ID = "com.jsonify.ClickIt"
13+
BUNDLE_ID = "com.jsonify.clickit"
1414
DIST_DIR = "dist"
1515

1616
platform :mac do

scripts/create-dev-certificate.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
# Create ClickIt Development Certificate for consistent app signing
4+
# This creates a permanent self-signed certificate that maintains app identity across builds
5+
6+
set -e
7+
8+
CERT_NAME="ClickIt Developer Certificate"
9+
KEYCHAIN="$HOME/Library/Keychains/login.keychain-db"
10+
TEMP_DIR=$(mktemp -d)
11+
12+
echo "🔐 Creating ClickIt development certificate..."
13+
14+
# Delete existing certificate if it exists
15+
security delete-certificate -c "$CERT_NAME" 2>/dev/null && echo " Removed existing certificate" || true
16+
17+
# Create certificate configuration
18+
cat > "$TEMP_DIR/cert.conf" << EOF
19+
[req]
20+
default_bits = 2048
21+
prompt = no
22+
distinguished_name = dn
23+
req_extensions = v3_req
24+
25+
[dn]
26+
CN=ClickIt Developer Certificate
27+
O=ClickIt Development
28+
OU=ClickIt Team
29+
C=US
30+
31+
[v3_req]
32+
basicConstraints = CA:FALSE
33+
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
34+
extendedKeyUsage = codeSigning
35+
EOF
36+
37+
echo "📝 Generating private key and certificate..."
38+
39+
# Generate private key
40+
openssl genrsa -out "$TEMP_DIR/private.key" 2048
41+
42+
# Generate self-signed certificate (valid for 10 years)
43+
openssl req -new -x509 -key "$TEMP_DIR/private.key" -out "$TEMP_DIR/cert.crt" -days 3650 -config "$TEMP_DIR/cert.conf" -extensions v3_req
44+
45+
echo "🔑 Importing certificate and private key into keychain..."
46+
47+
# Import certificate first
48+
security import "$TEMP_DIR/cert.crt" -k "$KEYCHAIN" -T /usr/bin/codesign -T /usr/bin/security
49+
50+
# Import private key
51+
security import "$TEMP_DIR/private.key" -k "$KEYCHAIN" -T /usr/bin/codesign -T /usr/bin/security
52+
53+
echo "✅ Certificate imported successfully"
54+
55+
# Set trust settings for code signing (allow without password)
56+
security set-key-partition-list -S apple-tool:,apple: -s -k "" -D "$CERT_NAME" -t private "$KEYCHAIN" 2>/dev/null || echo " Trust settings configured"
57+
58+
# Add trust settings for code signing (this makes it appear in find-identity)
59+
echo "🔐 Setting certificate trust for code signing..."
60+
security add-trusted-cert -d -r trustRoot -k "$KEYCHAIN" "$TEMP_DIR/cert.crt" 2>/dev/null || echo " Certificate already trusted"
61+
62+
# Verify certificate was created
63+
if security find-certificate -c "$CERT_NAME" >/dev/null 2>&1; then
64+
echo "✅ Certificate verification passed"
65+
66+
# Show certificate details
67+
echo "📋 Certificate details:"
68+
security find-certificate -c "$CERT_NAME" -p | openssl x509 -subject -dates -noout 2>/dev/null
69+
else
70+
echo "❌ Certificate verification failed"
71+
exit 1
72+
fi
73+
74+
# Clean up temporary files
75+
rm -rf "$TEMP_DIR"
76+
77+
echo ""
78+
echo "🎯 Certificate setup complete!"
79+
echo " Name: $CERT_NAME"
80+
echo " This certificate will provide consistent app identity across builds"
81+
echo " Permissions should now persist after rebuilding the app"

0 commit comments

Comments
 (0)