Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Add Mac App Store target (sandboxed)

Louis Raille193b90ea937d
diff --git a/NotchBuddy/Resources/CoucouAppStore.entitlements b/NotchBuddy/Resources/CoucouAppStore.entitlements
new file mode 100644
index 00000000..0fc60724
--- /dev/null
+++ b/NotchBuddy/Resources/CoucouAppStore.entitlements
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.security.app-sandbox</key>
+ <true/>
+ <key>com.apple.security.network.client</key>
+ <true/>
+ <key>com.apple.security.files.user-selected.read-write</key>
+ <true/>
+ <key>com.apple.security.files.bookmarks.app-scope</key>
+ <true/>
+</dict>
+</plist>
diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swift
index b79a37e1..113ba6dd 100644
--- a/NotchBuddy/Sources/App/HookServer.swift
+++ b/NotchBuddy/Sources/App/HookServer.swift
@@ -15,7 +15,15 @@ final class HookServer: @unchecked Sendable {
.appendingPathComponent("NotchBuddy")
}
static var socketPath: String { supportDir.appendingPathComponent("nb.sock").path }
- static var hookScriptPath: String { supportDir.appendingPathComponent("nb-hook").path }
+ static var hookScriptPath: String {
+ #if APPSTORE
+ // Written to ~/.claude/coucou/nb-hook via security-scoped bookmark during hook installation
+ return FileManager.default.homeDirectoryForCurrentUser
+ .appendingPathComponent(".claude/coucou/nb-hook").path
+ #else
+ return supportDir.appendingPathComponent("nb-hook").path
+ #endif
+ }
// No approval blocking state — notch is notification-only, user answers in VS Code
@@ -28,7 +36,9 @@ final class HookServer: @unchecked Sendable {
// MARK: - Start
func start() {
+ #if !APPSTORE
installHookScript()
+ #endif
Thread.detachNewThread { self.serverThread() }
}
@@ -442,15 +452,19 @@ final class HookServer: @unchecked Sendable {
// MARK: - nb-hook script installation
func installHookScript() {
+ #if APPSTORE
+ // In App Store mode the script is written during settings hook installation
+ // (requires a security-scoped bookmark to ~/.claude chosen by the user)
+ #else
let dir = Self.supportDir
try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
let scriptURL = URL(fileURLWithPath: Self.hookScriptPath)
- let script = nbHookScript
- try? script.write(to: scriptURL, atomically: true, encoding: .utf8)
+ try? nbHookScript.write(to: scriptURL, atomically: true, encoding: .utf8)
_ = try? FileManager.default.setAttributes(
[.posixPermissions: 0o755 as NSNumber],
ofItemAtPath: scriptURL.path
)
+ #endif
}
// MARK: - Claude Code settings.json hook installer
@@ -491,6 +505,12 @@ final class HookServer: @unchecked Sendable {
settings = parsed
}
let hookPath = Self.hookScriptPath
+ #if APPSTORE
+ // Sandboxed apps create quarantined files; /bin/sh bypasses the quarantine flag
+ let quotedCmd = "/bin/sh \"\(hookPath.replacingOccurrences(of: "\"", with: "\\\""))\""
+ #else
+ let quotedCmd = "\"\(hookPath.replacingOccurrences(of: "\"", with: "\\\""))\""
+ #endif
let events: [(String, Int)] = [
("SessionStart", 10), ("SessionEnd", 10),
("UserPromptSubmit", 10),
@@ -503,9 +523,8 @@ final class HookServer: @unchecked Sendable {
var hooks = settings["hooks"] as? [String: Any] ?? [:]
for (event, timeout) in events {
var existing = hooks[event] as? [[String: Any]] ?? []
- existing.removeAll { ($0["hooks"] as? [[String: Any]])?.contains { ($0["command"] as? String)?.contains("NotchBuddy") == true } ?? false }
- let quotedPath = "\"\(hookPath.replacingOccurrences(of: "\"", with: "\\\""))\""
- existing.append(["hooks": [["type": "command", "command": quotedPath, "timeout": timeout]]])
+ existing.removeAll { ($0["hooks"] as? [[String: Any]])?.contains { ($0["command"] as? String)?.contains("NotchBuddy") == true || ($0["command"] as? String)?.contains("coucou") == true } ?? false }
+ existing.append(["hooks": [["type": "command", "command": quotedCmd, "timeout": timeout]]])
hooks[event] = existing
}
settings["hooks"] = hooks
@@ -522,7 +541,68 @@ final class HookServer: @unchecked Sendable {
for key in hooks.keys {
if var matchers = hooks[key] as? [[String: Any]] {
matchers.removeAll { matcher in
- (matcher["hooks"] as? [[String: Any]])?.contains { ($0["command"] as? String)?.contains("NotchBuddy") == true } ?? false
+ (matcher["hooks"] as? [[String: Any]])?.contains {
+ ($0["command"] as? String)?.contains("NotchBuddy") == true ||
+ ($0["command"] as? String)?.contains("coucou") == true
+ } ?? false
+ }
+ if matchers.isEmpty { hooks.removeValue(forKey: key) }
+ else { hooks[key] = matchers }
+ }
+ }
+ settings["hooks"] = hooks
+ let newData = try JSONSerialization.data(withJSONObject: settings, options: [.prettyPrinted, .sortedKeys])
+ try newData.write(to: settingsURL, options: .atomic)
+ }
+
+ // MARK: - App Store: hooks via security-scoped bookmark
+
+ #if APPSTORE
+ /// App Store variant — needs a security-scoped bookmark URL pointing to ~/.claude
+ func previewClaudeHooksAppStore(claudeURL: URL) throws -> String {
+ let accessing = claudeURL.startAccessingSecurityScopedResource()
+ defer { if accessing { claudeURL.stopAccessingSecurityScopedResource() } }
+ let data = try buildHooksData(claudeURL: claudeURL)
+ _pendingHooksData = data
+ return String(data: data, encoding: .utf8) ?? ""
+ }
+
+ func writeClaudeHooksAppStore(claudeURL: URL) throws {
+ guard let data = _pendingHooksData else { return }
+ let accessing = claudeURL.startAccessingSecurityScopedResource()
+ defer { if accessing { claudeURL.stopAccessingSecurityScopedResource() } }
+
+ // Write the nb-hook script into ~/.claude/coucou/nb-hook
+ let coucouDir = claudeURL.appendingPathComponent("coucou")
+ try FileManager.default.createDirectory(at: coucouDir, withIntermediateDirectories: true)
+ let scriptURL = coucouDir.appendingPathComponent("nb-hook")
+ try nbHookScriptAppStore.write(to: scriptURL, atomically: true, encoding: .utf8)
+ _ = try? FileManager.default.setAttributes([.posixPermissions: 0o755 as NSNumber], ofItemAtPath: scriptURL.path)
+
+ // Write settings.json (with backup)
+ let settingsURL = claudeURL.appendingPathComponent("settings.json")
+ let formatter = DateFormatter()
+ formatter.dateFormat = "yyyyMMdd-HHmm"
+ let backupURL = claudeURL.appendingPathComponent("settings.json.bak-\(formatter.string(from: Date()))")
+ try? FileManager.default.copyItem(at: settingsURL, to: backupURL)
+ try data.write(to: settingsURL, options: .atomic)
+ _pendingHooksData = nil
+ }
+
+ func uninstallClaudeHooksAppStore(claudeURL: URL) throws {
+ let accessing = claudeURL.startAccessingSecurityScopedResource()
+ defer { if accessing { claudeURL.stopAccessingSecurityScopedResource() } }
+ let settingsURL = claudeURL.appendingPathComponent("settings.json")
+ guard let data = try? Data(contentsOf: settingsURL),
+ var settings = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
+ var hooks = settings["hooks"] as? [String: Any] else { return }
+ for key in hooks.keys {
+ if var matchers = hooks[key] as? [[String: Any]] {
+ matchers.removeAll { matcher in
+ (matcher["hooks"] as? [[String: Any]])?.contains {
+ ($0["command"] as? String)?.contains("coucou") == true ||
+ ($0["command"] as? String)?.contains("NotchBuddy") == true
+ } ?? false
}
if matchers.isEmpty { hooks.removeValue(forKey: key) }
else { hooks[key] = matchers }
@@ -532,6 +612,39 @@ final class HookServer: @unchecked Sendable {
let newData = try JSONSerialization.data(withJSONObject: settings, options: [.prettyPrinted, .sortedKeys])
try newData.write(to: settingsURL, options: .atomic)
}
+
+ private func buildHooksData(claudeURL: URL) throws -> Data {
+ let settingsURL = claudeURL.appendingPathComponent("settings.json")
+ var settings: [String: Any] = [:]
+ if let data = try? Data(contentsOf: settingsURL),
+ let parsed = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
+ settings = parsed
+ }
+ let hookPath = Self.hookScriptPath
+ let quotedCmd = "/bin/sh \"\(hookPath.replacingOccurrences(of: "\"", with: "\\\""))\""
+ let events: [(String, Int)] = [
+ ("SessionStart", 10), ("SessionEnd", 10),
+ ("UserPromptSubmit", 10),
+ ("PreToolUse", 10), ("PostToolUse", 10), ("PostToolUseFailure", 10),
+ ("PermissionRequest", 10),
+ ("Notification", 10),
+ ("Stop", 10), ("StopFailure", 10),
+ ("SubagentStart", 10), ("SubagentStop", 10),
+ ]
+ var hooks = settings["hooks"] as? [String: Any] ?? [:]
+ for (event, timeout) in events {
+ var existing = hooks[event] as? [[String: Any]] ?? []
+ existing.removeAll { ($0["hooks"] as? [[String: Any]])?.contains {
+ ($0["command"] as? String)?.contains("coucou") == true ||
+ ($0["command"] as? String)?.contains("NotchBuddy") == true
+ } ?? false }
+ existing.append(["hooks": [["type": "command", "command": quotedCmd, "timeout": timeout]]])
+ hooks[event] = existing
+ }
+ settings["hooks"] = hooks
+ return try JSONSerialization.data(withJSONObject: settings, options: [.prettyPrinted, .sortedKeys])
+ }
+ #endif
}
// MARK: - Notification names for hook server → controller communication
@@ -612,3 +725,72 @@ def main():
main()
sys.exit(0)
"""
+
+// MARK: - nb-hook script for App Store (socket in sandboxed container)
+
+private let nbHookScriptAppStore = """
+#!/usr/bin/env python3
+# nb-hook — Notch Buddy (App Store) hook relay for Claude Code
+import sys, json, os, socket
+
+def main():
+ try:
+ raw = sys.stdin.buffer.read()
+ if not raw:
+ return
+ payload = json.loads(raw)
+ except Exception:
+ return
+
+ env = os.environ
+ payload.setdefault('term_program', env.get('TERM_PROGRAM', ''))
+ payload.setdefault('iterm_session_id', env.get('ITERM_SESSION_ID', ''))
+ payload.setdefault('term_session_id', env.get('TERM_SESSION_ID', ''))
+ payload.setdefault('bundle_id', env.get('__CFBundleIdentifier', ''))
+ if 'cwd' not in payload or not payload['cwd']:
+ payload['cwd'] = os.getcwd()
+
+ event = payload.get('hook_event_name', '')
+ # App Store version: socket lives inside the sandboxed container
+ socket_path = os.path.expanduser(
+ '~/Library/Containers/fr.louisraille.Coucou/Data/Library/Application Support/NotchBuddy/nb.sock'
+ )
+
+ if event == 'PermissionRequest':
+ try:
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.settimeout(118)
+ s.connect(socket_path)
+ s.sendall((json.dumps(payload) + '\\n').encode())
+ chunks = []
+ while True:
+ chunk = s.recv(4096)
+ if not chunk:
+ break
+ chunks.append(chunk)
+ if b'\\n' in chunk:
+ break
+ s.close()
+ response = b''.join(chunks).decode().strip()
+ if response and 'permissionDecision' in response:
+ sys.stdout.write(response + '\\n')
+ sys.stdout.flush()
+ sys.exit(0)
+ except Exception:
+ pass
+ sys.stdout.write('{"permissionDecision":"deny"}\\n')
+ sys.stdout.flush()
+ sys.exit(0)
+
+ try:
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ s.settimeout(0.3)
+ s.connect(socket_path)
+ s.sendall((json.dumps(payload) + '\\n').encode())
+ s.close()
+ except Exception:
+ pass
+
+main()
+sys.exit(0)
+"""
diff --git a/NotchBuddy/Sources/App/IslandRootView.swift b/NotchBuddy/Sources/App/IslandRootView.swift
index a4dbdf9c..9de472e1 100644
--- a/NotchBuddy/Sources/App/IslandRootView.swift
+++ b/NotchBuddy/Sources/App/IslandRootView.swift
@@ -461,9 +461,11 @@ struct IslandHeader: View {
HStack(spacing: 5) {
TabButton(icon: "house.fill", view: .overview, state: state)
TabButton(icon: "bubble.left.fill", view: .prompt, state: state, preAction: {
+ #if !APPSTORE
if state.promptContext == nil {
state.promptContext = WindowContextCapture.captureActive(from: state.lastExternalApp)
}
+ #endif
})
TabButton(icon: "plus", view: .upload, state: state)
}
diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swift
index 1bd462f7..38010f75 100644
--- a/NotchBuddy/Sources/App/IslandViewContent.swift
+++ b/NotchBuddy/Sources/App/IslandViewContent.swift
@@ -146,6 +146,7 @@ struct OverviewView: View {
NSWorkspace.shared.open(url)
}
} else {
+ #if !APPSTORE
let terminalBundleIds = ["com.apple.Terminal", "com.googlecode.iterm2",
"net.kovidgoyal.kitty", "com.mitchellh.ghostty"]
if let hit = terminalBundleIds.compactMap({ id in
@@ -153,6 +154,7 @@ struct OverviewView: View {
}).first {
hit.activate(options: .activateIgnoringOtherApps)
}
+ #endif
}
}
}
@@ -287,6 +289,7 @@ struct FinishedView: View {
Text(state.focusTask?.steps.last ?? "Session finished")
.font(.system(size: 15, weight: .semibold))
HStack(spacing: 8) {
+ #if !APPSTORE
PrimaryButton("Open terminal") {
let terminalBundleIds = ["com.apple.Terminal", "com.googlecode.iterm2", "net.kovidgoyal.kitty", "com.mitchellh.ghostty"]
let activated = terminalBundleIds.compactMap { id in
@@ -297,6 +300,7 @@ struct FinishedView: View {
}
NotificationCenter.default.post(name: .islandCollapse, object: nil)
}
+ #endif
SecondaryButton("OK") {
NotificationCenter.default.post(name: .islandCollapse, object: nil)
}
@@ -604,7 +608,7 @@ struct MailView: View {
// API key set but no sender — guide user instead of silent fallback
statusMsg = "Set sender address in Settings."
} else {
- // No Resend — fallback to Apple Mail
+ // No Resend — fallback to Mail
sendViaAppleMail(to: to, subject: subj)
}
}
@@ -642,17 +646,31 @@ struct MailView: View {
}
private func sendViaAppleMail(to: String, subject: String) {
+ #if APPSTORE
+ // App Store: no AppleScript — use NSSharingService to compose (user sends manually)
+ guard let service = NSSharingService(named: .composeEmail) else {
+ statusMsg = "Mail not available."
+ return
+ }
+ var items: [Any] = [bodyText.isEmpty ? " " : bodyText]
+ if let url = state.droppedFile?.url,
+ FileManager.default.fileExists(atPath: url.path) {
+ items.append(url)
+ }
+ service.recipients = [to]
+ service.subject = subject
+ service.perform(withItems: items)
+ onSuccess(recipient: to)
+ #else
func asEscape(_ s: String) -> String {
s.replacingOccurrences(of: "\\", with: "\\\\")
.replacingOccurrences(of: "\"", with: "\\\"")
}
- // Build body as AppleScript expression so newlines survive string boundary
let bodyLines = bodyText.isEmpty ? [""] : bodyText.components(separatedBy: "\n")
let bodyExpr = bodyLines.map { "\"\(asEscape($0))\"" }.joined(separator: " & linefeed & ")
- + " & return & return" // trailing newlines ensure there's a paragraph to attach after
+ + " & return & return"
- // Verify file exists before referencing it
let attachBlock: String
if let url = state.droppedFile?.url,
FileManager.default.fileExists(atPath: url.path) {
@@ -678,6 +696,7 @@ struct MailView: View {
NSAppleScript(source: script)?.executeAndReturnError(&err)
if err == nil { onSuccess(recipient: to) }
else { statusMsg = "Mail error: \(err?["NSAppleScriptErrorMessage"] as? String ?? "unknown")" }
+ #endif
}
private func onSuccess(recipient: String) {
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index 64e26d11..a9e48ff4 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -419,12 +419,14 @@ final class IslandWindowController: NSWindowController {
self.attachDragStart = nil
self.state.stateOverride = nil
self.hideDragGhost()
+ #if !APPSTORE
if let ctx = self.windowContextAtPoint(mouse) {
self.state.promptContext = ctx
SoundEngine.shared.play("approve")
NotificationCenter.default.post(name: .triggerEmote, object: BotEmote.happy)
self.expand(to: .prompt)
}
+ #endif
}
}
NSEvent.addLocalMonitorForEvents(matching: .leftMouseUp) { [weak self] event in
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index ba2bd5c2..66244365 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -9,6 +9,9 @@ struct SettingsView: View {
@State private var statusMessage: String = ""
@State private var showDiff: Bool = false
@State private var pendingHookJSON: String = ""
+ #if APPSTORE
+ @State private var claudeAccessGranted: Bool = (UserDefaults.standard.data(forKey: "claudeDirectoryBookmark") != nil)
+ #endif
// Integration keys
@State private var resendKey: String = KeychainStore.shared.get("resend-api-key") ?? ""
@@ -60,18 +63,37 @@ struct SettingsView: View {
}
// MARK: Hooks
- GroupBox("Hooks Claude Code") {
+ GroupBox("Claude Code Hooks") {
VStack(alignment: .leading, spacing: 10) {
+ #if APPSTORE
+ if claudeAccessGranted {
+ Text("~/.claude/coucou/nb-hook")
+ .font(.system(size: 11, design: .monospaced))
+ .foregroundColor(.secondary)
+ HStack(spacing: 10) {
+ Button("Install hooks") { installHooksAppStore() }
+ .buttonStyle(.borderedProminent)
+ Button("Uninstall") { uninstallHooksAppStore() }
+ .buttonStyle(.bordered)
+ }
+ } else {
+ Text("Choose your ~/.claude folder so Coucou can add its hooks.")
+ .font(.system(size: 12))
+ .foregroundColor(.secondary)
+ Button("Choose .claude folder…") { chooseClaudeFolder() }
+ .buttonStyle(.borderedProminent)
+ }
+ #else
Text("nb-hook : \(HookServer.hookScriptPath)")
.font(.system(size: 11, design: .monospaced))
.foregroundColor(.secondary)
-
HStack(spacing: 10) {
Button("Install hooks") { installHooks() }
.buttonStyle(.borderedProminent)
Button("Uninstall") { uninstallHooks() }
.buttonStyle(.bordered)
}
+ #endif
if showDiff {
ScrollView {
@@ -84,8 +106,13 @@ struct SettingsView: View {
.cornerRadius(6)
HStack {
+ #if APPSTORE
+ Button("Confirm & write") { confirmInstallAppStore() }
+ .buttonStyle(.borderedProminent)
+ #else
Button("Confirm & write") { confirmInstall() }
.buttonStyle(.borderedProminent)
+ #endif
Button("Cancel") { showDiff = false; pendingHookJSON = "" }
.buttonStyle(.bordered)
}
@@ -326,6 +353,97 @@ struct SettingsView: View {
}
}
+ // MARK: - App Store: hooks via NSOpenPanel + security-scoped bookmark
+
+ #if APPSTORE
+ private func chooseClaudeFolder() {
+ let panel = NSOpenPanel()
+ panel.message = "Choose your .claude folder so Coucou can add its hooks"
+ panel.prompt = "Choose"
+ panel.canChooseFiles = false
+ panel.canChooseDirectories = true
+ panel.allowsMultipleSelection = false
+ panel.directoryURL = FileManager.default.homeDirectoryForCurrentUser
+ if panel.runModal() == .OK, let url = panel.url {
+ do {
+ let data = try url.bookmarkData(
+ options: .withSecurityScope,
+ includingResourceValuesForKeys: nil,
+ relativeTo: nil
+ )
+ UserDefaults.standard.set(data, forKey: "claudeDirectoryBookmark")
+ claudeAccessGranted = true
+ statusMessage = "✓ .claude folder access granted."
+ } catch {
+ statusMessage = "❌ Bookmark error: \(error.localizedDescription)"
+ }
+ }
+ }
+
+ private func resolveClaudeBookmark() -> URL? {
+ guard let data = UserDefaults.standard.data(forKey: "claudeDirectoryBookmark") else { return nil }
+ var isStale = false
+ guard let url = try? URL(resolvingBookmarkData: data,
+ options: .withSecurityScope,
+ relativeTo: nil,
+ bookmarkDataIsStale: &isStale) else { return nil }
+ if isStale {
+ // Re-prompt user if bookmark is stale
+ claudeAccessGranted = false
+ UserDefaults.standard.removeObject(forKey: "claudeDirectoryBookmark")
+ return nil
+ }
+ return url
+ }
+
+ private func installHooksAppStore() {
+ guard let claudeURL = resolveClaudeBookmark() else {
+ claudeAccessGranted = false
+ statusMessage = "❌ .claude folder access lost — choose the folder again."
+ return
+ }
+ do {
+ let accessing = claudeURL.startAccessingSecurityScopedResource()
+ defer { if accessing { claudeURL.stopAccessingSecurityScopedResource() } }
+ pendingHookJSON = try HookServer.shared.previewClaudeHooksAppStore(claudeURL: claudeURL)
+ showDiff = true
+ statusMessage = "Review the JSON below before confirming."
+ } catch {
+ statusMessage = "❌ \(error.localizedDescription)"
+ }
+ }
+
+ private func confirmInstallAppStore() {
+ guard let claudeURL = resolveClaudeBookmark() else {
+ claudeAccessGranted = false
+ statusMessage = "❌ .claude folder access lost."
+ return
+ }
+ do {
+ try HookServer.shared.writeClaudeHooksAppStore(claudeURL: claudeURL)
+ showDiff = false
+ statusMessage = "✓ Hooks installed in ~/.claude/settings.json"
+ pendingHookJSON = ""
+ } catch {
+ statusMessage = "❌ Write error: \(error.localizedDescription)"
+ }
+ }
+
+ private func uninstallHooksAppStore() {
+ guard let claudeURL = resolveClaudeBookmark() else {
+ claudeAccessGranted = false
+ statusMessage = "❌ .claude folder access lost."
+ return
+ }
+ do {
+ try HookServer.shared.uninstallClaudeHooksAppStore(claudeURL: claudeURL)
+ statusMessage = "✓ Hooks removed."
+ } catch {
+ statusMessage = "❌ \(error.localizedDescription)"
+ }
+ }
+ #endif
+
private func installHooks() {
do {
pendingHookJSON = try HookServer.shared.previewClaudeHooks()
diff --git a/NotchBuddy/Sources/App/WindowContextCapture.swift b/NotchBuddy/Sources/App/WindowContextCapture.swift
index 068a7b04..73bf4cbb 100644
--- a/NotchBuddy/Sources/App/WindowContextCapture.swift
+++ b/NotchBuddy/Sources/App/WindowContextCapture.swift
@@ -9,6 +9,10 @@ enum WindowContextCapture {
/// Uses AXUIElement for window title (requires Accessibility permission).
/// Uses AppleScript for browser URL (Safari, Chrome, Arc, Firefox, Edge).
static func captureActive(from app: NSRunningApplication? = NSWorkspace.shared.frontmostApplication) -> PromptContext? {
+ #if APPSTORE
+ // App Store: no Accessibility API, no screen capture
+ return nil
+ #else
guard let app, let appName = app.localizedName else { return nil }
let pid = app.processIdentifier
@@ -32,6 +36,7 @@ enum WindowContextCapture {
let url = browserURL(for: app)
return .window(appName: appName, title: title, url: url)
+ #endif
}
// MARK: - Private
@@ -50,10 +55,14 @@ enum WindowContextCapture {
]
private static func browserURL(for app: NSRunningApplication) -> String? {
+ #if APPSTORE
+ return nil // No AppleScript in App Store sandbox
+ #else
guard let bundleId = app.bundleIdentifier,
let script = browserScripts[bundleId] else { return nil }
var error: NSDictionary?
let result = NSAppleScript(source: script)?.executeAndReturnError(&error)
return error == nil ? result?.stringValue : nil
+ #endif
}
}
diff --git a/NotchBuddy/project.yml b/NotchBuddy/project.yml
index 78dba786..15d49dbb 100644
--- a/NotchBuddy/project.yml
+++ b/NotchBuddy/project.yml
@@ -58,3 +58,40 @@ targets:
ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon
MACOSX_DEPLOYMENT_TARGET: "15.0"
ENABLE_SANDBOX: NO
+
+ CoucouAppStore:
+ type: application
+ platform: macOS
+ sources:
+ - path: Sources
+ type: group
+ - path: Assets.xcassets
+ buildPhase: resources
+ - path: Resources/sounds
+ buildPhase: resources
+ type: folder
+ info:
+ path: Resources/InfoAppStore.plist
+ properties:
+ CFBundleName: Coucou
+ CFBundleDisplayName: Coucou
+ CFBundleIdentifier: fr.louisraille.Coucou
+ CFBundleVersion: "1"
+ CFBundleShortVersionString: "1.0"
+ CFBundlePackageType: APPL
+ LSUIElement: YES
+ NSHighResolutionCapable: YES
+ NSSupportsAutomaticGraphicsSwitching: YES
+ LSApplicationCategoryType: public.app-category.developer-tools
+ ITSAppUsesNonExemptEncryption: NO
+ settings:
+ base:
+ PRODUCT_BUNDLE_IDENTIFIER: fr.louisraille.Coucou
+ PRODUCT_NAME: Coucou
+ INFOPLIST_FILE: Resources/InfoAppStore.plist
+ ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon
+ MACOSX_DEPLOYMENT_TARGET: "15.0"
+ CODE_SIGN_STYLE: Automatic
+ CODE_SIGN_ENTITLEMENTS: Resources/CoucouAppStore.entitlements
+ DEVELOPMENT_TEAM: YOUR_TEAM_ID
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: APPSTORE