Skip to content

Commit d0676c4

Browse files
committed
feat: Add proper code signing and Info.plist embedding for macOS permissions
- Add Info.plist with bundle identifier and usage descriptions - Embed Info.plist into binary using linker flags in Package.swift - Add Developer ID code signing to build script (with ad-hoc fallback) - Update version to 2.0.0 in Info.plist - Enable runtime hardening for notarization readiness This ensures Peekaboo works properly with macOS permissions system and can be distributed via Homebrew with proper code signing.
1 parent 549c470 commit d0676c4

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

peekaboo-cli/Package.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ let package = Package(
2424
swiftSettings: [
2525
.enableExperimentalFeature("StrictConcurrency"),
2626
.unsafeFlags(["-parse-as-library"])
27+
],
28+
linkerSettings: [
29+
.unsafeFlags([
30+
"-Xlinker", "-sectcreate",
31+
"-Xlinker", "__TEXT",
32+
"-Xlinker", "__info_plist",
33+
"-Xlinker", "Sources/Resources/Info.plist"
34+
])
2735
]
2836
),
2937
.testTarget(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleIdentifier</key>
6+
<string>com.steipete.peekaboo</string>
7+
<key>CFBundleName</key>
8+
<string>Peekaboo</string>
9+
<key>CFBundleVersion</key>
10+
<string>2.0.0</string>
11+
<key>CFBundleShortVersionString</key>
12+
<string>2.0.0</string>
13+
<key>NSScreenCaptureUsageDescription</key>
14+
<string>Peekaboo needs screen recording permission to capture screenshots and analyze window content.</string>
15+
</dict>
16+
</plist>

scripts/build-swift-universal.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ echo "🤏 Stripping symbols for further size reduction..."
5252
# -x: Remove non-global symbols
5353
strip -Sx "$FINAL_BINARY_PATH.tmp"
5454

55+
echo "🔏 Code signing the universal binary..."
56+
if security find-identity -p codesigning -v | grep -q "Developer ID Application"; then
57+
# Sign with Developer ID if available
58+
SIGNING_IDENTITY=$(security find-identity -p codesigning -v | grep "Developer ID Application" | head -1 | awk '{print $2}')
59+
codesign --force --sign "$SIGNING_IDENTITY" \
60+
--options runtime \
61+
--identifier "com.steipete.peekaboo" \
62+
--timestamp \
63+
"$FINAL_BINARY_PATH.tmp"
64+
echo "✅ Signed with Developer ID: $SIGNING_IDENTITY"
65+
else
66+
# Fall back to ad-hoc signing for local builds
67+
codesign --force --sign - \
68+
--identifier "com.steipete.peekaboo" \
69+
"$FINAL_BINARY_PATH.tmp"
70+
echo "⚠️ Ad-hoc signed (no Developer ID found)"
71+
fi
72+
73+
# Verify the signature and embedded info
74+
echo "🔍 Verifying code signature..."
75+
codesign -dv "$FINAL_BINARY_PATH.tmp" 2>&1 | grep -E "Identifier=|Signature"
76+
5577
# Replace the old binary with the new one
5678
mv "$FINAL_BINARY_PATH.tmp" "$FINAL_BINARY_PATH"
5779

0 commit comments

Comments
 (0)