fix(swift-ios): isolate development installs
This commit is contained in:
15 files changed
+78
-32
No files matched your search
@@ -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)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>T3 Code (SwiftUI)</string>
|
||||
<string>$(T3CODE_SHARE_DISPLAY_NAME)</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.t3tools.t3code.swiftui</string>
|
||||
<string>$(T3CODE_APP_GROUP_IDENTIFIER)</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -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(
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<string>$(APS_ENVIRONMENT)</string>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.t3tools.t3code.swiftui</string>
|
||||
<string>$(T3CODE_APP_GROUP_IDENTIFIER)</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -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"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>T3 Code Widgets</string>
|
||||
<string>$(T3CODE_WIDGET_DISPLAY_NAME)</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.t3tools.t3code.swiftui</string>
|
||||
<string>$(T3CODE_APP_GROUP_IDENTIFIER)</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -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
|
||||
}
|
||||
|
||||
+18
-10
@@ -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
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<string>T3 Code SwiftUI Routes</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>t3code-swiftui</string>
|
||||
<string>$(T3CODE_URL_SCHEME)</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user