diff --git a/apps/swift-ios/App/Platform/PlatformDeepLinks.swift b/apps/swift-ios/App/Platform/PlatformDeepLinks.swift index 70caaade2b..94d96d9416 100644 --- a/apps/swift-ios/App/Platform/PlatformDeepLinks.swift +++ b/apps/swift-ios/App/Platform/PlatformDeepLinks.swift @@ -1,7 +1,11 @@ import Foundation enum PlatformRoute: Codable, Hashable, Identifiable, Sendable { + #if DEBUG + static let nativeScheme = "t3code-swiftui-dev" + #else static let nativeScheme = "t3code-swiftui" + #endif case connection(endpoint: String, token: String?) case environment(id: String) @@ -93,7 +97,7 @@ enum PlatformDeepLinkParser { } let query = queryValues(components.queryItems ?? []) - if ["t3", "t3code", PlatformRoute.nativeScheme].contains(scheme) { + if ["t3", "t3code", "t3code-swiftui", "t3code-swiftui-dev"].contains(scheme) { let segments = customSchemeSegments(components) if isConnectionRoute(segments: segments, query: query) { return try connectionRoute(url) diff --git a/apps/swift-ios/Extensions/Share/Info.plist b/apps/swift-ios/Extensions/Share/Info.plist index 48b76a5d52..6911ccde2d 100644 --- a/apps/swift-ios/Extensions/Share/Info.plist +++ b/apps/swift-ios/Extensions/Share/Info.plist @@ -3,7 +3,7 @@ CFBundleDisplayName - T3 Code (SwiftUI) + $(T3CODE_SHARE_DISPLAY_NAME) NSExtension NSExtensionAttributes diff --git a/apps/swift-ios/Extensions/Share/T3CodeShare.entitlements b/apps/swift-ios/Extensions/Share/T3CodeShare.entitlements index 471530405f..87c87298c6 100644 --- a/apps/swift-ios/Extensions/Share/T3CodeShare.entitlements +++ b/apps/swift-ios/Extensions/Share/T3CodeShare.entitlements @@ -4,7 +4,7 @@ com.apple.security.application-groups - group.com.t3tools.t3code.swiftui + $(T3CODE_APP_GROUP_IDENTIFIER) diff --git a/apps/swift-ios/Extensions/Shared/SharedContainer.swift b/apps/swift-ios/Extensions/Shared/SharedContainer.swift index 276a505671..751016113c 100644 --- a/apps/swift-ios/Extensions/Shared/SharedContainer.swift +++ b/apps/swift-ios/Extensions/Shared/SharedContainer.swift @@ -1,8 +1,13 @@ import Foundation enum T3SharedContainer { + #if DEBUG + static let appGroupID = "group.com.t3tools.t3code.swiftui.dev" + static let urlScheme = "t3code-swiftui-dev" + #else static let appGroupID = "group.com.t3tools.t3code.swiftui" static let urlScheme = "t3code-swiftui" + #endif static var rootURL: URL? { FileManager.default.containerURL( diff --git a/apps/swift-ios/Extensions/Shared/T3Code.entitlements b/apps/swift-ios/Extensions/Shared/T3Code.entitlements index 223fe3b909..69f2cfd997 100644 --- a/apps/swift-ios/Extensions/Shared/T3Code.entitlements +++ b/apps/swift-ios/Extensions/Shared/T3Code.entitlements @@ -6,7 +6,7 @@ $(APS_ENVIRONMENT) com.apple.security.application-groups - group.com.t3tools.t3code.swiftui + $(T3CODE_APP_GROUP_IDENTIFIER) diff --git a/apps/swift-ios/Extensions/Tests/ExtensionContractTests.swift b/apps/swift-ios/Extensions/Tests/ExtensionContractTests.swift index 519dde1f40..3e531463fc 100644 --- a/apps/swift-ios/Extensions/Tests/ExtensionContractTests.swift +++ b/apps/swift-ios/Extensions/Tests/ExtensionContractTests.swift @@ -16,7 +16,7 @@ final class ExtensionContractTests: XCTestCase { XCTAssertEqual(aggregate.attentionFirstActivities.first?.threadId, "thread-approval") XCTAssertEqual( aggregate.attentionFirstActivities.first?.nativeDeepLinkURL?.absoluteString, - "t3code-swiftui://threads?environment=env-2&thread=thread-approval" + "\(T3SharedContainer.urlScheme)://threads?environment=env-2&thread=thread-approval" ) } diff --git a/apps/swift-ios/Extensions/Widgets/Info.plist b/apps/swift-ios/Extensions/Widgets/Info.plist index 9a6f063b27..d31f30c5f6 100644 --- a/apps/swift-ios/Extensions/Widgets/Info.plist +++ b/apps/swift-ios/Extensions/Widgets/Info.plist @@ -3,7 +3,7 @@ CFBundleDisplayName - T3 Code Widgets + $(T3CODE_WIDGET_DISPLAY_NAME) NSExtension NSExtensionPointIdentifier diff --git a/apps/swift-ios/Extensions/Widgets/T3CodeWidgets.entitlements b/apps/swift-ios/Extensions/Widgets/T3CodeWidgets.entitlements index 471530405f..87c87298c6 100644 --- a/apps/swift-ios/Extensions/Widgets/T3CodeWidgets.entitlements +++ b/apps/swift-ios/Extensions/Widgets/T3CodeWidgets.entitlements @@ -4,7 +4,7 @@ com.apple.security.application-groups - group.com.t3tools.t3code.swiftui + $(T3CODE_APP_GROUP_IDENTIFIER) diff --git a/apps/swift-ios/Features/Connection/ConnectionDetails.swift b/apps/swift-ios/Features/Connection/ConnectionDetails.swift index d4ecff1a22..be783aafb2 100644 --- a/apps/swift-ios/Features/Connection/ConnectionDetails.swift +++ b/apps/swift-ios/Features/Connection/ConnectionDetails.swift @@ -118,7 +118,7 @@ enum ConnectionDetailsParser { let allItems = queryItems + fragmentItems let token = firstValue(named: tokenNames, in: allItems) - if ["t3", "t3code", "t3code-swiftui"].contains(scheme) { + if ["t3", "t3code", "t3code-swiftui", "t3code-swiftui-dev"].contains(scheme) { if let wrappedPairingURL = firstValue(named: wrappedPairingURLNames, in: allItems) { var wrapped = try parse(wrappedPairingURL) if wrapped.pairingCode == nil { @@ -159,7 +159,7 @@ enum ConnectionDetailsParser { private static func firstURL(in input: String) -> String? { guard let expression = try? NSRegularExpression( - pattern: #"(?i)(?:(?:https?|wss?|t3)://|t3code(?:-swiftui)?:(?://)?)[^\s<>"']+"# + pattern: #"(?i)(?:(?:https?|wss?|t3)://|t3code(?:-swiftui(?:-dev)?)?:(?://)?)[^\s<>"']+"# ) else { return nil } diff --git a/apps/swift-ios/README.md b/apps/swift-ios/README.md index 510cee96f8..09cde68bd0 100644 --- a/apps/swift-ios/README.md +++ b/apps/swift-ios/README.md @@ -71,7 +71,6 @@ Info.plist: | `T3CODE_CLERK_JWT_TEMPLATE` | No | Relay JWT template; defaults to `t3-relay`. | | `T3CODE_RELAY_URL` | T3 Connect only | Relay base URL using HTTPS. | | `DEVELOPMENT_TEAM` | Device/archive | Apple Developer team used by automatic signing. | -| `PRODUCT_BUNDLE_IDENTIFIER` | No | Defaults to `com.t3tools.t3code.swiftui`. | | `MARKETING_VERSION` | Release | User-facing version. | | `CURRENT_PROJECT_VERSION` | Release | Monotonically increasing build number. | @@ -79,8 +78,17 @@ Unset T3 Connect values disable that connection method without affecting direct pairing. Supply settings on the `xcodebuild` command line or through a local `.xcconfig`; do not commit private release configuration. -This app registers only the `t3code-swiftui` URL scheme so its routes do not -collide with another installed T3 Code client. +Debug and Release use separate identities so a local build can remain installed +beside TestFlight: + +| Configuration | Display name | Bundle identifier | URL scheme | +| ------------- | --------------------- | -------------------------------- | -------------------- | +| Debug | T3 Code (SwiftUI Dev) | `com.t3tools.t3code.swiftui.dev` | `t3code-swiftui-dev` | +| Release | T3 Code (SwiftUI) | `com.t3tools.t3code.swiftui` | `t3code-swiftui` | + +Each identity also has matching widget and share-extension bundle identifiers +and a separate App Group. Debug data and credentials therefore do not alter the +TestFlight installation. ## Verify @@ -108,13 +116,13 @@ T3_SWIFT_DEVELOPMENT_TEAM="TEAMID1234" \ ./Scripts/install-device.sh ``` -The script builds, provisions, installs, and launches the app. It accepts the T3 -Connect build settings above as environment variables. Optional overrides are -`T3_SWIFT_CONFIGURATION`, `T3_SWIFT_DERIVED_DATA_PATH`, `T3_SWIFT_VERSION`, and -`T3_SWIFT_BUILD_NUMBER`. The app and extension bundle identifiers stay fixed so -automatic signing provisions their shared App Group consistently. Run with -`T3_SWIFT_VERIFY_BUNDLE_IDENTIFIERS_ONLY=1` to verify those settings without a -device build. +The script builds, provisions, installs, and launches the Debug identity by +default. Set `T3_SWIFT_CONFIGURATION=Release` for the TestFlight identity. It +accepts the T3 Connect build settings above as environment variables. Optional +overrides are `T3_SWIFT_DERIVED_DATA_PATH`, `T3_SWIFT_VERSION`, and +`T3_SWIFT_BUILD_NUMBER`. Run with +`T3_SWIFT_VERIFY_BUNDLE_IDENTIFIERS_ONLY=1` to verify the configuration's host +and extension bundle identifiers without a device build. ## Release checklist diff --git a/apps/swift-ios/Resources/Info.plist b/apps/swift-ios/Resources/Info.plist index 080b3d57d2..3262cb2bc2 100644 --- a/apps/swift-ios/Resources/Info.plist +++ b/apps/swift-ios/Resources/Info.plist @@ -15,7 +15,7 @@ T3 Code SwiftUI Routes CFBundleURLSchemes - t3code-swiftui + $(T3CODE_URL_SCHEME) diff --git a/apps/swift-ios/Scripts/install-device.sh b/apps/swift-ios/Scripts/install-device.sh index 333f86d6c7..091d96365d 100755 --- a/apps/swift-ios/Scripts/install-device.sh +++ b/apps/swift-ios/Scripts/install-device.sh @@ -7,9 +7,6 @@ APP_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" DEVICE_ID="${T3_SWIFT_DEVICE_ID:-${1:-}}" DEVELOPMENT_TEAM="${T3_SWIFT_DEVELOPMENT_TEAM:-${2:-}}" CONFIGURATION="${T3_SWIFT_CONFIGURATION:-Debug}" -BUNDLE_IDENTIFIER="com.t3tools.t3code.swiftui" -WIDGET_BUNDLE_IDENTIFIER="${BUNDLE_IDENTIFIER}.widgets" -SHARE_BUNDLE_IDENTIFIER="${BUNDLE_IDENTIFIER}.sharing" DERIVED_DATA_PATH="${T3_SWIFT_DERIVED_DATA_PATH:-${APP_DIR}/.derivedData/device}" die() { @@ -27,8 +24,19 @@ require_cmd plutil require_cmd xcodebuild require_cmd xcrun +[[ "${CONFIGURATION}" == "Debug" || "${CONFIGURATION}" == "Release" ]] || die \ + "T3_SWIFT_CONFIGURATION must be Debug or Release" + +if [[ "${CONFIGURATION}" == "Debug" ]]; then + BUNDLE_IDENTIFIER="com.t3tools.t3code.swiftui.dev" +else + BUNDLE_IDENTIFIER="com.t3tools.t3code.swiftui" +fi +WIDGET_BUNDLE_IDENTIFIER="${BUNDLE_IDENTIFIER}.widgets" +SHARE_BUNDLE_IDENTIFIER="${BUNDLE_IDENTIFIER}.sharing" + [[ -z "${T3_SWIFT_BUNDLE_IDENTIFIER:-}" || "${T3_SWIFT_BUNDLE_IDENTIFIER}" == "${BUNDLE_IDENTIFIER}" ]] || die \ - "custom bundle identifiers are unsupported because this app and its extensions share a fixed App Group" + "custom bundle identifiers are unsupported; select the Debug or Release identity with T3_SWIFT_CONFIGURATION" bundle_identifier_for_target() { local target="$1" @@ -63,8 +71,6 @@ fi "set T3_SWIFT_DEVICE_ID to a CoreDevice identifier or UDID from 'xcrun devicectl list devices --columns UDID'" [[ -n "${DEVELOPMENT_TEAM}" ]] || die \ "set T3_SWIFT_DEVELOPMENT_TEAM to your Apple Developer team ID" -[[ "${CONFIGURATION}" == "Debug" || "${CONFIGURATION}" == "Release" ]] || die \ - "T3_SWIFT_CONFIGURATION must be Debug or Release" build_settings=( "DEVELOPMENT_TEAM=${DEVELOPMENT_TEAM}" diff --git a/apps/swift-ios/T3Code.xcodeproj/project.pbxproj b/apps/swift-ios/T3Code.xcodeproj/project.pbxproj index 8d7bf13f21..52d1b8434e 100644 --- a/apps/swift-ios/T3Code.xcodeproj/project.pbxproj +++ b/apps/swift-ios/T3Code.xcodeproj/project.pbxproj @@ -607,7 +607,7 @@ ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Resources/Info.plist; - INFOPLIST_KEY_CFBundleDisplayName = "T3 Code (SwiftUI)"; + INFOPLIST_KEY_CFBundleDisplayName = "T3 Code (SwiftUI Dev)"; INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; INFOPLIST_KEY_NSAppTransportSecurity_NSAllowsArbitraryLoads = YES; @@ -627,13 +627,15 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 0.1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.t3tools.t3code.swiftui; + PRODUCT_BUNDLE_IDENTIFIER = com.t3tools.t3code.swiftui.dev; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; + T3CODE_APP_GROUP_IDENTIFIER = group.com.t3tools.t3code.swiftui.dev; + T3CODE_URL_SCHEME = t3code-swiftui-dev; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -677,6 +679,8 @@ SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; + T3CODE_APP_GROUP_IDENTIFIER = group.com.t3tools.t3code.swiftui; + T3CODE_URL_SCHEME = t3code-swiftui; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -733,7 +737,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 0.1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.t3tools.t3code.swiftui.widgets; + PRODUCT_BUNDLE_IDENTIFIER = com.t3tools.t3code.swiftui.dev.widgets; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -741,6 +745,8 @@ SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; + T3CODE_APP_GROUP_IDENTIFIER = group.com.t3tools.t3code.swiftui.dev; + T3CODE_WIDGET_DISPLAY_NAME = "T3 Code Dev Widgets"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -771,6 +777,8 @@ SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; + T3CODE_APP_GROUP_IDENTIFIER = group.com.t3tools.t3code.swiftui; + T3CODE_WIDGET_DISPLAY_NAME = "T3 Code Widgets"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -793,7 +801,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 0.1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.t3tools.t3code.swiftui.sharing; + PRODUCT_BUNDLE_IDENTIFIER = com.t3tools.t3code.swiftui.dev.sharing; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -801,6 +809,8 @@ SUPPORTS_MACCATALYST = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; + T3CODE_APP_GROUP_IDENTIFIER = group.com.t3tools.t3code.swiftui.dev; + T3CODE_SHARE_DISPLAY_NAME = "T3 Code (SwiftUI Dev)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -831,6 +841,8 @@ SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; + T3CODE_APP_GROUP_IDENTIFIER = group.com.t3tools.t3code.swiftui; + T3CODE_SHARE_DISPLAY_NAME = "T3 Code (SwiftUI)"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; diff --git a/apps/swift-ios/Tests/FeatureTests/ConnectionDetailsTests.swift b/apps/swift-ios/Tests/FeatureTests/ConnectionDetailsTests.swift index 6ec8f0365f..9ec0dfab84 100644 --- a/apps/swift-ios/Tests/FeatureTests/ConnectionDetailsTests.swift +++ b/apps/swift-ios/Tests/FeatureTests/ConnectionDetailsTests.swift @@ -26,6 +26,8 @@ struct ConnectionDetailsTests { @Test(arguments: [ "t3code://pair?pairingUrl=https%3A%2F%2Fremote.example.com%2Fpair%23token%3Dpairing-token", "t3code:?pairingUrl=https%3A%2F%2Fremote.example.com%2Fpair%23token%3Dpairing-token", + "t3code-swiftui://pair?pairingUrl=https%3A%2F%2Fremote.example.com%2Fpair%23token%3Dpairing-token", + "t3code-swiftui-dev://pair?pairingUrl=https%3A%2F%2Fremote.example.com%2Fpair%23token%3Dpairing-token", ]) func unwrapsMobileQRCode(_ payload: String) throws { let details = try ConnectionDetailsParser.parse(payload) diff --git a/apps/swift-ios/Tests/PlatformTests/PlatformDeepLinkTests.swift b/apps/swift-ios/Tests/PlatformTests/PlatformDeepLinkTests.swift index 0db247b710..20def4d9da 100644 --- a/apps/swift-ios/Tests/PlatformTests/PlatformDeepLinkTests.swift +++ b/apps/swift-ios/Tests/PlatformTests/PlatformDeepLinkTests.swift @@ -76,12 +76,21 @@ struct PlatformDeepLinkTests { for route in routes { let url = try #require(route.url) #expect(url.scheme == PlatformRoute.nativeScheme) - #expect(try PlatformDeepLinkParser.parse(url) == route) + let parsed = try PlatformDeepLinkParser.parse(url) + #expect(parsed == route, "Failed to round-trip \(route) through \(url.absoluteString)") } } @Test - func acceptsLegacyRoutesWithoutClaimingTheirSharedSchemes() throws { + func acceptsLinksFromBothSwiftUIIdentitiesAndLegacyRoutes() throws { + #expect( + try PlatformDeepLinkParser.parse("t3code-swiftui://threads/environment/thread") + == .thread(environmentID: "environment", threadID: "thread") + ) + #expect( + try PlatformDeepLinkParser.parse("t3code-swiftui-dev://threads/environment/thread") + == .thread(environmentID: "environment", threadID: "thread") + ) #expect( try PlatformDeepLinkParser.parse("t3code://threads/environment/thread") == .thread(environmentID: "environment", threadID: "thread")