Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat: isolate development apps from production

leepokaia4fa3ac195c0
diff --git a/AGENTS.md b/AGENTS.md
index 3ae68449..fe594620 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -14,7 +14,7 @@
Run from the repository root unless a command changes directories:
- `xcodegen generate --spec apps/project.yml`: regenerate `apps/Codync.xcodeproj` after editing `apps/project.yml`; never edit `project.pbxproj` directly.
-- Use Xcode’s `iOS` scheme to run the iPhone app on a simulator or device.
+- Use Xcode’s `iOS Dev` scheme for development and `iOS` for production; see [Dev app isolation](docs/guides/dev-app.md).
- `cd apps/desktop && npm ci && npm run dev`: run the desktop app; `npm run typecheck && npm test` for its CI checks.
- `cd host && cargo build`: build the host; `cargo run -- serve` starts it in the foreground.
- `cd host && cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test`: run host CI checks.
@@ -24,7 +24,7 @@ Run from the repository root unless a command changes directories:
## Installing a new build: kill the old one first
-Always stop the old desktop app, host and iPhone process before running a new build (old host = old protocol, old app = old UI); commands in [docs/guides/development.md](docs/guides/development.md#apple-apps).
+Always stop the old desktop app, host and iPhone process for the variant being rebuilt before running a new build (old host = old protocol, old app = old UI); commands in [docs/guides/development.md](docs/guides/development.md#apple-apps).
Keep only the latest build: in this checkout, Apple builds go to `build/dd` only (no other `-derivedDataPath`, no copies in scratchpads, `/tmp` or Xcode's DerivedData); delete any older Codync build right away, so macOS never launches a stale copy. A git worktree may keep its own single build inside that worktree.
diff --git a/CLAUDE.md b/CLAUDE.md
index 5583ed52..2b7f7664 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -34,7 +34,7 @@ Bot-based remote for coding agents: persistent named bots on your computer, mess
- Remote access (Cloudflare relay primary, direct LAN/Tailscale alternative, accounts, SSH, public routine webhooks queued in the relay §7.8): [docs/reference/remote-relay.md](docs/reference/remote-relay.md).
- Remote screen (`host/src/screen/` is the reference): phones view/control the computer over WebRTC (hardware H.264, non-trickle SDP relayed by `screenOffer`, input on data channels `input` / `input-fast`); bots get the built-in `computer` MCP server (`codync-host mcp computer`, `host/src/mcp.rs`) when their `computer` flag is on; its tools run on the bundled cua-driver, which Codync Screen starts on macOS so its grants apply ([computer use](docs/features/computer-use.md)). Capture/input live in a helper on `~/.codync/screen.sock`: `apps/screen-macos` (macOS, launchd agent the desktop app registers via `SMAppService`, owns the TCC grants) or `apps/screen-linux` (`codync-screen`: portals + GStreamer, started by the host). On by default (Linux: only with a graphical session); `setScreenEnabled` is accepted only from loopback. An interactive phone takes over (bots may only look).
- Multiple computers per account are future work, not a current priority: the product targets one computer. The multi-computer structure (`AccountStore`, `BotReference`) stays because relay/accounts/SSH build on it; don't extend or polish multi-computer features unless asked.
-- Environments: **dev** (`dev-api.codync.dev`, Clerk development instance, Debug builds) and **main** (`api.codync.dev`, Clerk production, Release builds); `apps/shared/Config/<env>.plist` becomes the iOS `AccountConfig.plist` and the desktop `resources/account-config.json` (`tools/account-config.mjs`). Details: [spec §14.0](docs/reference/remote-relay.md).
+- Environments: `iOS Dev` / desktop `dist:*:dev` use the isolated Codync Dev app; `iOS` / `dist:*:main` retain production identities. Stop only the variant being rebuilt. Resource map, signing and diagnostics: [Dev app isolation](docs/guides/dev-app.md).
- Push: iOS registers its APNs token with `relay/` → gets an AES-GCM ticket → gives it (plus its X25519 push key) to the host; the host seals title/body to that key and a Notification Service Extension opens it, so `relay/` sees only generic text. Alert kinds: *needs you*, *done*, and *failed*, suppressed while the iOS app is connected. Delivery and lifecycle: [notification design](docs/design/push-and-live-activity.md).
- Voice call (iPhone, desktop): on-device speech (macOS desktop: the `codync-speech` helper), or OpenAI / Gemini realtime on the user's own key (kept in the host's vault, which mints per-call credentials; audio goes device ↔ provider); the host sees plain messages. Grok-style call bar: [docs/features/voice-call.md](docs/features/voice-call.md).
- Analytics: opt-in PostHog, asked once per device, feature use only (never content); host events come from `api::dispatch`: [docs/features/analytics.md](docs/features/analytics.md).
@@ -89,13 +89,7 @@ Build targets, folder layout, file naming and shared terms: [docs/architecture/f
## Commit messages
-- Conventional Commits: `type(scope): subject`. Types: `feat`, `fix`, `refactor`, `perf`, `docs`, `test`, `build`, `ci`, `chore`. Scope is the area touched: `ios`, `desktop`, `host`, `cloud`, `relay`, `web`, `docs`.
-- Subject: imperative mood ("add", not "added"), lowercase after the colon, no trailing period, at most 72 characters (aim for 50). Say what changes for the user, not which files moved.
-- Body (after a blank line, wrapped at 72 columns) when the change isn't obvious from the subject: what and why, not how. Bullets are fine.
-- One logical change per commit. Don't mix unrelated work, and stage only your own hunks when others have uncommitted changes in the tree.
-- Breaking changes: `!` after the type/scope, or a `BREAKING CHANGE:` footer.
-- English only.
-- PRs: fill the template's *What's New* bullets (zh-Hant + en-US) for user-visible iOS changes; they become the App Store notes when `apps/ios/WhatsNew.md` has no section for the release.
+Follow the Conventional Commit and PR rules in [AGENTS.md](AGENTS.md#commit--pull-request-guidelines); stage only your own changes.
## Keeping this file short
diff --git a/apps/Codync.xcodeproj/project.pbxproj b/apps/Codync.xcodeproj/project.pbxproj
index 6ef5d1e6..7fdf4821 100644
--- a/apps/Codync.xcodeproj/project.pbxproj
+++ b/apps/Codync.xcodeproj/project.pbxproj
@@ -117,6 +117,7 @@
305DDCC18BB8AA6CD9D19CEF /* WidgetPreviews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetPreviews.swift; sourceTree = "<group>"; };
31BFDAD6DCCE1CC98642ACDD /* AccountSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSession.swift; sourceTree = "<group>"; };
3F4C4D3B64C608AEF2F85F91 /* Kit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Kit; path = ios/Kit; sourceTree = SOURCE_ROOT; };
+ 445DB0A03CFBB5CC7A830139 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
4815867922559696EDCA47FD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4EB282B31FBC94EE70D07638 /* AccountSwitcherView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSwitcherView.swift; sourceTree = "<group>"; };
52A96030D47F1B9678095909 /* iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = iOS.entitlements; sourceTree = "<group>"; };
@@ -325,6 +326,7 @@
CE63C84233B14A2D63640EAA /* Capture.swift */,
8D16AD9979C77D976BC832D1 /* Driver.swift */,
8CC3E47D480A5F15CA95C504 /* HostLink.swift */,
+ 445DB0A03CFBB5CC7A830139 /* Info.plist */,
8BA06CEE98A7CDED62678522 /* Input.swift */,
28B2CB561A43ED9F2F1A4391 /* ScreenHelper.swift */,
F99C11684BFBEB49006600A9 /* Session.swift */,
@@ -590,7 +592,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "# Debug builds use dev (dev-api.codync.dev), Release builds use main (api.codync.dev).\ncp \"$SRCROOT/shared/Config/$CODYNC_ENV.plist\" \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/AccountConfig.plist\"\n";
+ shellScript = "# The scheme chooses an environment independently of Debug/Release optimization.\ncp \"$SRCROOT/shared/Config/$CODYNC_ENV.plist\" \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/AccountConfig.plist\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -670,6 +672,109 @@
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
+ 05067FF08AA4B445153FC8E5 /* DevDebug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_STYLE = Automatic;
+ CODYNC_APNS_ENVIRONMENT = sandbox;
+ CODYNC_APP_GROUP = group.com.pokai.Codync.dev;
+ CODYNC_APP_NAME = "Codync Dev";
+ CODYNC_DATA_FOLDER = ".codync-dev";
+ CODYNC_ENV = dev;
+ CODYNC_IOS_BUNDLE_ID = com.pokai.Codync.ios.dev;
+ CODYNC_KEYCHAIN_GROUP = com.pokai.Codync.dev;
+ CODYNC_SCREEN_BUNDLE_ID = com.pokai.Codync.dev.screen;
+ CODYNC_SCREEN_NAME = CodyncDevScreen;
+ CODYNC_URL_SCHEME = "codync-dev";
+ COPY_PHASE_STRIP = NO;
+ CURRENT_PROJECT_VERSION = 24;
+ DEAD_CODE_STRIPPING = YES;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ DEVELOPMENT_TEAM = 7FUM8A8H72;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ ENABLE_USER_SCRIPT_SANDBOXING = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "$(inherited)",
+ "DEBUG=1",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 18.0;
+ MACOSX_DEPLOYMENT_TARGET = 14.0;
+ MARKETING_VERSION = 2.11.2;
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_STRICT_CONCURRENCY = complete;
+ SWIFT_VERSION = 6.0;
+ };
+ name = DevDebug;
+ };
+ 0A80A3A954825D6FB822E4A6 /* DevDebug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ COMBINE_HIDPI_IMAGES = YES;
+ ENABLE_APP_SANDBOX = NO;
+ ENABLE_HARDENED_RUNTIME = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = "screen-macos/Info.plist";
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME) Screen";
+ INFOPLIST_KEY_LSUIElement = YES;
+ INFOPLIST_KEY_NSHumanReadableCopyright = "";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_SCREEN_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_SCREEN_NAME)";
+ SDKROOT = macosx;
+ SKIP_INSTALL = YES;
+ };
+ name = DevDebug;
+ };
0FE1E0F076B087CEBC2AD3BE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -704,7 +809,16 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
+ CODYNC_APNS_ENVIRONMENT = production;
+ CODYNC_APP_GROUP = group.com.pokai.Codync;
+ CODYNC_APP_NAME = Codync;
+ CODYNC_DATA_FOLDER = .codync;
CODYNC_ENV = main;
+ CODYNC_IOS_BUNDLE_ID = com.pokai.Codync.ios;
+ CODYNC_KEYCHAIN_GROUP = com.pokai.Codync;
+ CODYNC_SCREEN_BUNDLE_ID = com.pokai.Codync.screen;
+ CODYNC_SCREEN_NAME = CodyncScreen;
+ CODYNC_URL_SCHEME = codync;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 24;
DEAD_CODE_STRIPPING = YES;
@@ -734,6 +848,66 @@
};
name = Release;
};
+ 11BC91DD3F1932F31AB39498 /* DevDebug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_ENTITLEMENTS = ios/Widgets/Resources/Widgets.entitlements;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = ios/Widgets/Resources/Info.plist;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).LiveActivity";
+ PRODUCT_NAME = CodyncWidgets;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = DevDebug;
+ };
+ 2069ACA5FBBB95C57CA9AF2A /* DevRelease */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_ENTITLEMENTS = ios/Widgets/Resources/Widgets.entitlements;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = ios/Widgets/Resources/Info.plist;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).LiveActivity";
+ PRODUCT_NAME = CodyncWidgets;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = DevRelease;
+ };
+ 5BC265FBB8C161E9DF1D9399 /* DevDebug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_ENTITLEMENTS = ios/NotificationService/NotificationService.entitlements;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = ios/NotificationService/Info.plist;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).NotificationService";
+ PRODUCT_NAME = CodyncNotificationService;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = DevDebug;
+ };
6377E0B7DC2015DD92AB6550 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -742,15 +916,16 @@
ENABLE_APP_SANDBOX = NO;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
- INFOPLIST_KEY_CFBundleDisplayName = "Codync Screen";
+ INFOPLIST_FILE = "screen-macos/Info.plist";
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME) Screen";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.screen;
- PRODUCT_NAME = CodyncScreen;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_SCREEN_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_SCREEN_NAME)";
SDKROOT = macosx;
SKIP_INSTALL = YES;
};
@@ -762,13 +937,13 @@
CODE_SIGN_ENTITLEMENTS = ios/Widgets/Resources/Widgets.entitlements;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ios/Widgets/Resources/Info.plist;
- INFOPLIST_KEY_CFBundleDisplayName = Codync;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.ios.LiveActivity;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).LiveActivity";
PRODUCT_NAME = CodyncWidgets;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -782,13 +957,13 @@
CODE_SIGN_ENTITLEMENTS = ios/NotificationService/NotificationService.entitlements;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ios/NotificationService/Info.plist;
- INFOPLIST_KEY_CFBundleDisplayName = Codync;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.ios.NotificationService;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).NotificationService";
PRODUCT_NAME = CodyncNotificationService;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -804,20 +979,53 @@
ENABLE_APP_SANDBOX = NO;
ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES;
- INFOPLIST_KEY_CFBundleDisplayName = "Codync Screen";
+ INFOPLIST_FILE = "screen-macos/Info.plist";
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME) Screen";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.screen;
- PRODUCT_NAME = CodyncScreen;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_SCREEN_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_SCREEN_NAME)";
SDKROOT = macosx;
SKIP_INSTALL = YES;
};
name = Release;
};
+ 9284F9FFE5BA9F3EBA6F3086 /* DevRelease */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ CODE_SIGN_ENTITLEMENTS = ios/Resources/iOS.entitlements;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = ios/Resources/Info.plist;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
+ INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
+ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
+ INFOPLIST_KEY_NSCameraUsageDescription = "Scan the pairing code shown on your computer.";
+ INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Codync connects to the computer running your bots on your local network.";
+ INFOPLIST_KEY_NSMicrophoneUsageDescription = "Talk to your bots in a voice call.";
+ INFOPLIST_KEY_NSSpeechRecognitionUsageDescription = "Your words are transcribed on this iPhone and sent to your bot as a message.";
+ INFOPLIST_KEY_NSSupportsLiveActivities = YES;
+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_APP_NAME)";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = DevRelease;
+ };
A8BF4A3388AA1B9ECD65A197 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -852,7 +1060,16 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
- CODYNC_ENV = dev;
+ CODYNC_APNS_ENVIRONMENT = sandbox;
+ CODYNC_APP_GROUP = group.com.pokai.Codync;
+ CODYNC_APP_NAME = Codync;
+ CODYNC_DATA_FOLDER = .codync;
+ CODYNC_ENV = main;
+ CODYNC_IOS_BUNDLE_ID = com.pokai.Codync.ios;
+ CODYNC_KEYCHAIN_GROUP = com.pokai.Codync;
+ CODYNC_SCREEN_BUNDLE_ID = com.pokai.Codync.screen;
+ CODYNC_SCREEN_NAME = CodyncScreen;
+ CODYNC_URL_SCHEME = codync;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 24;
DEAD_CODE_STRIPPING = YES;
@@ -898,7 +1115,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ios/Resources/Info.plist;
- INFOPLIST_KEY_CFBundleDisplayName = Codync;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
INFOPLIST_KEY_NSCameraUsageDescription = "Scan the pairing code shown on your computer.";
@@ -914,26 +1131,142 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.ios;
- PRODUCT_NAME = Codync;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_APP_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
+ CC6EC33414AD65E072117755 /* DevRelease */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_ENTITLEMENTS = ios/NotificationService/NotificationService.entitlements;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = ios/NotificationService/Info.plist;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).NotificationService";
+ PRODUCT_NAME = CodyncNotificationService;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = DevRelease;
+ };
+ D2555C4A6D2F635EFD3EF91E /* DevRelease */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ COMBINE_HIDPI_IMAGES = YES;
+ ENABLE_APP_SANDBOX = NO;
+ ENABLE_HARDENED_RUNTIME = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = "screen-macos/Info.plist";
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME) Screen";
+ INFOPLIST_KEY_LSUIElement = YES;
+ INFOPLIST_KEY_NSHumanReadableCopyright = "";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_SCREEN_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_SCREEN_NAME)";
+ SDKROOT = macosx;
+ SKIP_INSTALL = YES;
+ };
+ name = DevRelease;
+ };
+ D332EFBFFE130E9B27B67337 /* DevRelease */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_STYLE = Automatic;
+ CODYNC_APNS_ENVIRONMENT = production;
+ CODYNC_APP_GROUP = group.com.pokai.Codync.dev;
+ CODYNC_APP_NAME = "Codync Dev";
+ CODYNC_DATA_FOLDER = ".codync-dev";
+ CODYNC_ENV = dev;
+ CODYNC_IOS_BUNDLE_ID = com.pokai.Codync.ios.dev;
+ CODYNC_KEYCHAIN_GROUP = com.pokai.Codync.dev;
+ CODYNC_SCREEN_BUNDLE_ID = com.pokai.Codync.dev.screen;
+ CODYNC_SCREEN_NAME = CodyncDevScreen;
+ CODYNC_URL_SCHEME = "codync-dev";
+ COPY_PHASE_STRIP = NO;
+ CURRENT_PROJECT_VERSION = 24;
+ DEAD_CODE_STRIPPING = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DEVELOPMENT_TEAM = 7FUM8A8H72;
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_USER_SCRIPT_SANDBOXING = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 18.0;
+ MACOSX_DEPLOYMENT_TARGET = 14.0;
+ MARKETING_VERSION = 2.11.2;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ MTL_FAST_MATH = YES;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_OPTIMIZATION_LEVEL = "-O";
+ SWIFT_STRICT_CONCURRENCY = complete;
+ SWIFT_VERSION = 6.0;
+ };
+ name = DevRelease;
+ };
D4128E0292901EF39924C449 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = ios/NotificationService/NotificationService.entitlements;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ios/NotificationService/Info.plist;
- INFOPLIST_KEY_CFBundleDisplayName = Codync;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.ios.NotificationService;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).NotificationService";
PRODUCT_NAME = CodyncNotificationService;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -950,7 +1283,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ios/Resources/Info.plist;
- INFOPLIST_KEY_CFBundleDisplayName = Codync;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
INFOPLIST_KEY_NSCameraUsageDescription = "Scan the pairing code shown on your computer.";
@@ -966,26 +1299,58 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.ios;
- PRODUCT_NAME = Codync;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_APP_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
+ E00ACB95077931E4BE46DB4C /* DevDebug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ CODE_SIGN_ENTITLEMENTS = ios/Resources/iOS.entitlements;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = ios/Resources/Info.plist;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
+ INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
+ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
+ INFOPLIST_KEY_NSCameraUsageDescription = "Scan the pairing code shown on your computer.";
+ INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Codync connects to the computer running your bots on your local network.";
+ INFOPLIST_KEY_NSMicrophoneUsageDescription = "Talk to your bots in a voice call.";
+ INFOPLIST_KEY_NSSpeechRecognitionUsageDescription = "Your words are transcribed on this iPhone and sent to your bot as a message.";
+ INFOPLIST_KEY_NSSupportsLiveActivities = YES;
+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID)";
+ PRODUCT_NAME = "$(CODYNC_APP_NAME)";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = DevDebug;
+ };
EB1D26BC053D93E98D308A5C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = ios/Widgets/Resources/Widgets.entitlements;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ios/Widgets/Resources/Info.plist;
- INFOPLIST_KEY_CFBundleDisplayName = Codync;
+ INFOPLIST_KEY_CFBundleDisplayName = "$(CODYNC_APP_NAME)";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
- PRODUCT_BUNDLE_IDENTIFIER = com.pokai.Codync.ios.LiveActivity;
+ PRODUCT_BUNDLE_IDENTIFIER = "$(CODYNC_IOS_BUNDLE_ID).LiveActivity";
PRODUCT_NAME = CodyncWidgets;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -1000,6 +1365,8 @@
isa = XCConfigurationList;
buildConfigurations = (
AA5DD179E0A7875E9EC22904 /* Debug */,
+ E00ACB95077931E4BE46DB4C /* DevDebug */,
+ 9284F9FFE5BA9F3EBA6F3086 /* DevRelease */,
D8FAD997F1279E25370608C5 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -1009,6 +1376,8 @@
isa = XCConfigurationList;
buildConfigurations = (
6A5CD5AB98E7B897A9E57C49 /* Debug */,
+ 11BC91DD3F1932F31AB39498 /* DevDebug */,
+ 2069ACA5FBBB95C57CA9AF2A /* DevRelease */,
EB1D26BC053D93E98D308A5C /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -1018,6 +1387,8 @@
isa = XCConfigurationList;
buildConfigurations = (
8B4776624C6CD584BCA689AF /* Debug */,
+ 5BC265FBB8C161E9DF1D9399 /* DevDebug */,
+ CC6EC33414AD65E072117755 /* DevRelease */,
D4128E0292901EF39924C449 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -1027,6 +1398,8 @@
isa = XCConfigurationList;
buildConfigurations = (
6377E0B7DC2015DD92AB6550 /* Debug */,
+ 0A80A3A954825D6FB822E4A6 /* DevDebug */,
+ D2555C4A6D2F635EFD3EF91E /* DevRelease */,
8BF1ED628DCBF23F16CFD028 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -1036,6 +1409,8 @@
isa = XCConfigurationList;
buildConfigurations = (
A8BF4A3388AA1B9ECD65A197 /* Debug */,
+ 05067FF08AA4B445153FC8E5 /* DevDebug */,
+ D332EFBFFE130E9B27B67337 /* DevRelease */,
0FE1E0F076B087CEBC2AD3BE /* Release */,
);
defaultConfigurationIsVisible = 0;
diff --git a/apps/Codync.xcodeproj/xcshareddata/xcschemes/Screen Dev.xcscheme b/apps/Codync.xcodeproj/xcshareddata/xcschemes/Screen Dev.xcscheme
new file mode 100644
index 00000000..759ccbf3
--- /dev/null
+++ b/apps/Codync.xcodeproj/xcshareddata/xcschemes/Screen Dev.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "1430"
+ version = "1.7">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES"
+ runPostActionsOnFailure = "NO">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ onlyGenerateCoverageForSpecifiedTargets = "NO">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <Testables>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "DevDebug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <CommandLineArguments>
+ </CommandLineArguments>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "DevRelease"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/apps/Codync.xcodeproj/xcshareddata/xcschemes/Screen.xcscheme b/apps/Codync.xcodeproj/xcshareddata/xcschemes/Screen.xcscheme
new file mode 100644
index 00000000..51b21bde
--- /dev/null
+++ b/apps/Codync.xcodeproj/xcshareddata/xcschemes/Screen.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "1430"
+ version = "1.7">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES"
+ runPostActionsOnFailure = "NO">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ onlyGenerateCoverageForSpecifiedTargets = "NO">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <Testables>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <CommandLineArguments>
+ </CommandLineArguments>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "907F1F4A709111FC7178EAE9"
+ BuildableName = "Screen.app"
+ BlueprintName = "Screen"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/apps/Codync.xcodeproj/xcshareddata/xcschemes/iOS Dev.xcscheme b/apps/Codync.xcodeproj/xcshareddata/xcschemes/iOS Dev.xcscheme
new file mode 100644
index 00000000..c1c7ef10
--- /dev/null
+++ b/apps/Codync.xcodeproj/xcshareddata/xcschemes/iOS Dev.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "1430"
+ version = "1.7">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES"
+ runPostActionsOnFailure = "NO">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ onlyGenerateCoverageForSpecifiedTargets = "NO">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <Testables>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "DevDebug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <CommandLineArguments>
+ </CommandLineArguments>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "DevRelease"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/apps/Codync.xcodeproj/xcshareddata/xcschemes/iOS.xcscheme b/apps/Codync.xcodeproj/xcshareddata/xcschemes/iOS.xcscheme
new file mode 100644
index 00000000..13adbb4c
--- /dev/null
+++ b/apps/Codync.xcodeproj/xcshareddata/xcschemes/iOS.xcscheme
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "1430"
+ version = "1.7">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES"
+ runPostActionsOnFailure = "NO">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ onlyGenerateCoverageForSpecifiedTargets = "NO">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <Testables>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <CommandLineArguments>
+ </CommandLineArguments>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable
+ runnableDebuggingMode = "0">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "913BDA9F79CE8C35A9E35830"
+ BuildableName = "iOS.app"
+ BlueprintName = "iOS"
+ ReferencedContainer = "container:Codync.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/apps/desktop/electron-builder.dev.yml b/apps/desktop/electron-builder.dev.yml
new file mode 100644
index 00000000..68fd7234
--- /dev/null
+++ b/apps/desktop/electron-builder.dev.yml
@@ -0,0 +1,45 @@
+# Overrides applied by tools/dev-builder.cjs (arrays replace, never merge).
+appId: com.pokai.Codync.dev
+productName: Codync Dev
+# Linux package managers and Windows installer caches also key on package.json's name.
+extraMetadata:
+ name: codync-desktop-dev
+ productName: Codync Dev
+ desktopName: codync-dev.desktop
+protocols:
+ - name: Codync Dev
+ schemes: [codync-dev, com.pokai.Codync.dev]
+publish: null
+mac:
+ signIgnore:
+ - CodyncDevScreen\.app/Contents/Helpers/cua-driver$
+ artifactName: codync-dev-macos.${ext}
+ notarize: false
+ extraFiles:
+ - from: build/native/CodyncDevScreen.app
+ to: Library/LoginItems/CodyncDevScreen.app
+ - from: resources/mac/com.pokai.Codync.dev.screen.plist
+ to: Library/LaunchAgents/com.pokai.Codync.dev.screen.plist
+dmg:
+ artifactName: codync-dev-macos.dmg
+linux:
+ executableName: codync-dev
+ artifactName: codync-dev-linux-${arch}.${ext}
+ desktop:
+ entry:
+ StartupWMClass: Codync Dev
+win:
+ artifactName: codync-dev-windows-x64.${ext}
+ extraResources:
+ - from: build/native/codync-host.exe
+ to: codync-host.exe
+ - from: build/native/codync-dev-hostw.exe
+ to: codync-dev-hostw.exe
+ - from: build/native/cua-driver.exe
+ to: cua-driver.exe
+ - from: build/native/cua-driver-uia.exe
+ to: cua-driver-uia.exe
+ - from: build/native/cua-driver.LICENSE
+ to: cua-driver.LICENSE
+ - from: resources/icon.png
+ to: icon.png
diff --git a/apps/desktop/electron-builder.yml b/apps/desktop/electron-builder.yml
index 6bbab8e3..0f64d6ff 100644
--- a/apps/desktop/electron-builder.yml
+++ b/apps/desktop/electron-builder.yml
@@ -5,6 +5,7 @@
# build/native/codync-speech macOS on-device speech helper
# build/native/CodyncScreen.app macOS screen helper (Xcode `Screen` target, with cua-driver inside)
# build/native/cua-driver.exe Windows: the computer-use driver and its UI Automation helper
+beforePack: tools/verify-build.cjs
appId: com.pokai.Codync
productName: Codync
copyright: ""
diff --git a/apps/desktop/package-lock.json b/apps/desktop/package-lock.json
index d8b20e97..79c48424 100644
--- a/apps/desktop/package-lock.json
+++ b/apps/desktop/package-lock.json
@@ -28,7 +28,8 @@
"react": "^19.3.0",
"react-dom": "^19.3.0",
"typescript": "^6.0.3",
- "vite": "^7.3.6"
+ "vite": "^7.3.6",
+ "yaml": "^2.9.1"
}
},
"node_modules/@babel/code-frame": {
@@ -6207,6 +6208,22 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/yaml": {
+ "version": "2.9.1",
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",
+ "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "yaml": "bin.mjs"
+ },
+ "engines": {
+ "node": ">= 14.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/eemeli"
+ }
+ },
"node_modules/yargs": {
"version": "17.7.3",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz",
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 3079165d..1f46fd57 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -18,11 +18,11 @@
"typecheck": "tsc --noEmit -p tsconfig.json",
"test": "node --test --experimental-strip-types src/shared/*.test.ts src/renderer/lib/*.test.ts src/renderer/views/thread/*.test.ts",
"icons": "swift tools/export-symbols.swift",
- "dist:mac:dev": "node tools/account-config.mjs dev && node tools/native-host.mjs dev && node tools/native-screen.mjs && electron-vite build && CSC_NAME=\"Pokai Lee (6KFK5J2LB4)\" electron-builder --mac",
- "dist:mac:main": "node tools/account-config.mjs main && node tools/native-host.mjs main && node tools/native-screen.mjs && electron-vite build && electron-builder --mac",
- "dist:linux:dev": "node tools/account-config.mjs dev && electron-vite build && electron-builder --linux",
+ "dist:mac:dev": "node tools/account-config.mjs dev && node tools/native-host.mjs dev && node tools/native-screen.mjs dev && electron-vite build && CSC_NAME=\"Pokai Lee (6KFK5J2LB4)\" electron-builder --mac --config tools/dev-builder.cjs",
+ "dist:mac:main": "node tools/account-config.mjs main && node tools/native-host.mjs main && node tools/native-screen.mjs main && electron-vite build && electron-builder --mac",
+ "dist:linux:dev": "node tools/account-config.mjs dev && electron-vite build && electron-builder --linux --config tools/dev-builder.cjs",
"dist:linux:main": "node tools/account-config.mjs main && electron-vite build && electron-builder --linux",
- "dist:win:dev": "node tools/account-config.mjs dev && node tools/native-host.mjs dev && electron-vite build && electron-builder --win",
+ "dist:win:dev": "node tools/account-config.mjs dev && node tools/native-host.mjs dev && electron-vite build && electron-builder --win --config tools/dev-builder.cjs",
"dist:win:main": "node tools/account-config.mjs main && node tools/native-host.mjs main && electron-vite build && electron-builder --win"
},
"devDependencies": {
@@ -42,7 +42,8 @@
"react": "^19.3.0",
"react-dom": "^19.3.0",
"typescript": "^6.0.3",
- "vite": "^7.3.6"
+ "vite": "^7.3.6",
+ "yaml": "^2.9.1"
},
"dependencies": {
"electron-updater": "^6.8.9"
diff --git a/apps/desktop/resources/mac/com.pokai.Codync.dev.screen.plist b/apps/desktop/resources/mac/com.pokai.Codync.dev.screen.plist
new file mode 100644
index 00000000..2b9dff91
--- /dev/null
+++ b/apps/desktop/resources/mac/com.pokai.Codync.dev.screen.plist
@@ -0,0 +1,22 @@
+<?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>Label</key>
+ <string>com.pokai.Codync.dev.screen</string>
+ <key>BundleProgram</key>
+ <string>Contents/Library/LoginItems/CodyncDevScreen.app/Contents/MacOS/CodyncDevScreen</string>
+ <key>AssociatedBundleIdentifiers</key>
+ <array>
+ <string>com.pokai.Codync.dev</string>
+ </array>
+ <key>RunAtLoad</key>
+ <true/>
+ <key>KeepAlive</key>
+ <true/>
+ <key>ProcessType</key>
+ <string>Interactive</string>
+ <key>LimitLoadToSessionType</key>
+ <string>Aqua</string>
+</dict>
+</plist>
diff --git a/apps/desktop/src/main/account.ts b/apps/desktop/src/main/account.ts
index fb58bd2d..f0825319 100644
--- a/apps/desktop/src/main/account.ts
+++ b/apps/desktop/src/main/account.ts
@@ -1,9 +1,10 @@
import { EventEmitter } from 'node:events'
-import { existsSync, promises as fs, readFileSync } from 'node:fs'
+import { promises as fs } from 'node:fs'
import { join } from 'node:path'
import { app, ipcMain, safeStorage, type BrowserWindow } from 'electron'
import type { AccountState } from '../shared/ipc'
import { authenticate } from './auth'
+import { buildConfig, identity } from './environment'
/**
* The Codync account through Clerk's Frontend API, the way ClerkKit drives it on the native
@@ -12,7 +13,7 @@ import { authenticate } from './auth'
* keychain. An account never grants access to a computer by itself (spec §4.2).
*/
-const SCHEME = 'com.pokai.Codync'
+const SCHEME = identity.appId
const REDIRECT = `${SCHEME}://callback`
interface Config {
@@ -20,30 +21,11 @@ interface Config {
cloudURL: string | null
}
-/** The build's account config (`tools/account-config.mjs`). */
-function configFile(): Partial<Config> & { environment?: string } {
- let file: Partial<Config> & { environment?: string } = {}
- const candidates = [
- app.isPackaged ? join(process.resourcesPath, 'account-config.json') : null,
- join(__dirname, '../../resources/account-config.json'),
- ]
- for (const path of candidates) {
- if (path && existsSync(path)) {
- try {
- file = JSON.parse(readFileSync(path, 'utf8')) as typeof file
- break
- } catch {}
- }
- }
- return file
-}
-
-/** Release builds are made for `main`; a `dev` build never replaces itself with one. */
-export const isMainEnvironment = () => configFile().environment === 'main'
+export const isMainEnvironment = () => identity.releaseUpdates
/** `CODYNC_CLERK_PUBLISHABLE_KEY` / `CODYNC_CLOUD_URL`, else the build's account config. */
function loadConfig(): Config {
- const file = configFile()
+ const file = buildConfig
const key = (process.env.CODYNC_CLERK_PUBLISHABLE_KEY ?? file.clerkPublishableKey ?? '').trim()
const cloud = (process.env.CODYNC_CLOUD_URL ?? file.cloudURL ?? '').trim()
return {
@@ -164,7 +146,7 @@ export class AccountService extends EventEmitter {
const url = new URL(`${this.base}${path}`)
url.searchParams.set('_is_native', 'true')
for (const [k, v] of Object.entries(query ?? {})) url.searchParams.set(k, v)
- const headers: Record<string, string> = { 'x-device-type': process.platform === 'darwin' ? 'macos' : process.platform, 'x-app-version': app.getVersion(), 'x-bundle-id': 'com.pokai.Codync' }
+ const headers: Record<string, string> = { 'x-device-type': process.platform === 'darwin' ? 'macos' : process.platform, 'x-app-version': app.getVersion(), 'x-bundle-id': identity.appId }
if (this.deviceToken) headers.Authorization = this.deviceToken
let payload: string | undefined
if (body) {
diff --git a/apps/desktop/src/main/auth.ts b/apps/desktop/src/main/auth.ts
index d5a3dff2..f77593a1 100644
--- a/apps/desktop/src/main/auth.ts
+++ b/apps/desktop/src/main/auth.ts
@@ -1,9 +1,10 @@
import { app, ipcMain, shell } from 'electron'
+import { identity } from './environment'
// Browser sign-ins that come back to this app on a custom scheme (ASWebAuthenticationSession's
// job on the native apps): connector OAuth (`codync://oauth`) and the account (`com.pokai.Codync://callback`).
-export const SCHEMES = ['codync', 'com.pokai.Codync']
+export const SCHEMES = [identity.scheme, identity.appId]
interface Pending {
scheme: string
diff --git a/apps/desktop/src/main/environment.ts b/apps/desktop/src/main/environment.ts
new file mode 100644
index 00000000..62239a3b
--- /dev/null
+++ b/apps/desktop/src/main/environment.ts
@@ -0,0 +1,23 @@
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { app } from 'electron'
+import { environmentProfile } from '../shared/environment'
+
+interface BuildConfig {
+ environment: 'main' | 'dev'
+ clerkPublishableKey: string | null
+ cloudURL: string | null
+}
+
+const path = app.isPackaged
+ ? join(process.resourcesPath, 'account-config.json')
+ : join(__dirname, '../../resources/account-config.json')
+export const buildConfig = JSON.parse(readFileSync(path, 'utf8')) as BuildConfig
+if (buildConfig.environment !== 'main' && buildConfig.environment !== 'dev') throw new Error('The app build environment is missing.')
+export const identity = environmentProfile(buildConfig.environment)
+
+// Before the single-instance lock, preferences, account restore or Chromium session is created.
+if (identity.environment === 'dev') {
+ app.setName(identity.name)
+ app.setPath('userData', join(app.getPath('appData'), identity.name))
+}
diff --git a/apps/desktop/src/main/host-controller.ts b/apps/desktop/src/main/host-controller.ts
index b9c62ae7..6d88e729 100644
--- a/apps/desktop/src/main/host-controller.ts
+++ b/apps/desktop/src/main/host-controller.ts
@@ -3,18 +3,24 @@ import { createHash } from 'node:crypto'
import { EventEmitter } from 'node:events'
import { existsSync, promises as fs, readFileSync, realpathSync } from 'node:fs'
import { homedir, platform } from 'node:os'
-import { join } from 'node:path'
+import { join, resolve } from 'node:path'
import { app } from 'electron'
import type { HostState, LocalHost } from '../shared/ipc'
import { unregisterScreenAgent } from './screen'
+import { identity } from './environment'
+import { hostEnvironmentError } from '../shared/environment'
/** `CODYNC_PORT` / `CODYNC_HOME` point the app at a dev host started with `codync-host serve`. */
export const devPort = process.env.CODYNC_PORT ? Number(process.env.CODYNC_PORT) : null
-export const port = devPort ?? 19222
-export const dataDir = process.env.CODYNC_HOME ?? join(homedir(), '.codync')
+export const port = devPort ?? identity.port
+export const dataDir = process.env.CODYNC_HOME ?? join(homedir(), identity.dataFolder)
+if (identity.environment === 'dev' && (port === 19222 || resolve(dataDir) === resolve(homedir(), '.codync'))) {
+ throw new Error('Codync Dev requires its own host port and data directory.')
+}
export const baseURL = `http://127.0.0.1:${port}`
interface Health {
+ environment?: string
ok?: boolean
computerId?: string
binaryPath?: string
@@ -52,11 +58,11 @@ function serviceDefinition(): string | null {
if (isWindows) {
// The per-user Run key that starts the host at sign-in.
const key = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
- return execFileSync('reg', ['query', key, '/v', 'CodyncHost'], { encoding: 'utf8', windowsHide: true })
+ return execFileSync('reg', ['query', key, '/v', identity.windowsService], { encoding: 'utf8', windowsHide: true })
}
const file = isMac
- ? join(homedir(), 'Library/LaunchAgents/com.pokai.codync.host.plist')
- : join(homedir(), '.config/systemd/user/codync-host.service')
+ ? join(homedir(), `Library/LaunchAgents/${identity.hostLabel}.plist`)
+ : join(homedir(), `.config/systemd/user/${identity.systemdUnit}`)
return readFileSync(file, 'utf8')
} catch {
return null
@@ -85,11 +91,17 @@ export class HostController extends EventEmitter {
app.isPackaged && isMac ? join(process.resourcesPath, 'codync-host') : null,
app.isPackaged && isWindows ? join(process.resourcesPath, 'codync-host.exe') : null,
process.env.CODYNC_HOST_BIN ?? null,
- join(homedir(), '.local/bin/codync-host'),
- '/opt/homebrew/bin/codync-host',
- '/usr/local/bin/codync-host',
- '/usr/bin/codync-host',
- join(homedir(), '.cargo/bin/codync-host'),
+ ...(identity.environment === 'dev' ? [
+ join(__dirname, '../../build/native/codync-host'),
+ join(__dirname, '../../../../host/target/debug/codync-host'),
+ join(homedir(), '.local/bin/codync-dev-host'),
+ ] : [
+ join(homedir(), '.local/bin/codync-host'),
+ '/opt/homebrew/bin/codync-host',
+ '/usr/local/bin/codync-host',
+ '/usr/bin/codync-host',
+ join(homedir(), '.cargo/bin/codync-host'),
+ ]),
]
return candidates.find((c): c is string => !!c && existsSync(c)) ?? null
}
@@ -131,15 +143,24 @@ export class HostController extends EventEmitter {
this.connect()
}
- /** `codync-host install` also routes Claude Code's status line through the host. */
+ private async verifyBinary(bin: string) {
+ const result = await run(bin, ['compat'])
+ if (result.status !== 0) throw new Error(result.output || 'Cannot verify the host environment.')
+ const info = JSON.parse(result.output) as { environment?: string }
+ const mismatch = hostEnvironmentError(identity.environment, info.environment)
+ if (mismatch) throw new Error(mismatch)
+ }
+
+ /** A service operation must never invoke the other environment's binary. */
async install() {
const bin = this.binary
- if (this.preparingForUpdate || this.installing || !bin) return
+ if (this.preparingForUpdate || this.installing || !bin || devPort !== null) return
this.installing = true
this.stopLoop()
prefs.set('hostUninstalled', false)
this.setState({ kind: 'starting' })
try {
+ await this.verifyBinary(bin)
const result = await run(bin, ['install', '--port', String(port)])
if (result.status !== 0) {
this.setState({ kind: 'failed', message: result.output || 'Install failed' })
@@ -147,6 +168,8 @@ export class HostController extends EventEmitter {
await sleep(1000)
this.connect()
}
+ } catch (error) {
+ this.setState({ kind: 'failed', message: error instanceof Error ? error.message : String(error) })
} finally {
this.installing = false
}
@@ -175,14 +198,22 @@ export class HostController extends EventEmitter {
return (await res.json()) as T
}
- async uninstall() {
+ async uninstall(): Promise<boolean> {
const bin = this.binary
- if (!bin) return
- this.stopLoop()
- prefs.set('hostUninstalled', true)
- await run(bin, ['uninstall'])
- this.setLocal(null)
- this.setState({ kind: 'notInstalled' })
+ if (!bin || devPort !== null) return false
+ try {
+ await this.verifyBinary(bin)
+ this.stopLoop()
+ const result = await run(bin, ['uninstall'])
+ if (result.status !== 0) throw new Error(result.output || 'Uninstall failed')
+ prefs.set('hostUninstalled', true)
+ this.setLocal(null)
+ this.setState({ kind: 'notInstalled' })
+ return true
+ } catch (error) {
+ this.setState({ kind: 'failed', message: error instanceof Error ? error.message : String(error) })
+ return false
+ }
}
/**
@@ -199,6 +230,7 @@ export class HostController extends EventEmitter {
unregisterScreenAgent()
const bin = this.binary
if (!bin) throw new Error('The bundled host is missing.')
+ await this.verifyBinary(bin)
const result = await run(bin, ['stop'])
if (result.status !== 0) throw new Error(result.output || 'The old host could not be stopped.')
}
@@ -252,9 +284,15 @@ export class HostController extends EventEmitter {
/** Attaches the local host once it answers, and again when its token or identity changed. */
private async attachLocal(): Promise<boolean> {
- const token = await readToken()
const health = await fetchHealth()
- if (!token || !health?.computerId) return false
+ if (!health?.computerId) return false
+ const mismatch = hostEnvironmentError(identity.environment, health.environment)
+ if (mismatch) {
+ this.setState({ kind: 'failed', message: mismatch })
+ return false
+ }
+ const token = await readToken()
+ if (!token) return false
if (devPort === null) {
// A rebuild can change the host without changing the release version.
const bin = this.binary
@@ -303,7 +341,7 @@ function serviceRuns(bin: string) {
const service = serviceDefinition()
if (service === null) return false
// Windows' service starts the launcher next to the host (codync-hostw.exe).
- const runs = (path: string) => service.includes(isWindows ? path.replace(/codync-host\.exe$/, 'codync-hostw.exe') : path)
+ const runs = (path: string) => service.includes(isWindows ? path.replace(/codync-host\.exe$/, identity.supervisor) : path)
return runs(bin) || runs(resolved(bin))
}
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index 384557c5..122a4fb9 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -1,3 +1,4 @@
+import { identity } from './environment'
import { execFileSync } from 'node:child_process'
import { hostname } from 'node:os'
import { join } from 'node:path'
@@ -62,7 +63,7 @@ function openChat() {
height: 760,
minWidth: 760,
minHeight: 500,
- title: 'Codync',
+ title: identity.name,
show: false,
backgroundColor: background(),
titleBarStyle: isMac ? 'hidden' : 'default',
@@ -135,6 +136,9 @@ function menu() {
function registerIPC(tray: Tray) {
registerHostProxy()
+ ipcMain.on('app:hostPort', (e) => (e.returnValue = identity.port))
+ ipcMain.on('app:name', (e) => (e.returnValue = identity.name))
+ ipcMain.on('app:scheme', (e) => (e.returnValue = identity.scheme))
ipcMain.on('app:version', (e) => (e.returnValue = app.getVersion()))
ipcMain.on('app:computerName', (e) => (e.returnValue = computerName()))
ipcMain.on('app:debugOpen', (e) => (e.returnValue = app.isPackaged ? null : (process.env.CODYNC_DEBUG_OPEN ?? null)))
@@ -180,7 +184,7 @@ function registerIPC(tray: Tray) {
const devices = await host.call<{ devices: { key: string }[] }>('devices').catch(() => ({ devices: [] }))
for (const device of devices.devices) await host.call('revokeDevice', { key: device.key }).catch(() => {})
await account.signOutAll()
- await host.uninstall()
+ if (!(await host.uninstall())) throw new Error('The host could not be safely uninstalled. Data was preserved.')
const { rm } = await import('node:fs/promises')
const { dataDir } = await import('./host-controller')
await rm(dataDir, { recursive: true, force: true })
diff --git a/apps/desktop/src/main/screen.ts b/apps/desktop/src/main/screen.ts
index 0b8f81e5..daf8af7a 100644
--- a/apps/desktop/src/main/screen.ts
+++ b/apps/desktop/src/main/screen.ts
@@ -2,17 +2,18 @@ import { statSync } from 'node:fs'
import { join } from 'node:path'
import { app, ipcMain } from 'electron'
import { prefs } from './host-controller'
+import { identity } from './environment'
// Codync Screen (capture + input for Remote screen): on macOS a launchd agent inside the app
// bundle (apps/screen-macos, registered through SMAppService), which owns the Screen Recording
// and Accessibility grants. Linux starts its helper from the host, so nothing happens here.
-const serviceName = 'com.pokai.Codync.screen.plist'
+const serviceName = `${identity.screenLabel}.plist`
const isMac = process.platform === 'darwin'
/** Identifies the helper binary inside this app: its path and modification date. */
function helperStamp() {
- const path = join(process.resourcesPath, '..', 'Library/LoginItems/CodyncScreen.app/Contents/MacOS/CodyncScreen')
+ const path = join(process.resourcesPath, '..', `Library/LoginItems/${identity.screenName}.app/Contents/MacOS/${identity.screenName}`)
try {
return `${path}@${statSync(path).mtimeMs}`
} catch {
diff --git a/apps/desktop/src/main/ssh-command.ts b/apps/desktop/src/main/ssh-command.ts
index 134b65f1..9f9c36ab 100644
--- a/apps/desktop/src/main/ssh-command.ts
+++ b/apps/desktop/src/main/ssh-command.ts
@@ -5,14 +5,20 @@ import type { SSHProfile } from '../shared/ssh.ts'
const REMOTE_PATH = '$PATH:/opt/homebrew/bin:/usr/local/bin:/home/linuxbrew/.linuxbrew/bin:$HOME/.local/bin:/Applications/Codync.app/Contents/Resources:/Applications/Codync.app/Contents/MacOS'
/** The caller validates the port before constructing the remote shell command. */
-export const remoteInfoCommand = (port: number) =>
- `sh -lc 'PATH="${REMOTE_PATH}" codync-host info --json --port ${port}'`
+export const remoteInfoCommand = (port: number, folder = '.codync') => {
+ // Only the fixed development folder is accepted; no arbitrary input enters this shell command.
+ const dev = folder === '.codync-dev'
+ if (dev) {
+ return `sh -lc 'export CODYNC_HOME="$HOME/.codync-dev"; if [ -x "/Applications/Codync Dev.app/Contents/Resources/codync-host" ]; then exec "/Applications/Codync Dev.app/Contents/Resources/codync-host" info --json --port ${port}; elif [ -x "$HOME/.local/bin/codync-dev-host" ]; then exec "$HOME/.local/bin/codync-dev-host" info --json --port ${port}; else exit 127; fi'`
+ }
+ return `sh -lc 'PATH="${REMOTE_PATH}" codync-host info --json --port ${port}'`
+}
-export const knownHostsFiles = (h: string) => [`${h}/.ssh/known_hosts`, `${h}/.codync/ssh_known_hosts`]
+export const knownHostsFiles = (h: string, folder = '.codync') => [`${h}/.ssh/known_hosts`, `${h}/${folder}/ssh_known_hosts`]
/** ssh's config tokenizer splits `UserKnownHostsFile` on spaces, so each path carries literal quotes. */
-export const hostKeyOptions = (h: string) => [
- '-o', 'UserKnownHostsFile=' + knownHostsFiles(h).map((f) => `"${f}"`).join(' '),
+export const hostKeyOptions = (h: string, folder = '.codync') => [
+ '-o', 'UserKnownHostsFile=' + knownHostsFiles(h, folder).map((f) => `"${f}"`).join(' '),
'-o', 'StrictHostKeyChecking=yes',
]
@@ -32,19 +38,19 @@ export function resolveArguments(p: SSHProfile) {
}
/** The remote command is fixed; only the validated port number goes into it. */
-export const infoArguments = (p: SSHProfile, h: string) => [
+export const infoArguments = (p: SSHProfile, h: string, folder = '.codync') => [
'-T', '-o', 'BatchMode=yes', '-o', 'ConnectTimeout=10', '-o', 'ForwardAgent=no', '-o', 'ForwardX11=no',
- ...hostKeyOptions(h), ...targetOptions(p),
- '--', p.host, remoteInfoCommand(p.remotePort),
+ ...hostKeyOptions(h, folder), ...targetOptions(p),
+ '--', p.host, remoteInfoCommand(p.remotePort, folder),
]
-export const tunnelArguments = (p: SSHProfile, localPort: number, h: string) => [
+export const tunnelArguments = (p: SSHProfile, localPort: number, h: string, folder = '.codync') => [
'-N', '-T', '-o', 'ExitOnForwardFailure=yes', '-o', 'ServerAliveInterval=15', '-o', 'ServerAliveCountMax=3',
// A shared master owns the listener and lets this child exit. The app must own
// its tunnel process to verify the listener and close the forward on disconnect.
'-S', 'none',
'-o', 'ForwardAgent=no', '-o', 'ForwardX11=no', '-o', 'BatchMode=yes',
- ...hostKeyOptions(h),
+ ...hostKeyOptions(h, folder),
'-L', `127.0.0.1:${localPort}:127.0.0.1:${p.remotePort}`,
...targetOptions(p), '--', p.host,
]
diff --git a/apps/desktop/src/main/ssh.ts b/apps/desktop/src/main/ssh.ts
index 4098e8d6..384c3cd1 100644
--- a/apps/desktop/src/main/ssh.ts
+++ b/apps/desktop/src/main/ssh.ts
@@ -1,3 +1,4 @@
+import { identity } from './environment'
import { spawn, type ChildProcess } from 'node:child_process'
import { createHash } from 'node:crypto'
import { existsSync, promises as fs, readFileSync, statSync } from 'node:fs'
@@ -133,7 +134,7 @@ function run(bin: string, args: string[], input?: string): Promise<Result> {
}
/** Tunnels a crashed or force-quit Codync left running: only Codync's tunnels carry this known_hosts file. */
-const killOrphanTunnels = () => run('/usr/bin/pkill', ['-f', '--', '^/usr/bin/ssh -N .*\\.codync/ssh_known_hosts'])
+const killOrphanTunnels = () => run('/usr/bin/pkill', ['-f', '--', `^/usr/bin/ssh -N .*\\${identity.dataFolder}/ssh_known_hosts`])
/** Binds port 0 on loopback to learn a free port. */
function freeLocalPort(): Promise<number | null> {
@@ -301,7 +302,7 @@ class SSHComputers {
const lines = this.pendingKeys.get(id)
if (this.status.get(id)?.kind !== 'confirmHostKey' || !lines) return
try {
- const dir = join(home, '.codync')
+ const dir = join(home, identity.dataFolder)
await fs.mkdir(dir, { recursive: true, mode: 0o700 })
await fs.appendFile(join(dir, 'ssh_known_hosts'), lines.join('\n') + '\n', { mode: 0o600 })
} catch (e) {
@@ -369,7 +370,7 @@ class SSHComputers {
}
this.setStatus(id, { kind: 'connecting', step: 'Signing in…' })
- const result = await run(SSH, infoArguments(profile, home))
+ const result = await run(SSH, infoArguments(profile, home, identity.dataFolder))
if (token.cancelled) return idle
if (result.status === 255) {
if (authRefused(result.stderr)) return stop({ kind: 'failed', message: signInRefused(profile) })
@@ -458,7 +459,7 @@ class SSHComputers {
private async recordedKeys(name: string, certAuthorities = true) {
const keys = new Set<string>()
- for (const file of knownHostsFiles(home)) {
+ for (const file of knownHostsFiles(home, identity.dataFolder)) {
if (!existsSync(file)) continue
const found = await run(KEYGEN, ['-F', name, '-f', file])
if (found.status === 0) for (const k of hostKeys(found.stdout, certAuthorities)) keys.add(k)
@@ -472,7 +473,7 @@ class SSHComputers {
let done = false
let child: ChildProcess
try {
- child = spawn(SSH, tunnelArguments(profile, localPort, home), { stdio: ['ignore', 'ignore', 'pipe'] })
+ child = spawn(SSH, tunnelArguments(profile, localPort, home, identity.dataFolder), { stdio: ['ignore', 'ignore', 'pipe'] })
} catch {
return null
}
diff --git a/apps/desktop/src/main/tray.ts b/apps/desktop/src/main/tray.ts
index 5bc4172d..252bc15d 100644
--- a/apps/desktop/src/main/tray.ts
+++ b/apps/desktop/src/main/tray.ts
@@ -4,6 +4,7 @@ import type { TraySummary, WindowCommand } from '../shared/ipc'
import type { HostController } from './host-controller'
import type { Updates } from './updates'
import { setShowInDock, showInDock } from './dock'
+import { identity } from './environment'
interface Deps {
openChat: () => unknown
@@ -24,7 +25,7 @@ export class Tray {
constructor(private deps: Deps) {
this.tray = new ElectronTray(this.icon(false))
- this.tray.setToolTip('Codync')
+ this.tray.setToolTip(app.getName())
// Windows opens a tray icon's menu on right-click; a left-click opens the chat.
if (process.platform === 'win32') this.tray.on('click', () => this.deps.openChat())
this.rebuild()
@@ -69,7 +70,7 @@ export class Tray {
: state.kind === 'failed' ? 'Host problem'
: (s?.status ?? 'Connected')
items.push({ label: status, enabled: false })
- items.push({ label: 'Open Codync', accelerator: 'CmdOrCtrl+O', click: () => this.deps.openChat() })
+ items.push({ label: `Open ${app.getName()}`, accelerator: 'CmdOrCtrl+O', click: () => this.deps.openChat() })
if (state.kind === 'running') {
items.push({ label: 'Pair iPhone…', enabled: s?.canPair ?? false, click: () => this.deps.openPairing() })
}
@@ -77,6 +78,10 @@ export class Tray {
switch (state.kind) {
case 'missingBinary':
+ if (identity.environment === 'dev') {
+ items.push({ label: 'Rebuild Codync Dev with its development host.', enabled: false })
+ break
+ }
items.push({ label: 'Reinstall Codync or install the host with Homebrew.', enabled: false })
items.push({ label: 'Copy host install command', click: () => clipboard.writeText('brew install leepokai/codync/codync-host') })
break
@@ -128,7 +133,7 @@ export class Tray {
items.push({ type: 'separator' })
items.push({ label: 'Settings', submenu: this.settingsMenu() })
if (s?.version) items.push({ label: `Version ${s.version}`, enabled: false })
- items.push({ label: 'Quit Codync', accelerator: 'CmdOrCtrl+Q', click: () => app.quit() })
+ items.push({ label: `Quit ${app.getName()}`, accelerator: 'CmdOrCtrl+Q', click: () => app.quit() })
this.tray.setContextMenu(Menu.buildFromTemplate(items))
}
@@ -144,7 +149,7 @@ export class Tray {
]
if (screen.enabled) {
if (screen.needsLoginItem) {
- items.push({ label: 'Allow Codync Screen in Login Items…', click: () => void shell.openExternal('x-apple.systempreferences:com.apple.LoginItems-Settings.extension') })
+ items.push({ label: `Allow ${app.getName()} Screen in Login Items…`, click: () => void shell.openExternal('x-apple.systempreferences:com.apple.LoginItems-Settings.extension') })
} else {
if (screen.needsCapture) items.push({ label: 'Allow Screen Recording…', click: () => void shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture') })
if (screen.needsInput) items.push({ label: 'Allow Accessibility…', click: () => void shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility') })
diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.ts
index c6fc20c1..00515898 100644
--- a/apps/desktop/src/preload/index.ts
+++ b/apps/desktop/src/preload/index.ts
@@ -20,6 +20,9 @@ function listen<T>(channel: string, cb: (value: T) => void) {
const bridge: CodyncBridge = {
platform: process.platform as CodyncBridge['platform'],
+ appName: ipcRenderer.sendSync('app:name') as string,
+ appScheme: ipcRenderer.sendSync('app:scheme') as string,
+ hostPort: ipcRenderer.sendSync('app:hostPort') as number,
appVersion: ipcRenderer.sendSync('app:version') as string,
computerName: ipcRenderer.sendSync('app:computerName') as string,
debugOpen: ipcRenderer.sendSync('app:debugOpen') as string | null,
diff --git a/apps/desktop/src/renderer/demo/bridge.ts b/apps/desktop/src/renderer/demo/bridge.ts
index fbba80bc..0778627f 100644
--- a/apps/desktop/src/renderer/demo/bridge.ts
+++ b/apps/desktop/src/renderer/demo/bridge.ts
@@ -24,6 +24,9 @@ const updates: UpdateState = {
const bridge: CodyncBridge = {
platform: 'darwin',
+ appName: 'Codync',
+ appScheme: 'codync',
+ hostPort: 19222,
appVersion: version,
computerName: HOST_NAME,
// Opens the group at launch, like the website's screenshot.
diff --git a/apps/desktop/src/renderer/main.tsx b/apps/desktop/src/renderer/main.tsx
index 56246990..66b80a7f 100644
--- a/apps/desktop/src/renderer/main.tsx
+++ b/apps/desktop/src/renderer/main.tsx
@@ -8,6 +8,7 @@ import { applyTextSize, prefs } from './lib/prefs'
import { account } from './store/account'
const page = new URLSearchParams(location.search).get('window') ?? 'chat'
+document.title = window.codync.appName
document.documentElement.dataset.platform = window.codync.platform
applyTextSize(prefs.textSize.get())
diff --git a/apps/desktop/src/renderer/views/HostStateView.tsx b/apps/desktop/src/renderer/views/HostStateView.tsx
index 8e15bc68..a0c6cf2d 100644
--- a/apps/desktop/src/renderer/views/HostStateView.tsx
+++ b/apps/desktop/src/renderer/views/HostStateView.tsx
@@ -13,7 +13,7 @@ export function HostStateView({ compact = false }: { compact?: boolean }) {
case 'notInstalled':
return <EmptyState compact={compact} icon="desktopcomputer" title={`Set up this ${isMac ? 'Mac' : 'computer'}`} message={`Codync runs your coding agents through the host, a small background service on this ${isMac ? 'Mac' : 'computer'}.`} action={['Install host', () => window.codync.host.install()]} />
case 'missingBinary':
- return <EmptyState compact={compact} icon="desktopcomputer.trianglebadge.exclamationmark" title="The host is missing" message="This copy of Codync doesn't include codync-host. Download Codync again from codync.dev or GitHub." />
+ return <EmptyState compact={compact} icon="desktopcomputer.trianglebadge.exclamationmark" title="The host is missing" message={window.codync.appScheme === 'codync-dev' ? 'Rebuild Codync Dev with its development host, then open it again.' : "This copy of Codync doesn't include codync-host. Download Codync again from codync.dev or GitHub."} />
case 'failed':
return <EmptyState compact={compact} icon="desktopcomputer.trianglebadge.exclamationmark" title="The host isn't running" message={state.message} action={['Try again', () => window.codync.host.restart()]} />
default:
diff --git a/apps/desktop/src/renderer/views/marketplace/plugins.ts b/apps/desktop/src/renderer/views/marketplace/plugins.ts
index 6f4e9167..2448ca15 100644
--- a/apps/desktop/src/renderer/views/marketplace/plugins.ts
+++ b/apps/desktop/src/renderer/views/marketplace/plugins.ts
@@ -84,7 +84,7 @@ export class Plugins extends Observable {
}
let back: string
try {
- back = await window.codync.app.authenticate(plan.url, 'codync')
+ back = await window.codync.app.authenticate(plan.url, window.codync.appScheme)
} catch {
return
}
diff --git a/apps/desktop/src/renderer/views/settings/ComputersView.tsx b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
index d5640ddd..49d90c65 100644
--- a/apps/desktop/src/renderer/views/settings/ComputersView.tsx
+++ b/apps/desktop/src/renderer/views/settings/ComputersView.tsx
@@ -40,7 +40,7 @@ export function ComputersView() {
<div>
<SectionHeader title="Over SSH">
- {sshBridge() ? <IconButton title="Add SSH computer" icon="plus" onClick={() => setEditing({ profile: newSSHProfile(), isNew: true })} /> : null}
+ {sshBridge() ? <IconButton title="Add SSH computer" icon="plus" onClick={() => setEditing({ profile: newSSHProfile(window.codync.hostPort), isNew: true })} /> : null}
</SectionHeader>
<Reveal show={sshState.state.profiles.length === 0}>
<div style={{ ...font('callout'), color: 'var(--secondary)' }}>
diff --git a/apps/desktop/src/renderer/views/settings/SSHRow.tsx b/apps/desktop/src/renderer/views/settings/SSHRow.tsx
index 83258f6d..87a30c11 100644
--- a/apps/desktop/src/renderer/views/settings/SSHRow.tsx
+++ b/apps/desktop/src/renderer/views/settings/SSHRow.tsx
@@ -8,6 +8,7 @@ import { sshBridge } from './ssh-model'
export function SSHRow({ profile, status, edit, attached = true }: { profile: SSHProfile; status: SSHStatus; attached?: boolean; edit: () => void }) {
const bridge = sshBridge()
+ const dev = window.codync.appScheme === 'codync-dev'
const target = `${profile.user ? `${profile.user}@` : ''}${profile.host}${profile.port !== null ? `:${profile.port}` : ''}`
const line = (() => {
switch (status.kind) {
@@ -24,7 +25,7 @@ export function SSHRow({ profile, status, edit, attached = true }: { profile: SS
case 'failed':
return status.message
case 'notInstalled':
- return `codync-host isn't installed on ${profile.host}. Install it there:`
+ return dev ? `Install Codync Dev on ${profile.host} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.` : `codync-host isn't installed on ${profile.host}. Install it there:`
}
})()
const problem = status.kind === 'retrying' || status.kind === 'failed' || status.kind === 'notInstalled'
@@ -64,7 +65,7 @@ export function SSHRow({ profile, status, edit, attached = true }: { profile: SS
</div>
) : null}
</Reveal>
- <Reveal show={status.kind === 'notInstalled'}>
+ <Reveal show={status.kind === 'notInstalled' && !dev}>
<div className="settings-row" style={{ gap: 6 }}>
<span className="settings-code selectable">{SSH_INSTALL_COMMAND}</span>
<IconButton title="Copy install command" icon="doc.on.doc" onClick={() => window.codync.app.copy(SSH_INSTALL_COMMAND)} />
diff --git a/apps/desktop/src/shared/environment.test.ts b/apps/desktop/src/shared/environment.test.ts
new file mode 100644
index 00000000..8b37f557
--- /dev/null
+++ b/apps/desktop/src/shared/environment.test.ts
@@ -0,0 +1,24 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { environmentProfile, hostEnvironmentError } from './environment.ts'
+
+test('development installations cannot share production resources or update feed', () => {
+ const prod = environmentProfile('main')
+ const dev = environmentProfile('dev')
+ assert.equal(prod.appId, 'com.pokai.Codync')
+ assert.equal(prod.port, 19222)
+ assert.equal(prod.dataFolder, '.codync')
+ assert.equal(prod.hostLabel, 'com.pokai.codync.host')
+ assert.equal(prod.supervisor, 'codync-hostw.exe')
+ for (const key of Object.keys(prod) as (keyof typeof prod)[]) assert.notEqual(dev[key], prod[key], key)
+ assert.equal(dev.releaseUpdates, false)
+})
+
+test('a development app rejects production and old unidentified hosts', () => {
+ assert.equal(hostEnvironmentError('main', undefined), null)
+ assert.equal(hostEnvironmentError('main', 'main'), null)
+ assert.equal(hostEnvironmentError('dev', 'dev'), null)
+ assert.ok(hostEnvironmentError('dev', undefined))
+ assert.ok(hostEnvironmentError('dev', 'main'))
+ assert.ok(hostEnvironmentError('main', 'dev'))
+})
diff --git a/apps/desktop/src/shared/environment.ts b/apps/desktop/src/shared/environment.ts
new file mode 100644
index 00000000..f24275c1
--- /dev/null
+++ b/apps/desktop/src/shared/environment.ts
@@ -0,0 +1,25 @@
+/** Installed identities. Production values stay unchanged when adding Codync Dev. */
+export function environmentProfile(environment: 'main' | 'dev') {
+ const dev = environment === 'dev'
+ return {
+ environment,
+ name: dev ? 'Codync Dev' : 'Codync',
+ appId: dev ? 'com.pokai.Codync.dev' : 'com.pokai.Codync',
+ scheme: dev ? 'codync-dev' : 'codync',
+ dataFolder: dev ? '.codync-dev' : '.codync',
+ port: dev ? 19223 : 19222,
+ hostLabel: dev ? 'com.pokai.codync.dev.host' : 'com.pokai.codync.host',
+ systemdUnit: dev ? 'codync-dev-host.service' : 'codync-host.service',
+ windowsService: dev ? 'CodyncDevHost' : 'CodyncHost',
+ supervisor: dev ? 'codync-dev-hostw.exe' : 'codync-hostw.exe',
+ screenLabel: dev ? 'com.pokai.Codync.dev.screen' : 'com.pokai.Codync.screen',
+ screenName: dev ? 'CodyncDevScreen' : 'CodyncScreen',
+ releaseUpdates: !dev,
+ }
+}
+
+/** Refuse to manage a different environment's daemon, including pre-isolation dev hosts. */
+export function hostEnvironmentError(expected: 'main' | 'dev', actual?: string): string | null {
+ if (actual === expected || (expected === 'main' && actual === undefined)) return null
+ return `This ${expected === 'dev' ? 'Codync Dev' : 'Codync'} app found a host from ${actual ?? 'an unidentified environment'}. Start the matching host on its own port.`
+}
diff --git a/apps/desktop/src/shared/host-update.test.ts b/apps/desktop/src/shared/host-update.test.ts
index cbdcc4ba..9783269c 100644
--- a/apps/desktop/src/shared/host-update.test.ts
+++ b/apps/desktop/src/shared/host-update.test.ts
@@ -48,6 +48,7 @@ test('failed stop reports the error and cancellation reinstalls the service once
await assert.rejects(f.host.prepareForUpdate(), /service command failed/)
f.host.resumeAfterCancelledUpdate()
f.host.resumeAfterCancelledUpdate()
+ await settle()
assert.deepEqual(f.calls, [['stop'], ['install', '--port', '19222']])
await f.tick(1000)
})
@@ -103,3 +104,24 @@ test('idle detection distinguishes working, offline and idle hosts', async () =>
f.behavior.reachable = false
assert.equal(await f.host.isIdleForUpdate(), false)
})
+
+
+test('development install and stop reject a production binary before touching its service', async () => {
+ const f = hostUpdateFixture({ environment: 'dev' })
+ f.behavior.binaryEnvironment = 'main'
+ await f.host.install()
+ assert.equal(f.host.state.kind, 'failed')
+ assert.deepEqual(f.calls, [])
+ assert.equal(await f.host.uninstall(), false)
+ assert.deepEqual(f.calls, [])
+})
+
+test('development service installs on its own port', async () => {
+ const f = hostUpdateFixture({ environment: 'dev' })
+ const installing = f.host.install()
+ await settle()
+ assert.deepEqual(f.calls, [['install', '--port', '19223']])
+ await f.tick(1000)
+ await installing
+ assert.equal(f.host.state.kind, 'running')
+})
diff --git a/apps/desktop/src/shared/ipc.ts b/apps/desktop/src/shared/ipc.ts
index 68daea65..ff90f7d9 100644
--- a/apps/desktop/src/shared/ipc.ts
+++ b/apps/desktop/src/shared/ipc.ts
@@ -102,6 +102,9 @@ export type SpeechEvent =
export interface CodyncBridge {
platform: 'darwin' | 'linux' | 'win32'
+ appName: string
+ appScheme: string
+ hostPort: number
appVersion: string
/** The computer's name ("Kevin's MacBook Pro"). */
computerName: string
diff --git a/apps/desktop/src/shared/packaging.test.ts b/apps/desktop/src/shared/packaging.test.ts
new file mode 100644
index 00000000..a99e5f7b
--- /dev/null
+++ b/apps/desktop/src/shared/packaging.test.ts
@@ -0,0 +1,37 @@
+import assert from 'node:assert/strict'
+import { createRequire } from 'node:module'
+import { readFileSync } from 'node:fs'
+import { test } from 'node:test'
+const require = createRequire(import.meta.url)
+const dev = require('../../tools/dev-builder.cjs')
+const { AppInfo } = require('app-builder-lib/out/appInfo')
+const { getWindowsInstallationDirName, getWindowsInstallationAppPackageName } = require('app-builder-lib/out/targets/targetUtil')
+const { parse } = require('yaml')
+const prod = parse(readFileSync(new URL('../../electron-builder.yml', import.meta.url), 'utf8'))
+const metadata = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'))
+
+test('Linux packages and Windows installation resources have separate development names', () => {
+ const mainInfo = new AppInfo({ config: prod, metadata })
+ const devInfo = new AppInfo({ config: dev, metadata: { ...metadata, ...dev.extraMetadata } })
+ assert.equal(mainInfo.linuxPackageName, 'codync-desktop')
+ assert.equal(devInfo.linuxPackageName, 'codync-desktop-dev')
+ assert.notEqual(devInfo.updaterCacheDirName, mainInfo.updaterCacheDirName)
+ assert.notEqual(getWindowsInstallationDirName(devInfo, true), getWindowsInstallationDirName(mainInfo, true))
+ assert.notEqual(getWindowsInstallationAppPackageName(devInfo.name), getWindowsInstallationAppPackageName(mainInfo.name))
+ assert.equal(dev.extraMetadata.desktopName, 'codync-dev.desktop')
+})
+
+test('development packaging registers only development callbacks and background helpers', () => {
+ assert.equal(dev.appId, 'com.pokai.Codync.dev')
+ assert.equal(dev.productName, 'Codync Dev')
+ assert.equal(dev.publish, null)
+ assert.ok(new RegExp(dev.mac.signIgnore[0]).test('CodyncDevScreen.app/Contents/Helpers/cua-driver'))
+ assert.deepEqual(dev.protocols.flatMap((p: { schemes: string[] }) => p.schemes), ['codync-dev', 'com.pokai.Codync.dev'])
+ assert.deepEqual(dev.mac.extraFiles.map((f: { to: string }) => f.to), [
+ 'Library/LoginItems/CodyncDevScreen.app',
+ 'Library/LaunchAgents/com.pokai.Codync.dev.screen.plist',
+ ])
+ assert.ok(dev.win.extraResources.some((f: { to: string }) => f.to === 'codync-dev-hostw.exe'))
+ assert.ok(!dev.win.extraResources.some((f: { to: string }) => f.to === 'codync-hostw.exe'))
+ assert.equal(dev.linux.executableName, 'codync-dev')
+})
diff --git a/apps/desktop/src/shared/ssh-command.test.ts b/apps/desktop/src/shared/ssh-command.test.ts
index 953dde0d..111e65f3 100644
--- a/apps/desktop/src/shared/ssh-command.test.ts
+++ b/apps/desktop/src/shared/ssh-command.test.ts
@@ -60,6 +60,35 @@ test('SSH reports command not found when no installation is reachable', { skip:
assert.equal(probe([]).status, 127)
})
+for (const installed of ['mac', 'linux', 'production-only'] as const) {
+ test(`development SSH uses only its own host with ${installed} installed`, { skip: process.platform === 'win32' }, () => {
+ const root = mkdtempSync(join(tmpdir(), 'codync-dev-ssh-'))
+ try {
+ const home = join(root, 'user home')
+ const mac = join(root, 'Applications/Codync Dev.app/Contents/Resources/codync-host')
+ const linux = join(home, '.local/bin/codync-dev-host')
+ const prod = join(home, '.local/bin/codync-host')
+ for (const bin of [prod, ...(installed === 'mac' ? [mac] : installed === 'linux' ? [linux] : [])]) {
+ mkdirSync(join(bin, '..'), { recursive: true })
+ writeFileSync(bin, '#!/bin/sh\nprintf "%s\\n" "$0" "$CODYNC_HOME" "$@"\n')
+ chmodSync(bin, 0o755)
+ }
+ const command = remoteInfoCommand(19223, '.codync-dev')
+ .replace(/^sh -lc '/, '').replace(/'$/, '')
+ .replaceAll('/Applications/', `${root}/Applications/`)
+ const result = spawnSync('/bin/sh', ['-c', command], {
+ encoding: 'utf8', env: { HOME: home, PATH: join(home, '.local/bin') },
+ })
+ assert.equal(result.status, installed === 'production-only' ? 127 : 0)
+ if (installed !== 'production-only') {
+ assert.deepEqual(result.stdout.trim().split('\n'), [installed === 'mac' ? mac : linux, join(home, '.codync-dev'), 'info', '--json', '--port', '19223'])
+ }
+ } finally {
+ rmSync(root, { recursive: true, force: true })
+ }
+ })
+}
+
const profile: SSHProfile = {
id: 'test', host: 'test-mini', user: null, port: null, identityFile: null,
remotePort: 19222, computerId: null, name: 'Test mini',
diff --git a/apps/desktop/src/shared/ssh.ts b/apps/desktop/src/shared/ssh.ts
index 285de2d3..3f3f9419 100644
--- a/apps/desktop/src/shared/ssh.ts
+++ b/apps/desktop/src/shared/ssh.ts
@@ -43,13 +43,13 @@ export interface SSHState {
export const SSH_INSTALL_COMMAND = 'brew install leepokai/codync/codync-host && codync-host install'
-export const newSSHProfile = (): SSHProfile => ({
+export const newSSHProfile = (remotePort = 19222): SSHProfile => ({
id: crypto.randomUUID(),
host: '',
port: null,
user: null,
identityFile: null,
- remotePort: 19222,
+ remotePort,
computerId: null,
name: '',
})
diff --git a/apps/desktop/src/shared/test-support/host-update.ts b/apps/desktop/src/shared/test-support/host-update.ts
index d57b0c7b..48fc3b10 100644
--- a/apps/desktop/src/shared/test-support/host-update.ts
+++ b/apps/desktop/src/shared/test-support/host-update.ts
@@ -1,9 +1,11 @@
import { EventEmitter } from 'node:events'
import * as crypto from 'node:crypto'
import * as path from 'node:path'
+import { environmentProfile, hostEnvironmentError } from '../environment.ts'
import { loadMainModule, settle } from './main-module.ts'
-export function hostUpdateFixture(options: { platform?: string; devPort?: string; installed?: boolean; missingBinary?: boolean; restartMarker?: boolean } = {}) {
+export function hostUpdateFixture(options: { environment?: 'main' | 'dev'; platform?: string; devPort?: string; installed?: boolean; missingBinary?: boolean; restartMarker?: boolean } = {}) {
+ const identity = environmentProfile(options.environment ?? 'main')
const platform = options.platform ?? 'darwin'
const binary = platform === 'win32' ? '/bundle/codync-host.exe' : platform === 'linux' ? '/home/test/.local/bin/codync-host' : '/bundle/codync-host'
const binaryBytes = Buffer.from('new signed host fixture')
@@ -19,10 +21,12 @@ export function hostUpdateFixture(options: { platform?: string; devPort?: string
busy: false,
reachable: true,
wrongBinary: false,
+ binaryEnvironment: identity.environment as string,
+ runningEnvironment: identity.environment as string,
}
const service = () => {
if (!behavior.installed) throw new Error('No service')
- return binary.replace(/codync-host\.exe$/, 'codync-hostw.exe')
+ return binary.replace(/codync-host\.exe$/, identity.supervisor)
}
const fs = {
existsSync: (name: string) => !options.missingBinary && name === binary,
@@ -40,20 +44,27 @@ export function hostUpdateFixture(options: { platform?: string; devPort?: string
'node:child_process': {
execFileSync: () => service(),
execFile: (_bin: string, args: string[], _options: unknown, callback: (error: { code: number } | null, stdout: string, stderr: string) => void) => {
+ if (args[0] === 'compat') {
+ callback(null, JSON.stringify({ environment: behavior.binaryEnvironment }), '')
+ return
+ }
calls.push([...args]); order.push(args[0]!)
const status = args[0] === 'stop' ? behavior.stopStatus : behavior.installStatus
callback(status ? { code: status } : null, '', status ? 'service command failed' : '')
},
},
electron: { app: { isPackaged: true, getPath: () => '/prefs' } },
+ './environment': { identity },
+ '../shared/environment': { hostEnvironmentError },
'./screen': { unregisterScreenAgent: () => { order.push('unregisterScreen') } },
}, {
+ __dirname: '/app/out/main',
process: { env: options.devPort ? { CODYNC_PORT: options.devPort } : {}, resourcesPath: '/bundle' },
setTimeout: (callback: () => void, ms: number) => { const id = ++timerId; timers.set(id, { callback, ms }); return id },
clearTimeout: (id: number) => timers.delete(id),
fetch: async () => {
if (!behavior.reachable) throw new Error('Host offline')
- return { ok: true, json: async () => ({ computerId: 'fixture-computer', busy: behavior.busy, binaryPath: binary, binaryHash: behavior.wrongBinary ? 'stale' : crypto.createHash('sha256').update(binaryBytes).digest('hex') }) }
+ return { ok: true, json: async () => ({ environment: behavior.runningEnvironment, computerId: 'fixture-computer', busy: behavior.busy, binaryPath: binary, binaryHash: behavior.wrongBinary ? 'stale' : crypto.createHash('sha256').update(binaryBytes).digest('hex') }) }
},
})
const host = new module.HostController()
diff --git a/apps/desktop/tools/dev-builder.cjs b/apps/desktop/tools/dev-builder.cjs
new file mode 100644
index 00000000..04a5dc28
--- /dev/null
+++ b/apps/desktop/tools/dev-builder.cjs
@@ -0,0 +1,16 @@
+// electron-builder merges inherited arrays, which would let Dev register production callbacks.
+// Compose the two objects ourselves so variant-owned resource and protocol lists replace them.
+const { readFileSync } = require('node:fs')
+const { join } = require('node:path')
+const { parse } = require('yaml')
+const root = join(__dirname, '..')
+const base = parse(readFileSync(join(root, 'electron-builder.yml'), 'utf8'))
+const dev = parse(readFileSync(join(root, 'electron-builder.dev.yml'), 'utf8'))
+module.exports = {
+ ...base,
+ ...dev,
+ mac: { ...base.mac, ...dev.mac },
+ dmg: { ...base.dmg, ...dev.dmg },
+ linux: { ...base.linux, ...dev.linux },
+ win: { ...base.win, ...dev.win },
+}
diff --git a/apps/desktop/tools/native-host.mjs b/apps/desktop/tools/native-host.mjs
index ba58c7a5..aa5600bb 100644
--- a/apps/desktop/tools/native-host.mjs
+++ b/apps/desktop/tools/native-host.mjs
@@ -25,7 +25,7 @@ mkdirSync(out, { recursive: true })
if (process.platform === 'win32') {
const target = 'x86_64-pc-windows-msvc'
build(target)
- for (const exe of ['codync-host.exe', 'codync-hostw.exe']) copyFileSync(join(host, 'target', target, 'release', exe), join(out, exe))
+ for (const exe of ['codync-host.exe', 'codync-hostw.exe']) copyFileSync(join(host, 'target', target, 'release', exe), join(out, env === 'dev' && exe === 'codync-hostw.exe' ? 'codync-dev-hostw.exe' : exe))
run(process.execPath, [join(root, '../../packaging/cua-driver/fetch.mjs'), 'windows-x86_64', out])
} else {
const targets = ['aarch64-apple-darwin', 'x86_64-apple-darwin']
diff --git a/apps/desktop/tools/native-screen.mjs b/apps/desktop/tools/native-screen.mjs
index 35f9a66c..a4c0e936 100644
--- a/apps/desktop/tools/native-screen.mjs
+++ b/apps/desktop/tools/native-screen.mjs
@@ -8,16 +8,20 @@ import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
if (process.platform !== 'darwin') process.exit(0)
+const env = process.argv[2] ?? 'main'
+if (!['main', 'dev'].includes(env)) throw new Error(`unknown environment ${env}`)
+const name = env === 'dev' ? 'CodyncDevScreen' : 'CodyncScreen'
+const configuration = env === 'dev' ? 'DevRelease' : 'Release'
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
const repo = join(root, '../..')
const derived = join(repo, 'build/dd')
execFileSync('xcodebuild', [
- 'build', '-project', join(repo, 'apps/Codync.xcodeproj'), '-scheme', 'Screen', '-configuration', 'Release',
+ 'build', '-project', join(repo, 'apps/Codync.xcodeproj'), '-scheme', env === 'dev' ? 'Screen Dev' : 'Screen', '-configuration', configuration,
'-destination', 'generic/platform=macOS', '-derivedDataPath', derived, '-quiet',
'CODE_SIGN_IDENTITY=-', 'CODE_SIGNING_REQUIRED=NO', 'CODE_SIGNING_ALLOWED=NO',
], { stdio: 'inherit' })
-const out = join(root, 'build/native/CodyncScreen.app')
+const out = join(root, `build/native/${name}.app`)
mkdirSync(dirname(out), { recursive: true })
rmSync(out, { recursive: true, force: true })
-cpSync(join(derived, 'Build/Products/Release/CodyncScreen.app'), out, { recursive: true, verbatimSymlinks: true })
+cpSync(join(derived, `Build/Products/${configuration}/${name}.app`), out, { recursive: true, verbatimSymlinks: true })
console.log('screen: built')
diff --git a/apps/desktop/tools/verify-build.cjs b/apps/desktop/tools/verify-build.cjs
new file mode 100644
index 00000000..1b711526
--- /dev/null
+++ b/apps/desktop/tools/verify-build.cjs
@@ -0,0 +1,8 @@
+// Fail before packaging if a stale account-config.json belongs to the other app variant.
+const { readFileSync } = require('node:fs')
+const { join } = require('node:path')
+module.exports = async (context) => {
+ const expected = context.packager.appInfo.id === 'com.pokai.Codync.dev' ? 'dev' : 'main'
+ const config = JSON.parse(readFileSync(join(context.packager.projectDir, 'resources/account-config.json'), 'utf8'))
+ if (config.environment !== expected) throw new Error(`Packaging ${expected} with ${config.environment} account config; run the matching dist script.`)
+}
diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swift
index e720330e..1f6494ba 100644
--- a/apps/ios/App/CodyncApp.swift
+++ b/apps/ios/App/CodyncApp.swift
@@ -221,10 +221,11 @@ final class AppStore {
}
func open(_ url: URL) {
- if url.scheme == "com.pokai.Codync.ios" {
+ if url.scheme == Bundle.main.bundleIdentifier {
Task { await account.handle(url) }
return
}
+ guard url.scheme == AppEnvironment.current.urlScheme else { return }
switch url.host() {
case "pair":
// Scanned with the Camera app: pair right away.
diff --git a/apps/ios/App/Push.swift b/apps/ios/App/Push.swift
index e955dc18..4bafa195 100644
--- a/apps/ios/App/Push.swift
+++ b/apps/ios/App/Push.swift
@@ -9,21 +9,17 @@ import os
private let log = Logger(subsystem: "com.pokai.Codync.ios", category: "Push")
private var apnsEnvironment: String {
- #if DEBUG
- "sandbox"
- #else
- "production"
- #endif
+ Bundle.main.object(forInfoDictionaryKey: "CodyncAPNSEnvironment") as? String ?? "production"
}
/// Turns an APNs token into a relay ticket (see relay/src/index.ts).
private func relayTicket(token: Data, kind: String) async throws -> String {
- struct Body: Encodable { var token: String; var env: String; var kind: String }
+ struct Body: Encodable { var token: String; var env: String; var kind: String; var bundleId: String }
struct Res: Decodable { var ticket: String }
var req = URLRequest(url: URL(string: "\(SharedStore.relayURL)/register")!)
req.httpMethod = "POST"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
- req.httpBody = try JSONEncoder().encode(Body(token: token.map { String(format: "%02x", $0) }.joined(), env: apnsEnvironment, kind: kind))
+ req.httpBody = try JSONEncoder().encode(Body(token: token.map { String(format: "%02x", $0) }.joined(), env: apnsEnvironment, kind: kind, bundleId: Bundle.main.bundleIdentifier ?? "com.pokai.Codync.ios"))
req.timeoutInterval = 15
let (data, response) = try await URLSession.shared.data(for: req)
guard let http = response as? HTTPURLResponse, (200..<300).contains(http.statusCode) else {
@@ -180,7 +176,7 @@ final class LiveActivities {
activity: status == "needsInput" || status == "multiple" ? "Review the proposed changes." : "Running the test suite.",
startedAt: .now - 154)
do {
- _ = try Activity.request(attributes: BotActivityAttributes(bot: bot, computerId: "preview", link: URL(string: "codync://computers")),
+ _ = try Activity.request(attributes: BotActivityAttributes(bot: bot, computerId: "preview", link: AppEnvironment.current.link("computers")),
content: .init(state: state, staleDate: status == "stale" ? .now - 1 : .now + 900), pushType: nil)
} catch { log.error("Simulator activity preview: \(error.localizedDescription)") }
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Client/AppEnvironment.swift b/apps/ios/Kit/Sources/CodyncKit/Client/AppEnvironment.swift
new file mode 100644
index 00000000..62d28a3c
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncKit/Client/AppEnvironment.swift
@@ -0,0 +1,20 @@
+import Foundation
+
+/// Read from the containing app or extension, so the shared package follows its build configuration.
+public enum AppEnvironment: String, Sendable {
+ case main
+ case dev
+
+ public static let current = AppEnvironment(
+ rawValue: Bundle.main.object(forInfoDictionaryKey: "CodyncEnvironment") as? String ?? "main"
+ ) ?? .main
+
+ public var appGroup: String { self == .dev ? "group.com.pokai.Codync.dev" : "group.com.pokai.Codync" }
+ public var urlScheme: String { self == .dev ? "codync-dev" : "codync" }
+ public var appName: String { self == .dev ? "Codync Dev" : "Codync" }
+
+ public func link(_ destination: String) -> URL {
+ // All callers supply a fixed app route.
+ URL(string: "\(urlScheme)://\(destination)")!
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Client/Pairing.swift b/apps/ios/Kit/Sources/CodyncKit/Client/Pairing.swift
index 425defb7..12eded2a 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Client/Pairing.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Client/Pairing.swift
@@ -37,7 +37,7 @@ public struct Pairing: Hashable, Sendable {
}
public static func parse(_ url: URL) throws(Problem) -> Pairing {
- guard url.scheme == "codync", url.host() == "pair",
+ guard url.scheme == AppEnvironment.current.urlScheme, url.host() == "pair",
let items = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems else { throw .notPairingLink }
let q = Dictionary(items.map { ($0.name, $0.value ?? "") }, uniquingKeysWith: { a, _ in a })
guard q["v"] == "3" else { throw .outdatedHost }
diff --git a/apps/ios/Kit/Sources/CodyncKit/Client/SharedStore.swift b/apps/ios/Kit/Sources/CodyncKit/Client/SharedStore.swift
index 853160b4..88ae16c2 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Client/SharedStore.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Client/SharedStore.swift
@@ -4,7 +4,7 @@ import Foundation
/// Values shared between the app, its widgets and its notification extension through the App Group,
/// one namespace per account context so a signed-out account's data never shows in another.
public enum SharedStore {
- public static let appGroup = "group.com.pokai.Codync"
+ public static let appGroup = AppEnvironment.current.appGroup
/// The APNs push relay (relay/ in this repo).
public static let relayURL = "https://codync-relay.kevin2005ha.workers.dev"
@@ -74,19 +74,19 @@ public enum SharedStore {
/// can't open another account's bot: `codync://bot/<botId>?scope=<id>&computer=<computerId>`.
public func botURL(_ ref: BotReference) -> URL {
var url = URLComponents()
- url.scheme = "codync"
+ url.scheme = AppEnvironment.current.urlScheme
url.host = "bot"
url.path = "/" + ref.botId
url.queryItems = [
URLQueryItem(name: "scope", value: id),
URLQueryItem(name: "computer", value: ref.computerId),
]
- return url.url ?? URL(string: "codync://bot")!
+ return url.url ?? AppEnvironment.current.link("bot")
}
/// The bot a deep link points at, or nil when it belongs to another context or is malformed.
public func reference(from url: URL) -> BotReference? {
- guard url.scheme == "codync", url.host() == "bot",
+ guard url.scheme == AppEnvironment.current.urlScheme, url.host() == "bot",
let items = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems,
items.first(where: { $0.name == "scope" })?.value == id,
let computer = items.first(where: { $0.name == "computer" })?.value,
diff --git a/apps/ios/Kit/Sources/CodyncUI/Marketplace/ConnectorSignInFlow.swift b/apps/ios/Kit/Sources/CodyncUI/Marketplace/ConnectorSignInFlow.swift
index dd43ca3a..6a4505da 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Marketplace/ConnectorSignInFlow.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Marketplace/ConnectorSignInFlow.swift
@@ -22,7 +22,7 @@ struct ConnectorSignInFlow {
}
let back: URL
do {
- back = try await webAuthenticationSession.authenticate(using: url, callbackURLScheme: "codync", preferredBrowserSession: .shared)
+ back = try await webAuthenticationSession.authenticate(using: url, callbackURLScheme: AppEnvironment.current.urlScheme, preferredBrowserSession: .shared)
} catch let error as ASWebAuthenticationSessionError where error.code == .canceledLogin {
return
}
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/AppEnvironmentTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/AppEnvironmentTests.swift
new file mode 100644
index 00000000..c662c3d4
--- /dev/null
+++ b/apps/ios/Kit/Tests/CodyncKitTests/AppEnvironmentTests.swift
@@ -0,0 +1,13 @@
+import Foundation
+import Testing
+@testable import CodyncKit
+
+struct AppEnvironmentTests {
+ @Test func developmentWidgetsAndDataStaySeparateFromProduction() {
+ #expect(AppEnvironment.main.appGroup == "group.com.pokai.Codync")
+ #expect(AppEnvironment.main.link("computers").absoluteString == "codync://computers")
+ #expect(AppEnvironment.dev.appGroup != AppEnvironment.main.appGroup)
+ #expect(AppEnvironment.dev.link("computers").absoluteString == "codync-dev://computers")
+ #expect(AppEnvironment.dev.link("usage").scheme != AppEnvironment.main.link("usage").scheme)
+ }
+}
diff --git a/apps/ios/NotificationService/Info.plist b/apps/ios/NotificationService/Info.plist
index 86cc7405..f8bd9fe4 100644
--- a/apps/ios/NotificationService/Info.plist
+++ b/apps/ios/NotificationService/Info.plist
@@ -2,8 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>CodyncEnvironment</key><string>$(CODYNC_ENV)</string>
+ <key>CodyncAppGroup</key><string>$(CODYNC_APP_GROUP)</string>
+ <key>CodyncURLScheme</key><string>$(CODYNC_URL_SCHEME)</string>
+ <key>CodyncAPNSEnvironment</key><string>$(CODYNC_APNS_ENVIRONMENT)</string>
<key>CodyncKeychainGroup</key>
- <string>$(AppIdentifierPrefix)com.pokai.Codync</string>
+ <string>$(AppIdentifierPrefix)$(CODYNC_KEYCHAIN_GROUP)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
diff --git a/apps/ios/NotificationService/NotificationService.entitlements b/apps/ios/NotificationService/NotificationService.entitlements
index c5f86e3a..73179017 100644
--- a/apps/ios/NotificationService/NotificationService.entitlements
+++ b/apps/ios/NotificationService/NotificationService.entitlements
@@ -4,11 +4,11 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
- <string>group.com.pokai.Codync</string>
+ <string>$(CODYNC_APP_GROUP)</string>
</array>
<key>keychain-access-groups</key>
<array>
- <string>$(AppIdentifierPrefix)com.pokai.Codync</string>
+ <string>$(AppIdentifierPrefix)$(CODYNC_KEYCHAIN_GROUP)</string>
</array>
</dict>
</plist>
diff --git a/apps/ios/Resources/Info.plist b/apps/ios/Resources/Info.plist
index b2309b69..f80677a8 100644
--- a/apps/ios/Resources/Info.plist
+++ b/apps/ios/Resources/Info.plist
@@ -2,17 +2,21 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>CodyncEnvironment</key><string>$(CODYNC_ENV)</string>
+ <key>CodyncAppGroup</key><string>$(CODYNC_APP_GROUP)</string>
+ <key>CodyncURLScheme</key><string>$(CODYNC_URL_SCHEME)</string>
+ <key>CodyncAPNSEnvironment</key><string>$(CODYNC_APNS_ENVIRONMENT)</string>
<key>CodyncKeychainGroup</key>
- <string>$(AppIdentifierPrefix)com.pokai.Codync</string>
+ <string>$(AppIdentifierPrefix)$(CODYNC_KEYCHAIN_GROUP)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
- <string>com.pokai.Codync.ios</string>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
- <string>codync</string>
- <string>com.pokai.Codync.ios</string>
+ <string>$(CODYNC_URL_SCHEME)</string>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>
diff --git a/apps/ios/Resources/iOS.entitlements b/apps/ios/Resources/iOS.entitlements
index 6c20193e..a23e6f85 100644
--- a/apps/ios/Resources/iOS.entitlements
+++ b/apps/ios/Resources/iOS.entitlements
@@ -12,11 +12,11 @@
<true/>
<key>com.apple.security.application-groups</key>
<array>
- <string>group.com.pokai.Codync</string>
+ <string>$(CODYNC_APP_GROUP)</string>
</array>
<key>keychain-access-groups</key>
<array>
- <string>$(AppIdentifierPrefix)com.pokai.Codync</string>
+ <string>$(AppIdentifierPrefix)$(CODYNC_KEYCHAIN_GROUP)</string>
</array>
</dict>
</plist>
diff --git a/apps/ios/Views/PairingView.swift b/apps/ios/Views/PairingView.swift
index a02c358b..4409cbd5 100644
--- a/apps/ios/Views/PairingView.swift
+++ b/apps/ios/Views/PairingView.swift
@@ -228,7 +228,7 @@ private struct ScanPage: View {
viewfinder
HStack {
- TextField("Or paste a codync://pair link", text: $pasted)
+ TextField("Or paste a \(AppEnvironment.current.urlScheme)://pair link", text: $pasted)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.font(.callout.monospaced())
@@ -360,7 +360,7 @@ struct QRScanner: UIViewControllerRepresentable {
func dataScanner(_ scanner: DataScannerViewController, didAdd items: [RecognizedItem], allItems: [RecognizedItem]) {
for case let .barcode(code) in items {
- if let value = code.payloadStringValue, value.hasPrefix("codync://"), !done {
+ if let value = code.payloadStringValue, value.hasPrefix(AppEnvironment.current.urlScheme + "://"), !done {
done = true
scanner.stopScanning()
onCode(value)
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index 2d22b02f..2dc34013 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -9,6 +9,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
### zh-Hant
+- 開發測試版本現在使用獨立的 App 與資料空間,可和正式版本並存。
+
- 憑證設定欄位保留清楚的標籤,並顯示尚未儲存連線憑證的狀態。
- 對話捲到底後繼續拖動時保留自然回彈,不再突然跳回底部或閃現跳至最新訊息按鈕。
- 改善跳至最新訊息的捲動動畫,避免長對話來回跳動,並可隨時用手勢中止。
@@ -17,6 +19,8 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
### en-US
+- Development builds now use a separate app and data storage, so they can coexist with the production app.
+
- Credential fields keep their labels visible, with a clearer empty state for saved connections.
- Chats bounce naturally when dragged past the bottom, without snapping back or flashing the jump-to-latest button.
- Smoother jumps to the latest message, without back-and-forth movement in long chats; dragging interrupts immediately.
diff --git a/apps/ios/Widgets/CodyncWidgets.swift b/apps/ios/Widgets/CodyncWidgets.swift
index 74096aef..091e0ce9 100644
--- a/apps/ios/Widgets/CodyncWidgets.swift
+++ b/apps/ios/Widgets/CodyncWidgets.swift
@@ -248,7 +248,7 @@ struct LeadBot: Sendable {
let symbol: String
let url: URL
- static let home = URL(string: "codync://computers")!
+ static let home = AppEnvironment.current.link("computers")
init(text: String, symbol: String, url: URL = LeadBot.home) {
self.text = text; self.symbol = symbol; self.url = url
@@ -573,7 +573,7 @@ struct ProviderUsageView: View {
}
}
.containerBackground(Palette.surface, for: .widget)
- .widgetURL(URL(string: "codync://usage"))
+ .widgetURL(AppEnvironment.current.link("usage"))
}
}
@@ -590,7 +590,7 @@ struct BotLiveActivity: Widget {
indicator(context, state: state, size: 28)
}
.modifier(SurfaceTint())
- .widgetURL(context.attributes.link ?? URL(string: "codync://computers"))
+ .widgetURL(context.attributes.link ?? AppEnvironment.current.link("computers"))
} dynamicIsland: { context in
let state = presentation(context)
return DynamicIsland {
@@ -626,7 +626,7 @@ struct BotLiveActivity: Widget {
.accessibilityLabel("\(context.attributes.name), \(state.title)")
}
.keylineTint(state.tint)
- .widgetURL(context.attributes.link ?? URL(string: "codync://computers"))
+ .widgetURL(context.attributes.link ?? AppEnvironment.current.link("computers"))
}
}
diff --git a/apps/ios/Widgets/Resources/Info.plist b/apps/ios/Widgets/Resources/Info.plist
index e62a3901..18474b09 100644
--- a/apps/ios/Widgets/Resources/Info.plist
+++ b/apps/ios/Widgets/Resources/Info.plist
@@ -2,8 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>CodyncEnvironment</key><string>$(CODYNC_ENV)</string>
+ <key>CodyncAppGroup</key><string>$(CODYNC_APP_GROUP)</string>
+ <key>CodyncURLScheme</key><string>$(CODYNC_URL_SCHEME)</string>
+ <key>CodyncAPNSEnvironment</key><string>$(CODYNC_APNS_ENVIRONMENT)</string>
<key>CodyncKeychainGroup</key>
- <string>$(AppIdentifierPrefix)com.pokai.Codync</string>
+ <string>$(AppIdentifierPrefix)$(CODYNC_KEYCHAIN_GROUP)</string>
<!-- The Dynamic Island's animated bot faces and thinking orb (tools/timer-fonts.py). -->
<key>UIAppFonts</key>
<array>
diff --git a/apps/ios/Widgets/Resources/Widgets.entitlements b/apps/ios/Widgets/Resources/Widgets.entitlements
index c5f86e3a..73179017 100644
--- a/apps/ios/Widgets/Resources/Widgets.entitlements
+++ b/apps/ios/Widgets/Resources/Widgets.entitlements
@@ -4,11 +4,11 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
- <string>group.com.pokai.Codync</string>
+ <string>$(CODYNC_APP_GROUP)</string>
</array>
<key>keychain-access-groups</key>
<array>
- <string>$(AppIdentifierPrefix)com.pokai.Codync</string>
+ <string>$(AppIdentifierPrefix)$(CODYNC_KEYCHAIN_GROUP)</string>
</array>
</dict>
</plist>
diff --git a/apps/ios/Widgets/WidgetPreviews.swift b/apps/ios/Widgets/WidgetPreviews.swift
index bf3a6a5a..91daf087 100644
--- a/apps/ios/Widgets/WidgetPreviews.swift
+++ b/apps/ios/Widgets/WidgetPreviews.swift
@@ -81,7 +81,7 @@ import ActivityKit
}
private extension BotActivityAttributes {
- static var preview: Self { .init(bot: Bot.widgetPreview[0], computerId: "preview", link: URL(string: "codync://computers")) }
+ static var preview: Self { .init(bot: Bot.widgetPreview[0], computerId: "preview", link: AppEnvironment.current.link("computers")) }
}
#Preview("Activity · Lock Screen", as: .content, using: BotActivityAttributes.preview) {
diff --git a/apps/project.yml b/apps/project.yml
index 0a1719e5..6ab71fe2 100644
--- a/apps/project.yml
+++ b/apps/project.yml
@@ -18,6 +18,11 @@ packages:
WebRTC:
url: https://github.com/stasel/WebRTC
exactVersion: 153.0.0
+configs:
+ Debug: debug
+ Release: release
+ DevDebug: debug
+ DevRelease: release
settings:
base:
MARKETING_VERSION: 2.11.2
@@ -28,12 +33,75 @@ settings:
DEVELOPMENT_TEAM: 7FUM8A8H72
DEAD_CODE_STRIPPING: YES
ENABLE_USER_SCRIPT_SANDBOXING: NO
+ CODYNC_ENV: main
+ CODYNC_APP_NAME: Codync
+ CODYNC_IOS_BUNDLE_ID: com.pokai.Codync.ios
+ CODYNC_APP_GROUP: group.com.pokai.Codync
+ CODYNC_KEYCHAIN_GROUP: com.pokai.Codync
+ CODYNC_URL_SCHEME: codync
+ CODYNC_SCREEN_NAME: CodyncScreen
+ CODYNC_SCREEN_BUNDLE_ID: com.pokai.Codync.screen
+ CODYNC_DATA_FOLDER: .codync
configs:
- # Which Codync cloud a build talks to: shared/Config/<env>.plist becomes AccountConfig.plist.
Debug:
- CODYNC_ENV: dev
+ CODYNC_APNS_ENVIRONMENT: sandbox
Release:
- CODYNC_ENV: main
+ CODYNC_APNS_ENVIRONMENT: production
+ DevDebug:
+ CODYNC_ENV: dev
+ CODYNC_APP_NAME: Codync Dev
+ CODYNC_IOS_BUNDLE_ID: com.pokai.Codync.ios.dev
+ CODYNC_APP_GROUP: group.com.pokai.Codync.dev
+ CODYNC_KEYCHAIN_GROUP: com.pokai.Codync.dev
+ CODYNC_URL_SCHEME: codync-dev
+ CODYNC_SCREEN_NAME: CodyncDevScreen
+ CODYNC_SCREEN_BUNDLE_ID: com.pokai.Codync.dev.screen
+ CODYNC_DATA_FOLDER: .codync-dev
+ CODYNC_APNS_ENVIRONMENT: sandbox
+ DevRelease:
+ CODYNC_ENV: dev
+ CODYNC_APP_NAME: Codync Dev
+ CODYNC_IOS_BUNDLE_ID: com.pokai.Codync.ios.dev
+ CODYNC_APP_GROUP: group.com.pokai.Codync.dev
+ CODYNC_KEYCHAIN_GROUP: com.pokai.Codync.dev
+ CODYNC_URL_SCHEME: codync-dev
+ CODYNC_SCREEN_NAME: CodyncDevScreen
+ CODYNC_SCREEN_BUNDLE_ID: com.pokai.Codync.dev.screen
+ CODYNC_DATA_FOLDER: .codync-dev
+ CODYNC_APNS_ENVIRONMENT: production
+schemes:
+ iOS:
+ build:
+ targets:
+ iOS: all
+ run:
+ config: Debug
+ archive:
+ config: Release
+ iOS Dev:
+ build:
+ targets:
+ iOS: all
+ run:
+ config: DevDebug
+ archive:
+ config: DevRelease
+ Screen:
+ build:
+ targets:
+ Screen: all
+ run:
+ config: Debug
+ archive:
+ config: Release
+ Screen Dev:
+ build:
+ targets:
+ Screen: all
+ run:
+ config: DevDebug
+ archive:
+ config: DevRelease
targets:
# Screen capture, input and WebRTC for Remote screen. A separate signed bundle so
# macOS's Screen Recording / Accessibility grants belong to it (see host/src/screen/).
@@ -46,11 +114,12 @@ targets:
- package: WebRTC
settings:
base:
- PRODUCT_NAME: CodyncScreen
- PRODUCT_BUNDLE_IDENTIFIER: com.pokai.Codync.screen
+ INFOPLIST_FILE: screen-macos/Info.plist
+ PRODUCT_NAME: $(CODYNC_SCREEN_NAME)
+ PRODUCT_BUNDLE_IDENTIFIER: $(CODYNC_SCREEN_BUNDLE_ID)
GENERATE_INFOPLIST_FILE: YES
INFOPLIST_KEY_LSUIElement: YES
- INFOPLIST_KEY_CFBundleDisplayName: Codync Screen
+ INFOPLIST_KEY_CFBundleDisplayName: $(CODYNC_APP_NAME) Screen
INFOPLIST_KEY_NSHumanReadableCopyright: ""
ENABLE_HARDENED_RUNTIME: YES
ENABLE_APP_SANDBOX: NO
@@ -92,17 +161,17 @@ targets:
basedOnDependencyAnalysis: false
showEnvVars: false
script: |
- # Debug builds use dev (dev-api.codync.dev), Release builds use main (api.codync.dev).
+ # The scheme chooses an environment independently of Debug/Release optimization.
cp "$SRCROOT/shared/Config/$CODYNC_ENV.plist" "$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/AccountConfig.plist"
settings:
base:
- PRODUCT_NAME: Codync
- PRODUCT_BUNDLE_IDENTIFIER: com.pokai.Codync.ios
+ PRODUCT_NAME: $(CODYNC_APP_NAME)
+ PRODUCT_BUNDLE_IDENTIFIER: $(CODYNC_IOS_BUNDLE_ID)
INFOPLIST_FILE: ios/Resources/Info.plist
GENERATE_INFOPLIST_FILE: YES
CODE_SIGN_ENTITLEMENTS: ios/Resources/iOS.entitlements
TARGETED_DEVICE_FAMILY: "1,2"
- INFOPLIST_KEY_CFBundleDisplayName: Codync
+ INFOPLIST_KEY_CFBundleDisplayName: $(CODYNC_APP_NAME)
INFOPLIST_KEY_LSApplicationCategoryType: public.app-category.developer-tools
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption: NO
INFOPLIST_KEY_UIApplicationSceneManifest_Generation: YES
@@ -131,11 +200,11 @@ targets:
settings:
base:
PRODUCT_NAME: CodyncWidgets
- PRODUCT_BUNDLE_IDENTIFIER: com.pokai.Codync.ios.LiveActivity
+ PRODUCT_BUNDLE_IDENTIFIER: $(CODYNC_IOS_BUNDLE_ID).LiveActivity
INFOPLIST_FILE: ios/Widgets/Resources/Info.plist
GENERATE_INFOPLIST_FILE: YES
CODE_SIGN_ENTITLEMENTS: ios/Widgets/Resources/Widgets.entitlements
- INFOPLIST_KEY_CFBundleDisplayName: Codync
+ INFOPLIST_KEY_CFBundleDisplayName: $(CODYNC_APP_NAME)
TARGETED_DEVICE_FAMILY: "1,2"
SKIP_INSTALL: YES
# Opens end-to-end sealed alert text (spec §6.7) with this account's push key from the shared Keychain.
@@ -150,10 +219,10 @@ targets:
settings:
base:
PRODUCT_NAME: CodyncNotificationService
- PRODUCT_BUNDLE_IDENTIFIER: com.pokai.Codync.ios.NotificationService
+ PRODUCT_BUNDLE_IDENTIFIER: $(CODYNC_IOS_BUNDLE_ID).NotificationService
INFOPLIST_FILE: ios/NotificationService/Info.plist
GENERATE_INFOPLIST_FILE: YES
CODE_SIGN_ENTITLEMENTS: ios/NotificationService/NotificationService.entitlements
- INFOPLIST_KEY_CFBundleDisplayName: Codync
+ INFOPLIST_KEY_CFBundleDisplayName: $(CODYNC_APP_NAME)
TARGETED_DEVICE_FAMILY: "1,2"
SKIP_INSTALL: YES
diff --git a/apps/screen-macos/Driver.swift b/apps/screen-macos/Driver.swift
index cb17f08c..c0014a9f 100644
--- a/apps/screen-macos/Driver.swift
+++ b/apps/screen-macos/Driver.swift
@@ -52,7 +52,8 @@ final class Driver {
/// In the per-user temporary directory (private, and short enough for a socket path).
private static var socketPath: String {
- NSTemporaryDirectory() + "codync-cua/cua.sock"
+ let development = Bundle.main.object(forInfoDictionaryKey: "CodyncEnvironment") as? String == "dev"
+ return NSTemporaryDirectory() + (development ? "codync-dev-cua/cua.sock" : "codync-cua/cua.sock")
}
private static func listening(_ path: String) -> Bool {
diff --git a/apps/screen-macos/HostLink.swift b/apps/screen-macos/HostLink.swift
index e499ac6f..28a27b15 100644
--- a/apps/screen-macos/HostLink.swift
+++ b/apps/screen-macos/HostLink.swift
@@ -21,7 +21,7 @@ final class HostLink {
var onConnect: (@MainActor () -> Void)?
static var socketPath: String {
- let base = ProcessInfo.processInfo.environment["CODYNC_HOME"] ?? NSHomeDirectory() + "/.codync"
+ let base = ProcessInfo.processInfo.environment["CODYNC_HOME"] ?? NSHomeDirectory() + "/" + (Bundle.main.object(forInfoDictionaryKey: "CodyncDataFolder") as? String ?? ".codync")
return base + "/screen.sock"
}
diff --git a/apps/screen-macos/Info.plist b/apps/screen-macos/Info.plist
new file mode 100644
index 00000000..4f800f82
--- /dev/null
+++ b/apps/screen-macos/Info.plist
@@ -0,0 +1,6 @@
+<?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>CodyncEnvironment</key><string>$(CODYNC_ENV)</string>
+ <key>CodyncDataFolder</key><string>$(CODYNC_DATA_FOLDER)</string>
+</dict></plist>
diff --git a/cloud/src/api.ts b/cloud/src/api.ts
index 0ab84379..5611363d 100644
--- a/cloud/src/api.ts
+++ b/cloud/src/api.ts
@@ -24,6 +24,10 @@ export const health = async () => ({ ok: true, version: VERSION });
export const oauthCallback = async (c: Ctx) =>
new Response(null, { status: 302, headers: { Location: `codync://oauth${c.url.search}`, "Cache-Control": "no-store" } });
+/** Separate callback route keeps installed production clients and older dev builds working. */
+export const oauthDevCallback = async (c: Ctx) =>
+ new Response(null, { status: 302, headers: { Location: `codync-dev://oauth${c.url.search}`, "Cache-Control": "no-store" } });
+
// ---- cron (every 15 minutes) ----
export async function sweep(env: Env, now: number): Promise<void> {
diff --git a/cloud/src/index.ts b/cloud/src/index.ts
index 394f3329..941e59f9 100644
--- a/cloud/src/index.ts
+++ b/cloud/src/index.ts
@@ -36,6 +36,7 @@ const ID = "([A-Za-z0-9_-]{1,64})";
const routes: [string, RegExp, Handler][] = [
["GET", /^\/v1\/health$/, api.health],
["GET", /^\/v1\/oauth\/callback$/, api.oauthCallback],
+ ["GET", /^\/v1\/oauth\/callback\/dev$/, api.oauthDevCallback],
["GET", /^\/v1\/me$/, api.me],
["POST", /^\/v1\/devices$/, api.registerDevice],
["GET", /^\/v1\/devices$/, api.listDevices],
diff --git a/cloud/test/api.test.ts b/cloud/test/api.test.ts
index ef984eda..d2e9b58e 100644
--- a/cloud/test/api.test.ts
+++ b/cloud/test/api.test.ts
@@ -90,6 +90,12 @@ describe("basics", () => {
expect(res.headers.get("Location")).toBe("codync://oauth?code=abc&state=xyz");
});
+ it("keeps development connector callbacks separate from production", async () => {
+ const res = await SELF.fetch(`${ORIGIN}/v1/oauth/callback/dev?code=abc&state=xyz`, { redirect: "manual" });
+ expect(res.status).toBe(302);
+ expect(res.headers.get("Location")).toBe("codync-dev://oauth?code=abc&state=xyz");
+ });
+
it("health", async () => {
expect(await call("GET", "/v1/health")).toEqual({ status: 200, body: { ok: true, version: "2.2.0" } });
});
diff --git a/docs/architecture/desktop-app.md b/docs/architecture/desktop-app.md
index 6c5616c9..16d78e81 100644
--- a/docs/architecture/desktop-app.md
+++ b/docs/architecture/desktop-app.md
@@ -96,7 +96,7 @@ It uses port 19222 on the remote computer and leaves bots and settings unchanged
cd apps/desktop
npm ci
npm run icons # macOS: SF Symbol masks
-npm run dev # dev config, against the installed host on 19222
+npm run dev # Codync Dev, separate host on 19223
CODYNC_PORT=19333 CODYNC_HOME=/path/to/home npm run dev # against a manually run host
npm run typecheck && npm test
```
@@ -123,8 +123,7 @@ helper at the top of `electron-builder.yml` doesn't depend on the environment; p
`package.json`): the Screen launch agent only runs code from that team, and the keychain holds
another team's certificate electron-builder would otherwise pick. Update the name when it is
renewed.
-Only one environment's host runs on a computer at a time (one `~/.codync`, port and service):
-switching environments means installing the other build.
+Codync and Codync Dev can run side by side: separate app identities, host services, ports, data and login callbacks. See [Dev app isolation](../guides/dev-app.md) for the resource map and external signing/account setup.
For a local signed Mac build, explicitly select a development identity from the project's
team with `-c.mac.identity="Apple Development: …"`; use `--dir --arm64` and
diff --git a/docs/guides/dev-app.md b/docs/guides/dev-app.md
new file mode 100644
index 00000000..470b7818
--- /dev/null
+++ b/docs/guides/dev-app.md
@@ -0,0 +1,73 @@
+# Codync Dev and production side by side
+
+Codync Dev uses the same source as Codync, with a separate installed identity and local state. Production identifiers and storage locations remain unchanged. Do not copy production credentials, host identity keys, databases or paired devices into Dev; sign in and pair test devices independently.
+
+Both variants use the original Codync icon. The installed name **Codync Dev** distinguishes the development app.
+
+## Choose a build
+
+| Client | Production | Development |
+| --- | --- | --- |
+| Xcode iPhone scheme | `iOS` | `iOS Dev` |
+| Xcode Screen helper scheme | `Screen` | `Screen Dev` |
+| Desktop packaging | `npm run dist:<platform>:main` | `npm run dist:<platform>:dev` |
+| Foreground host | `CODYNC_ENV=main cargo run -- serve` | `cargo run -- serve` |
+
+`<platform>` is `mac`, `linux`, or `win`. Desktop `npm run dev` uses the development identity. An unpackaged run needs a matching development host binary (`host/target/debug/codync-host`, or `CODYNC_HOST_BIN`). On Linux, install a development host as `~/.local/bin/codync-dev-host`; the production binary remains `codync-host`.
+
+Xcode configurations separate environment from optimization: `Debug` and `Release` use production; `DevDebug` and `DevRelease` use development. The `iOS` archive remains `Release`, preserving Xcode Cloud's existing production scheme. Configure schemes through `apps/project.yml`, then regenerate with `xcodegen generate --spec apps/project.yml`.
+
+## Resource ownership
+
+| Resource | Production | Development |
+| --- | --- | --- |
+| Cloud | `https://api.codync.dev` | `https://dev-api.codync.dev` |
+| iOS bundle | `com.pokai.Codync.ios` | `com.pokai.Codync.ios.dev` |
+| iOS App Group | `group.com.pokai.Codync` | `group.com.pokai.Codync.dev` |
+| iOS Keychain group (team prefix omitted) | `com.pokai.Codync` | `com.pokai.Codync.dev` |
+| Desktop bundle | `com.pokai.Codync` | `com.pokai.Codync.dev` |
+| Linux package / Windows package cache | `codync-desktop` | `codync-desktop-dev` |
+| Desktop account callback | `com.pokai.Codync://callback` | `com.pokai.Codync.dev://callback` |
+| Pairing and widget links | `codync://` | `codync-dev://` |
+| Host default port | `19222` | `19223` |
+| Host data | `~/.codync` | `~/.codync-dev` |
+| macOS host launch agent | `com.pokai.codync.host` | `com.pokai.codync.dev.host` |
+| Linux user service | `codync-host.service` | `codync-dev-host.service` |
+| Windows Run key value | `CodyncHost` | `CodyncDevHost` |
+| Windows supervisor | `codync-hostw.exe` | `codync-dev-hostw.exe` |
+| macOS Screen helper identifier | `com.pokai.Codync.screen` | `com.pokai.Codync.dev.screen` |
+
+The iPhone extensions inherit the parent environment. Electron Dev stores its browser session, account credentials and SSH profiles under its own `Codync Dev` user-data directory. SSH host-key storage and orphan-tunnel cleanup are also separate. Dev never installs production updates and does not rewrite the shared Claude Code status line.
+
+Remote SSH lookup in Dev accepts the host bundled in `/Applications/Codync Dev.app` or `~/.local/bin/codync-dev-host`; it does not fall back to Homebrew's production host. The desktop's missing-host instructions therefore ask for a Dev build. iOS has no SSH installer or local host to manage. The terminal pairing screen names Codync Dev when it emits a Dev pairing link.
+
+Stop only the variant being replaced. Avoid `pkill codync-host`, generic bundle lookups, or commands that stop both variants. macOS Dev's host can be stopped with `launchctl bootout gui/$(id -u)/com.pokai.codync.dev.host`; its app is **Codync Dev**. Keep each worktree's Apple build products under its own `build/dd`.
+
+## Accounts, callbacks and notifications
+
+Register the development app identifiers, App Group and Sign in with Apple capability with the signing team. Configure the Clerk development instance to accept the new iOS identifier and desktop callback. These settings are external to the repository; a successful simulator build does not prove signing or sign-in works on a device.
+
+The cloud adds `/v1/oauth/callback/dev` for connector sign-in, returning `codync-dev://oauth`. The existing callback keeps returning `codync://oauth`. Deploy the added route to the development Worker before testing connector sign-in from a Dev client.
+
+The push relay seals the app bundle identifier into new tickets and selects that APNs topic. Existing tickets and registrations without a bundle identifier retain the production topic. Only the production and Dev iOS identifiers are accepted; alert and Live Activity destinations stay separate. Deploy this additive relay change before testing Dev notifications. APNs sandbox/production is a signing/distribution choice, independent of which Codync cloud is used.
+
+## Troubleshooting a running host shown as Offline
+
+Observed on 2026-10-09: a MacBook development host was online in development D1, while a Mac mini production app showed the same computer identity's old production record as Offline. Both hosts reported healthy relay connections. Their cloud environments differed.
+
+Before resetting keys or pairing again:
+
+1. Run the relevant bundled `codync-host cloud` on each computer. Compare `url`, `registered`, `connected` and `last error`.
+2. Read `/health` on that host's port for `environment`, `computerId`, binary path and version.
+3. Confirm the desktop app, its host and the iPhone app participating in the test use the same environment. An identical version number or Apple login does not establish this.
+4. Refresh the account list. Working SSH or local access does not prove the clouds match.
+
+An environment change is not a migration of the production account or host. The fresh Dev instance starts without production bots or permissions.
+
+## Local verification (2026-10-09)
+
+- iOS Dev built, signed and launched on a physical iPhone. The app and both extensions use the Dev App Group; the signed app uses the separate Dev Keychain group and development APNs entitlement.
+- The production iOS Release simulator build succeeded with its existing bundle identifiers, App Group and URL scheme. The Swift package's 55 tests passed.
+- A signed macOS Dev app launched into an independent empty workspace. The existing host on 19222 and Dev host on 19223 ran together with different computer identities. Starting and stopping Dev left the original launch agent, token and Claude Code settings unchanged.
+- Desktop type checking and regression tests passed; Rust tests and Clippy passed. Windows and Linux identities and package configuration were checked in tests, but their installed apps have not been exercised on those operating systems.
+- Live Apple account sign-in, connector callbacks and APNs delivery require the external setup and deployments above. Local build success does not verify those flows.
diff --git a/docs/guides/development.md b/docs/guides/development.md
index a15808a9..65d7e09d 100644
--- a/docs/guides/development.md
+++ b/docs/guides/development.md
@@ -15,11 +15,11 @@ npm run icons # macOS only
npm run dev
```
-Before launching a new build, quit running copies (the installed app and earlier `npm run dev` windows):
+Before launching a new build, quit only that variant. Production and Dev may coexist; see [Dev app isolation](dev-app.md). For a development rebuild:
```sh
-osascript -e 'tell application id "com.pokai.Codync" to quit'
-pkill -x Codync
+osascript -e 'tell application id "com.pokai.Codync.dev" to quit'
+pkill -x "Codync Dev"
```
`pkill` can return nonzero when no process exists.
@@ -41,11 +41,10 @@ into their own sessions and unrelated hosts using other data directories are
outside this cleanup.
After rebuilding the host, restart the service (macOS launch agent shown; Linux
-uses the `codync-host` systemd user unit) and kill any `codync-host` still running
-from a different path. Test hosts you start yourself must be stopped when done:
+uses the environment-specific systemd user unit). Stop only test hosts you started; do not kill another environment's host. For Dev:
```sh
-launchctl kickstart -k gui/$(id -u)/com.pokai.codync.host
+launchctl kickstart -k gui/$(id -u)/com.pokai.codync.dev.host
pgrep -fl codync-host
```
@@ -55,16 +54,16 @@ Install Xcode and XcodeGen, then generate the project from its source. The Xcode
```sh
xcodegen generate --spec apps/project.yml
-xcodebuild build -project apps/Codync.xcodeproj -scheme iOS -configuration Debug -derivedDataPath build/dd -destination 'platform=iOS,id=<device-id>'
+xcodebuild build -project apps/Codync.xcodeproj -scheme "iOS Dev" -configuration DevDebug -derivedDataPath build/dd -destination 'platform=iOS,id=<device-id>'
```
-Use the `iOS` scheme with a connected device or simulator in Xcode. Do not edit `project.pbxproj` directly. Keep normal simulator signing: Clerk uses Keychain, and unsigned simulator builds can fail initialization with OSStatus -34018.
+Use `iOS Dev` for development and `iOS` for production, with a connected device or simulator in Xcode. Do not edit `project.pbxproj` directly. Keep normal simulator signing: Clerk uses Keychain, and unsigned simulator builds can fail initialization with OSStatus -34018.
Install the device build and replace the old iPhone process (substitute its device ID):
```sh
-xcrun devicectl device install app --device <device-id> build/dd/Build/Products/Debug-iphoneos/Codync.app
-xcrun devicectl device process launch --terminate-existing --device <device-id> com.pokai.Codync.ios
+xcrun devicectl device install app --device <device-id> "build/dd/Build/Products/DevDebug-iphoneos/Codync Dev.app"
+xcrun devicectl device process launch --terminate-existing --device <device-id> com.pokai.Codync.ios.dev
```
Unlock the phone when required. Build, install, launch, and visual inspection are separate checks; report which actually completed.
diff --git a/docs/guides/environments-and-deployment.md b/docs/guides/environments-and-deployment.md
index 9d15bad0..e9da5e8f 100644
--- a/docs/guides/environments-and-deployment.md
+++ b/docs/guides/environments-and-deployment.md
@@ -2,11 +2,13 @@
Reviewed against repository configuration on 2026-09-26; migration log updated 2026-10-07. Checked-in configuration does not prove that a deployment is healthy or that an external dashboard is configured.
+See [side-by-side Dev and production apps](dev-app.md) for schemes, identifiers, data isolation and the running-host/Offline troubleshooting checklist.
+
## Configuration ownership
| Layer | Source | Selection |
| --- | --- | --- |
-| Apple app | `apps/shared/Config/dev.plist`, `main.plist` | `project.yml` copies the selected file to bundled `AccountConfig.plist`; Debug uses dev, Release uses main |
+| Apple app | `apps/shared/Config/dev.plist`, `main.plist` | `project.yml` copies the selected file to bundled `AccountConfig.plist`; `iOS Dev` uses dev; `iOS` uses main |
| Account SDK | `apps/shared/AccountSession.swift` | Public Clerk configuration; development environment overrides are supported |
| Host | `host/src/remote/cloud.rs` | `CODYNC_CLOUD=off` or stored disable wins; then `CODYNC_CLOUD_URL`, then the build's cloud (`CODYNC_ENV` at compile time) |
| Cloud Worker / D1 / DO | `cloud/wrangler.toml` | Root production, `dev`, or `local` environment |
diff --git a/host/src/api/http.rs b/host/src/api/http.rs
index 91e4b9e4..4ee86c31 100644
--- a/host/src/api/http.rs
+++ b/host/src/api/http.rs
@@ -69,6 +69,7 @@ async fn health(State(hub): State<Arc<Hub>>) -> Json<Value> {
"computerId": hub.identity.computer_id(),
"version": env!("CARGO_PKG_VERSION"),
"binaryPath": crate::service::binary_identity().map(|(path, _)| path),
+ "environment": crate::environment::Environment::current().name(),
"binaryHash": crate::service::binary_identity().map(|(_, hash)| hash),
"busy": hub.busy(),
}))
diff --git a/host/src/bin/codync-hostw.rs b/host/src/bin/codync-hostw.rs
index 3793f482..d3116068 100644
--- a/host/src/bin/codync-hostw.rs
+++ b/host/src/bin/codync-hostw.rs
@@ -4,6 +4,11 @@
//! GUI-subsystem program, so signing in doesn't flash a console either.
#![cfg_attr(windows, windows_subsystem = "windows")]
+#[cfg(windows)]
+#[path = "../environment.rs"]
+#[allow(dead_code)]
+mod environment;
+
#[cfg(windows)]
fn main() {
use std::os::windows::process::CommandExt as _;
@@ -16,7 +21,7 @@ fn main() {
let args: Vec<_> = std::env::args_os().skip(1).collect();
let data = std::env::var_os("CODYNC_HOME")
.map(std::path::PathBuf::from)
- .or_else(|| dirs::home_dir().map(|h| h.join(".codync")));
+ .or_else(|| dirs::home_dir().map(|h| h.join(environment::Environment::current().data_folder())));
loop {
let mut command = std::process::Command::new(&host);
command.args(&args).creation_flags(CREATE_NO_WINDOW);
diff --git a/host/src/environment.rs b/host/src/environment.rs
new file mode 100644
index 00000000..bba9bc06
--- /dev/null
+++ b/host/src/environment.rs
@@ -0,0 +1,121 @@
+//! Build identity. Development and production must never own the same service or data.
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum Environment {
+ Main,
+ Dev,
+}
+
+impl Environment {
+ pub const fn current() -> Self {
+ match option_env!("CODYNC_ENV") {
+ Some(value) => match value.as_bytes() {
+ b"main" => Self::Main,
+ _ => Self::Dev,
+ },
+ None => Self::Dev,
+ }
+ }
+
+ pub const fn name(self) -> &'static str {
+ match self {
+ Self::Main => "main",
+ Self::Dev => "dev",
+ }
+ }
+
+ pub const fn port(self) -> u16 {
+ match self {
+ Self::Main => 19222,
+ Self::Dev => 19223,
+ }
+ }
+
+ pub const fn data_folder(self) -> &'static str {
+ match self {
+ Self::Main => ".codync",
+ Self::Dev => ".codync-dev",
+ }
+ }
+
+ pub const fn service_label(self) -> &'static str {
+ match self {
+ Self::Main => "com.pokai.codync.host",
+ Self::Dev => "com.pokai.codync.dev.host",
+ }
+ }
+
+ pub const fn systemd_unit(self) -> &'static str {
+ match self {
+ Self::Main => "codync-host.service",
+ Self::Dev => "codync-dev-host.service",
+ }
+ }
+
+ #[cfg(any(windows, test))]
+ pub const fn windows_value(self) -> &'static str {
+ match self {
+ Self::Main => "CodyncHost",
+ Self::Dev => "CodyncDevHost",
+ }
+ }
+
+ #[cfg(any(windows, test))]
+ pub const fn supervisor(self) -> &'static str {
+ match self {
+ Self::Main => "codync-hostw.exe",
+ Self::Dev => "codync-dev-hostw.exe",
+ }
+ }
+
+ pub const fn cloud_url(self) -> &'static str {
+ match self {
+ Self::Main => "https://api.codync.dev",
+ Self::Dev => "https://dev-api.codync.dev",
+ }
+ }
+
+ pub const fn url_scheme(self) -> &'static str {
+ match self {
+ Self::Main => "codync",
+ Self::Dev => "codync-dev",
+ }
+ }
+
+ pub fn require_release_updates(self) -> anyhow::Result<()> {
+ anyhow::ensure!(
+ self == Self::Main,
+ "Codync Dev does not install production updates; rebuild the development app"
+ );
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::Environment::{Dev, Main};
+
+ #[test]
+ fn development_cannot_replace_production_resources() {
+ assert_eq!(Main.port(), 19222);
+ assert_eq!(Main.data_folder(), ".codync");
+ assert_eq!(Main.service_label(), "com.pokai.codync.host");
+ assert_eq!(Main.systemd_unit(), "codync-host.service");
+ assert_eq!(Main.windows_value(), "CodyncHost");
+ assert_eq!(Main.supervisor(), "codync-hostw.exe");
+ assert_ne!(Main.port(), Dev.port());
+ for (main, dev) in [
+ (Main.data_folder(), Dev.data_folder()),
+ (Main.service_label(), Dev.service_label()),
+ (Main.systemd_unit(), Dev.systemd_unit()),
+ (Main.windows_value(), Dev.windows_value()),
+ (Main.supervisor(), Dev.supervisor()),
+ (Main.cloud_url(), Dev.cloud_url()),
+ (Main.url_scheme(), Dev.url_scheme()),
+ ] {
+ assert_ne!(main, dev);
+ }
+ assert!(Dev.require_release_updates().is_err());
+ assert!(Main.require_release_updates().is_ok());
+ }
+}
diff --git a/host/src/main.rs b/host/src/main.rs
index 15475ed6..59e81626 100644
--- a/host/src/main.rs
+++ b/host/src/main.rs
@@ -6,6 +6,7 @@ mod api;
mod background;
mod chat;
mod compat;
+mod environment;
mod hub;
mod market;
mod mcp;
@@ -369,6 +370,7 @@ async fn main() -> Result<()> {
// Windows: the shell Claude Code runs status lines in varies (Git Bash, PowerShell), so
// the line stays the user's; usage still comes from `claude -p /usage` and ACP.
if cfg!(unix)
+ && environment::Environment::current() == environment::Environment::Main
&& let Some(home) = dirs::home_dir()
{
match service::ensure_statusline(&home.join(".claude/settings.json")) {
@@ -384,7 +386,10 @@ async fn main() -> Result<()> {
Ok(())
}
Sub::Compat => {
- println!("{}", serde_json::json!({"version": env!("CARGO_PKG_VERSION"), "minApp": compat::MIN_APP}));
+ println!(
+ "{}",
+ serde_json::json!({"version": env!("CARGO_PKG_VERSION"), "minApp": compat::MIN_APP, "environment": environment::Environment::current().name()})
+ );
Ok(())
}
Sub::Update { check, status, auto, force, skip_app_check, port, json, worker } => {
@@ -437,7 +442,8 @@ async fn main() -> Result<()> {
}
Sub::Uninstall => {
service::uninstall();
- if let Some(home) = dirs::home_dir()
+ if environment::Environment::current() == environment::Environment::Main
+ && let Some(home) = dirs::home_dir()
&& let Err(e) = service::restore_statusline(&home.join(".claude/settings.json"))
{
eprintln!("Couldn't restore Claude Code's status line: {e:#}");
diff --git a/host/src/market/oauth.rs b/host/src/market/oauth.rs
index dc76d70b..2eaa7f23 100644
--- a/host/src/market/oauth.rs
+++ b/host/src/market/oauth.rs
@@ -83,7 +83,14 @@ fn loopback_uri(port: u16) -> String {
}
fn app_uri(store: &Store) -> Option<String> {
- crate::remote::cloud::url(store).map(|base| format!("{base}/v1/oauth/callback"))
+ crate::remote::cloud::url(store).map(|base| {
+ let suffix = if crate::environment::Environment::current() == crate::environment::Environment::Dev {
+ "/dev"
+ } else {
+ ""
+ };
+ format!("{base}/v1/oauth/callback{suffix}")
+ })
}
async fn get_json(url: &str) -> Result<Value> {
diff --git a/host/src/market/vault.rs b/host/src/market/vault.rs
index b0bf2f01..db0cece3 100644
--- a/host/src/market/vault.rs
+++ b/host/src/market/vault.rs
@@ -11,7 +11,10 @@ use std::sync::Arc;
use zeroize::Zeroizing;
const PREFIX: &str = "vault:v1:";
-const SERVICE: &str = "dev.codync.credentials";
+const SERVICE: &str = match crate::environment::Environment::current() {
+ crate::environment::Environment::Main => "dev.codync.credentials",
+ crate::environment::Environment::Dev => "dev.codync.development.credentials",
+};
pub async fn unlock(hub: Arc<crate::hub::Hub>) -> Result<()> {
if hub.store.secret_key.locked().is_some() {
diff --git a/host/src/remote/cloud.rs b/host/src/remote/cloud.rs
index 065f9fbc..050ae64b 100644
--- a/host/src/remote/cloud.rs
+++ b/host/src/remote/cloud.rs
@@ -20,7 +20,7 @@ use tokio::sync::watch;
/// release workflows), dev for every local build, debug or release, like the apps built next
/// to it.
fn build_cloud_url() -> &'static str {
- if option_env!("CODYNC_ENV") == Some("main") { "https://api.codync.dev" } else { "https://dev-api.codync.dev" }
+ crate::environment::Environment::current().cloud_url()
}
/// How long one successful state pull keeps an account device allowed.
diff --git a/host/src/screen/cua.rs b/host/src/screen/cua.rs
index b81116b8..521d4323 100644
--- a/host/src/screen/cua.rs
+++ b/host/src/screen/cua.rs
@@ -241,7 +241,11 @@ async fn start() -> Result<(tokio::process::Child, String)> {
fn endpoint_name() -> Result<String> {
use std::os::unix::fs::PermissionsExt;
let parent = std::env::var_os("XDG_RUNTIME_DIR").map_or_else(crate::service::data_dir, std::path::PathBuf::from);
- let dir = parent.join("codync-cua");
+ let folder = match crate::environment::Environment::current() {
+ crate::environment::Environment::Main => "codync-cua",
+ crate::environment::Environment::Dev => "codync-dev-cua",
+ };
+ let dir = parent.join(folder);
std::fs::create_dir_all(&dir)?;
std::fs::set_permissions(&dir, std::fs::Permissions::from_mode(0o700))?;
let socket = dir.join("cua.sock");
diff --git a/host/src/service/mod.rs b/host/src/service/mod.rs
index 398d26f4..779a635e 100644
--- a/host/src/service/mod.rs
+++ b/host/src/service/mod.rs
@@ -70,7 +70,7 @@ fn wait_for_host_exit() -> Result<()> {
}
}
-pub const DEFAULT_PORT: u16 = 19222;
+pub const DEFAULT_PORT: u16 = crate::environment::Environment::current().port();
/// Marker between our command and a wrapped user status line.
const STATUSLINE_MARK: &str = " statusline --";
@@ -80,7 +80,8 @@ pub(crate) fn home() -> PathBuf {
}
pub fn data_dir() -> PathBuf {
- std::env::var_os("CODYNC_HOME").map_or_else(|| home().join(".codync"), PathBuf::from)
+ std::env::var_os("CODYNC_HOME")
+ .map_or_else(|| home().join(crate::environment::Environment::current().data_folder()), PathBuf::from)
}
fn create_parent(file: &Path) -> Result<()> {
@@ -266,7 +267,8 @@ pub struct PairingQr<'a> {
pub fn pairing_url(q: &PairingQr) -> String {
let mut url = format!(
- "codync://pair?v=3&name={}&id={}&sk={}&bk={}&code={}&urls={}",
+ "{}://pair?v=3&name={}&id={}&sk={}&bk={}&code={}&urls={}",
+ crate::environment::Environment::current().url_scheme(),
pct(q.name),
q.computer_id,
q.sign_key,
@@ -391,7 +393,10 @@ mod tests {
};
assert_eq!(
pairing_url(&q),
- "codync://pair?v=3&name=Kevin%27s%20Mac&id=cid&sk=sk&bk=bk&code=c0de&urls=http%3A%2F%2F100.1.2.3%3A19222%2Chttp%3A%2F%2Fa%3A1"
+ format!(
+ "{}://pair?v=3&name=Kevin%27s%20Mac&id=cid&sk=sk&bk=bk&code=c0de&urls=http%3A%2F%2F100.1.2.3%3A19222%2Chttp%3A%2F%2Fa%3A1",
+ crate::environment::Environment::current().url_scheme()
+ )
);
q.cloud = Some("https://cloud.example");
assert!(pairing_url(&q).ends_with("&cloud=https%3A%2F%2Fcloud.example"));
diff --git a/host/src/service/unix.rs b/host/src/service/unix.rs
index 93c4bdfc..a01e5009 100644
--- a/host/src/service/unix.rs
+++ b/host/src/service/unix.rs
@@ -5,7 +5,8 @@ use anyhow::{Context, Result, bail};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
-const LABEL: &str = "com.pokai.codync.host";
+const LABEL: &str = crate::environment::Environment::current().service_label();
+const UNIT: &str = crate::environment::Environment::current().systemd_unit();
/// Stops the installed job, preserving its configuration for a later start.
/// A manually started daemon is never mistaken for the service we own.
@@ -16,7 +17,7 @@ pub fn stop() -> Result<()> {
.stderr(Stdio::null())
.status()?;
} else if installed() {
- run("systemctl", &["--user", "stop", "codync-host.service"])?;
+ run("systemctl", &["--user", "stop", UNIT])?;
}
wait_for_host_exit()
}
@@ -25,7 +26,7 @@ pub fn start() -> Result<()> {
if cfg!(target_os = "macos") {
run("launchctl", &["bootstrap", &format!("gui/{}", current_uid()), &launchd_plist().to_string_lossy()])
} else {
- run("systemctl", &["--user", "start", "codync-host.service"])
+ run("systemctl", &["--user", "start", UNIT])
}
}
@@ -58,7 +59,7 @@ fn launchd_plist() -> PathBuf {
}
fn systemd_unit() -> PathBuf {
- dirs::config_dir().unwrap_or_else(|| home().join(".config")).join("systemd/user/codync-host.service")
+ dirs::config_dir().unwrap_or_else(|| home().join(".config")).join("systemd/user").join(UNIT)
}
fn xml_escape(s: &str) -> String {
@@ -81,7 +82,7 @@ pub fn install(port: u16) -> Result<()> {
<dict>
<key>Label</key><string>{LABEL}</string>
<key>ProgramArguments</key><array><string>{exe}</string><string>serve</string><string>--port</string><string>{port}</string></array>
- <key>EnvironmentVariables</key><dict><key>PATH</key><string>{path}</string></dict>
+ <key>EnvironmentVariables</key><dict><key>PATH</key><string>{path}</string><key>CODYNC_HOME</key><string>{data}</string></dict>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>ProcessType</key><string>Interactive</string>
@@ -92,6 +93,7 @@ pub fn install(port: u16) -> Result<()> {
"#,
exe = xml_escape(&exe),
path = xml_escape(&path),
+ data = xml_escape(&data_dir().to_string_lossy()),
log = xml_escape(&log.to_string_lossy()),
);
let file = launchd_plist();
@@ -105,15 +107,16 @@ pub fn install(port: u16) -> Result<()> {
run("launchctl", &["bootstrap", &format!("gui/{uid}"), &file.to_string_lossy()])?;
} else {
let unit = format!(
- "[Unit]\nDescription=Codync host\nAfter=network-online.target\n\n[Service]\nExecStart={exe} serve --port {port}\nEnvironment=PATH={path}\nRestart=always\nRestartSec=3\n\n[Install]\nWantedBy=default.target\n"
+ "[Unit]\nDescription=Codync host\nAfter=network-online.target\n\n[Service]\nExecStart={exe} serve --port {port}\nEnvironment=PATH={path}\nEnvironment=\"CODYNC_HOME={data}\"\nRestart=always\nRestartSec=3\n\n[Install]\nWantedBy=default.target\n",
+ data = data_dir().display(),
);
let file = systemd_unit();
create_parent(&file)?;
std::fs::write(&file, unit).with_context(|| format!("writing {}", file.display()))?;
run("systemctl", &["--user", "daemon-reload"])?;
- run("systemctl", &["--user", "stop", "codync-host.service"])?;
+ run("systemctl", &["--user", "stop", UNIT])?;
wait_for_host_exit()?;
- run("systemctl", &["--user", "enable", "--now", "codync-host.service"])?;
+ run("systemctl", &["--user", "enable", "--now", UNIT])?;
println!("Tip: `loginctl enable-linger $USER` keeps the host running while you're logged out.");
}
Ok(())
@@ -128,7 +131,7 @@ pub fn uninstall() {
.status();
let _ = std::fs::remove_file(launchd_plist());
} else {
- let _ = run("systemctl", &["--user", "disable", "--now", "codync-host.service"]);
+ let _ = run("systemctl", &["--user", "disable", "--now", UNIT]);
let _ = std::fs::remove_file(systemd_unit());
let _ = run("systemctl", &["--user", "daemon-reload"]);
}
diff --git a/host/src/service/windows.rs b/host/src/service/windows.rs
index f54ef71e..a2d28021 100644
--- a/host/src/service/windows.rs
+++ b/host/src/service/windows.rs
@@ -9,8 +9,8 @@ use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
const RUN_KEY: &str = r"HKCU\Software\Microsoft\Windows\CurrentVersion\Run";
-const VALUE: &str = "CodyncHost";
-const SUPERVISOR: &str = "codync-hostw.exe";
+const VALUE: &str = crate::environment::Environment::current().windows_value();
+const SUPERVISOR: &str = crate::environment::Environment::current().supervisor();
const HOST: &str = "codync-host.exe";
const DETACHED_PROCESS: u32 = 0x0000_0008;
diff --git a/host/src/tui/view/pair.rs b/host/src/tui/view/pair.rs
index d224ba75..794c2c7c 100644
--- a/host/src/tui/view/pair.rs
+++ b/host/src/tui/view/pair.rs
@@ -43,7 +43,11 @@ pub(super) fn pair(buf: &mut Buffer, area: Rect, url: Option<&str>) {
inner.x,
y,
inner.width,
- "Scan with the Codync iPhone app, or open on the phone:",
+ if url.starts_with("codync-dev:") {
+ "Scan with Codync Dev on your iPhone:"
+ } else {
+ "Scan with the Codync iPhone app, or open on the phone:"
+ },
t.secondary.patch(t.panel),
);
put(buf, inner.x, y + 1, inner.width, &truncate(url, usize::from(inner.width)), t.dim.patch(t.panel));
diff --git a/host/src/update/mod.rs b/host/src/update/mod.rs
index 90a8a20e..c48117f5 100644
--- a/host/src/update/mod.rs
+++ b/host/src/update/mod.rs
@@ -75,6 +75,7 @@ fn status_at(executable: &Path) -> Result<Value> {
pub fn set_automatic(enabled: bool) -> Result<Value> {
let executable = service::current_exe()?;
if enabled {
+ crate::environment::Environment::current().require_release_updates()?;
install::require_standalone(&executable)?;
ensure!(service::installed(), "install the background host service before enabling automatic updates");
service::require_executable(&executable)?;
@@ -84,6 +85,7 @@ pub fn set_automatic(enabled: bool) -> Result<Value> {
}
pub async fn check() -> Result<Value> {
+ crate::environment::Environment::current().require_release_updates()?;
let _lock = lock()?;
let mut state: State = read("update-state.json")?;
ensure!(!awaiting_worker(&state), "a host update is starting");
@@ -115,6 +117,7 @@ pub async fn check() -> Result<Value> {
}
pub async fn apply(port: u16, force: bool, skip_app_check: bool, worker: bool) -> Result<Value> {
+ crate::environment::Environment::current().require_release_updates()?;
let deadline = tokio::time::Instant::now() + Duration::from_secs(5);
let _lock = loop {
match lock() {
@@ -168,6 +171,7 @@ pub async fn apply(port: u16, force: bool, skip_app_check: bool, worker: bool) -
/// The updater must live outside the daemon's job/cgroup. Otherwise stopping
/// the host would also kill the process responsible for starting its replacement.
pub fn spawn_worker(port: u16, force: bool, skip_app_check: bool) -> Result<()> {
+ crate::environment::Environment::current().require_release_updates()?;
let _lock = lock()?;
let previous: State = read("update-state.json")?;
ensure!(!awaiting_worker(&previous), "a host update is already starting");
@@ -234,6 +238,9 @@ fn spawn_job(executable: &Path, args: &[String]) -> Result<()> {
}
pub async fn automatic_loop(hub: Arc<Hub>) {
+ if crate::environment::Environment::current() != crate::environment::Environment::Main {
+ return;
+ }
let mut last_check = None;
let mut last_store_probe = None;
loop {
diff --git a/relay/src/index.ts b/relay/src/index.ts
index 9c908746..1291c3be 100644
--- a/relay/src/index.ts
+++ b/relay/src/index.ts
@@ -24,7 +24,7 @@ export interface Env {
type ApnsEnv = "sandbox" | "production";
type Kind = "alert" | "liveactivity";
-interface TicketPayload { t: string; e: ApnsEnv; k: Kind }
+interface TicketPayload { t: string; e: ApnsEnv; k: Kind; b?: string }
const BUNDLE_ID = "com.pokai.Codync.ios";
@@ -73,15 +73,22 @@ export async function openTicket(env: Env, ticket: string): Promise<TicketPayloa
const clients = new Map<string, ApnsClient>();
-function client(env: Env, apnsEnv: ApnsEnv, kind: Kind): ApnsClient {
- const id = `${env.APNS_KEY_ID}:${apnsEnv}:${kind}`;
+export function apnsTopic(bundleId: string | undefined, kind: Kind): string {
+ const bundle = bundleId ?? BUNDLE_ID;
+ if (bundle !== BUNDLE_ID && bundle !== `${BUNDLE_ID}.dev`) throw new Error("invalid bundle identifier");
+ return kind === "liveactivity" ? `${bundle}.push-type.liveactivity` : bundle;
+}
+
+function client(env: Env, apnsEnv: ApnsEnv, kind: Kind, bundleId?: string): ApnsClient {
+ const topic = apnsTopic(bundleId, kind);
+ const id = `${env.APNS_KEY_ID}:${apnsEnv}:${topic}`;
let c = clients.get(id);
if (!c) {
c = new ApnsClient({
team: env.APNS_TEAM_ID,
keyId: env.APNS_KEY_ID,
signingKey: env.APNS_SIGNING_KEY.replace(/\\n/g, "\n"),
- defaultTopic: kind === "liveactivity" ? `${BUNDLE_ID}.push-type.liveactivity` : BUNDLE_ID,
+ defaultTopic: topic,
host: apnsEnv === "production" ? "api.push.apple.com" : "api.sandbox.push.apple.com",
});
clients.set(id, c);
@@ -92,13 +99,14 @@ function client(env: Env, apnsEnv: ApnsEnv, kind: Kind): ApnsClient {
const json = (body: unknown, status = 200) => Response.json(body, { status });
async function register(req: Request, env: Env): Promise<Response> {
- const body = (await req.json().catch(() => null)) as { token?: string; env?: string; kind?: string } | null;
+ const body = (await req.json().catch(() => null)) as { token?: string; env?: string; kind?: string; bundleId?: string } | null;
if (typeof body?.token !== "string" || !/^(?:[0-9a-fA-F]{2}){16,100}$/.test(body.token)) return json({ error: "invalid token" }, 400);
if (body.env !== "production" && body.env !== "sandbox") return json({ error: "invalid environment" }, 400);
if (body.kind !== "alert" && body.kind !== "liveactivity") return json({ error: "invalid kind" }, 400);
+ if (body.bundleId !== undefined && body.bundleId !== BUNDLE_ID && body.bundleId !== `${BUNDLE_ID}.dev`) return json({ error: "invalid bundle identifier" }, 400);
const e: ApnsEnv = body.env;
const k: Kind = body.kind === "liveactivity" ? "liveactivity" : "alert";
- return json({ ticket: await sealTicket(env, { t: body.token, e, k }) });
+ return json({ ticket: await sealTicket(env, { t: body.token, e, k, ...(body.bundleId ? { b: body.bundleId } : {}) }) });
}
export interface PushBody {
@@ -171,14 +179,14 @@ async function push(req: Request, env: Env): Promise<Response> {
if (new TextEncoder().encode(JSON.stringify(notification.buildApnsOptions())).length > 4096) {
return json({ error: "payload too large" }, 413);
}
- await client(env, t.e, "alert").send(notification);
+ await client(env, t.e, "alert", t.b).send(notification);
} else {
const la = body.liveActivity;
if (!la) return json({ error: "liveActivity required" }, 400);
let aps: Record<string, unknown>;
try { aps = liveActivityAps(la); }
catch { return json({ error: "invalid liveActivity" }, 400); }
- await client(env, t.e, "liveactivity").send(
+ await client(env, t.e, "liveactivity", t.b).send(
new Notification(t.t, {
type: PushType.liveactivity,
priority: la.event === "end" || la.contentState?.status === "needsInput" ? Priority.immediate : Priority.throttled,
@@ -203,7 +211,7 @@ async function push(req: Request, env: Env): Promise<Response> {
export function latestTicketIndices(tickets: Array<TicketPayload | null>): Set<number> {
const latest = new Map<string, number>();
tickets.forEach((ticket, index) => {
- if (ticket) latest.set(`${ticket.e}:${ticket.k}:${ticket.t.toLowerCase()}`, index);
+ if (ticket) latest.set(`${ticket.b ?? BUNDLE_ID}:${ticket.e}:${ticket.k}:${ticket.t.toLowerCase()}`, index);
});
return new Set(latest.values());
}
diff --git a/relay/test/ticket.test.ts b/relay/test/ticket.test.ts
index 3c319546..23fd332c 100644
--- a/relay/test/ticket.test.ts
+++ b/relay/test/ticket.test.ts
@@ -1,6 +1,6 @@
// Ticket round-trip: sealed tickets open with the same key and fail with another.
import assert from "node:assert/strict";
-import { sealTicket, openTicket } from "../src/index.ts";
+import worker, { sealTicket, openTicket, apnsTopic, latestTicketIndices } from "../src/index.ts";
const key = btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(32))));
const env = { TICKET_KEY: key } as any;
@@ -10,3 +10,19 @@ const other = { TICKET_KEY: btoa(String.fromCharCode(...new Uint8Array(32))) } a
assert.equal(await openTicket(other, ticket), null);
assert.equal(await openTicket(env, ticket.slice(0, -2) + "AA"), null);
console.log("ticket tests ok");
+
+const registration = { token: "ab".repeat(32), env: "sandbox", kind: "alert", bundleId: "com.pokai.Codync.ios.dev" };
+const response = await worker.fetch(new Request("https://relay.test/register", { method: "POST", body: JSON.stringify(registration) }), env);
+assert.equal(response.status, 200);
+const registered = await response.json() as { ticket: string };
+assert.equal((await openTicket(env, registered.ticket))?.b, registration.bundleId);
+assert.equal(apnsTopic(undefined, "alert"), "com.pokai.Codync.ios");
+assert.equal(apnsTopic(registration.bundleId, "liveactivity"), "com.pokai.Codync.ios.dev.push-type.liveactivity");
+assert.throws(() => apnsTopic("another.app", "alert"));
+const invalid = await worker.fetch(new Request("https://relay.test/register", { method: "POST", body: JSON.stringify({ ...registration, bundleId: "another.app" }) }), env);
+assert.equal(invalid.status, 400);
+assert.deepEqual([...latestTicketIndices([
+ { t: "ab", e: "sandbox", k: "alert" },
+ { t: "ab", e: "sandbox", k: "alert", b: registration.bundleId },
+])], [0, 1]);
+console.log("development push destinations stay isolated; existing tickets retain production topic");