diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml
new file mode 100644
index 00000000..51e93c73
--- /dev/null
+++ b/.github/workflows/check.yaml
@@ -0,0 +1,114 @@
+name: Check
+
+on:
+ workflow_dispatch:
+ pull_request:
+ push:
+ branches:
+ - main
+jobs:
+ lint:
+ runs-on: macos-latest
+
+ # From actions/cache documentation linked to below
+ env:
+ MINT_PATH: .mint/lib
+ MINT_LINK_PATH: .mint/bin
+
+ steps:
+ - uses: actions/checkout@v4
+
+ # We use caching for Mint because at the time of writing SwiftLint took about 5 minutes to build in CI, which is unacceptably slow.
+ # https://github.com/actions/cache/blob/40c3b67b2955d93d83b27ed164edd0756bc24049/examples.md#swift---mint
+ - uses: actions/cache@v4
+ with:
+ path: .mint
+ key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
+ restore-keys: |
+ ${{ runner.os }}-mint-
+
+ - run: npm ci
+ - run: brew install mint
+ - run: mint bootstrap
+
+ - run: swift run BuildTool lint
+
+ generate-matrices:
+ runs-on: macos-latest
+ outputs:
+ matrix: ${{ steps.generation-step.outputs.matrix }}
+ steps:
+ - uses: actions/checkout@v4
+ - id: generation-step
+ run: swift run BuildTool generate-matrices >> $GITHUB_OUTPUT
+
+ check-spm:
+ name: SPM (Xcode ${{ matrix.tooling.xcodeVersion }}, Swift ${{ matrix.tooling.swiftVersion }})
+ runs-on: macos-latest
+ needs: generate-matrices
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.generate-matrices.outputs.matrix).withoutPlatform }}
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: maxim-lobanov/setup-xcode@v1
+ with:
+ xcode-version: ${{ matrix.tooling.xcodeVersion }}
+
+ # https://forums.swift.org/t/warnings-as-errors-for-libraries-frameworks/58393/2
+ - run: swift build -Xswiftc -warnings-as-errors -Xswiftc -swift-version -Xswiftc ${{ matrix.tooling.swiftVersion }}
+ - run: swift test -Xswiftc -warnings-as-errors -Xswiftc -swift-version -Xswiftc ${{ matrix.tooling.swiftVersion }}
+
+ check-xcode:
+ name: Xcode, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }}, Swift ${{ matrix.tooling.swiftVersion }})
+ runs-on: macos-latest
+ needs: generate-matrices
+
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.generate-matrices.outputs.matrix).withPlatform }}
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: maxim-lobanov/setup-xcode@v1
+ with:
+ xcode-version: ${{ matrix.tooling.xcodeVersion }}
+
+ - name: Build and run tests
+ run: swift run BuildTool build-and-test-library --platform ${{ matrix.platform }} --swift-version ${{ matrix.tooling.swiftVersion }}
+
+ check-example-app:
+ name: Example app, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }}, Swift ${{ matrix.tooling.swiftVersion }})
+ runs-on: macos-latest
+ needs: generate-matrices
+
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.generate-matrices.outputs.matrix).withPlatform }}
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: maxim-lobanov/setup-xcode@v1
+ with:
+ xcode-version: ${{ matrix.tooling.xcodeVersion }}
+
+ - name: Build example app
+ run: swift run BuildTool build-example-app --platform ${{ matrix.platform }} --swift-version ${{ matrix.tooling.swiftVersion }}
+
+ # We use this job as a marker that all of the required checks have completed.
+ # This allows us to configure a single required status check in our branch
+ # protection rules instead of having to type loads of different check names
+ # into the branch protection web UI (and keep this list up to date as we
+ # tweak the matrices).
+ all-checks-completed:
+ runs-on: ubuntu-latest
+ needs:
+ - lint
+ - check-spm
+ - check-xcode
+ - check-example-app
+
+ steps:
+ - name: No-op
+ run: "true"
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..67d3f4a7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,13 @@
+# Start of .gitignore created by Swift Package Manager
+.DS_Store
+/.build
+/Packages
+xcuserdata/
+DerivedData/
+.swiftpm/configuration/registries.json
+.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
+.netrc
+# End of .gitignore created by Swift Package Manager
+
+/node_modules
+/.mint
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000..1443d6cc
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,2 @@
+# Don’t try and format the asset catalogue JSON files, which are managed by Xcode
+*.xcassets/
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 00000000..0967ef42
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1 @@
+{}
diff --git a/.swift-version b/.swift-version
new file mode 100644
index 00000000..f9ce5a96
--- /dev/null
+++ b/.swift-version
@@ -0,0 +1 @@
+5.10
diff --git a/.swiftlint.yml b/.swiftlint.yml
new file mode 100644
index 00000000..967c45bf
--- /dev/null
+++ b/.swiftlint.yml
@@ -0,0 +1,102 @@
+excluded:
+ - .build
+
+strict: true
+
+disabled_rules:
+ # All of the default rules of type "metrics". We have no reason to believe that the arbitrary defaults picked by SwiftLint are helpful.
+ - cyclomatic_complexity
+ - file_length
+ - function_body_length
+ - function_parameter_count
+ - large_tuple
+ - line_length
+ - nesting
+ - type_body_length
+
+ # Rules of type "lint" that we’ve decided we don’t want:
+ - todo # We frequently use TODOs accompanied by a GitHub issue reference
+
+opt_in_rules:
+ # All of the opt-in rules of type "performance":
+ - contains_over_filter_count
+ - contains_over_filter_is_empty
+ - contains_over_first_not_nil
+ - contains_over_range_nil_comparison
+ - empty_collection_literal
+ - empty_count
+ - empty_string
+ - first_where
+ - flatmap_over_map_reduce
+ - last_where
+ - reduce_into
+ - sorted_first_last
+
+ # Opt-in rules of type "style" that we’ve decided we want:
+ - attributes
+ - closure_end_indentation
+ - closure_spacing
+ - collection_alignment
+ - comma_inheritance
+ - conditional_returns_on_newline
+ - file_header
+ - implicit_return
+ - literal_expression_end_indentation
+ - modifier_order
+ - multiline_arguments
+ - multiline_arguments_brackets
+ - multiline_function_chains
+ - multiline_literal_brackets
+ - multiline_parameters
+ - multiline_parameters_brackets
+ - operator_usage_whitespace
+ - prefer_self_type_over_type_of_self
+ - self_binding
+ - single_test_class
+ - sorted_imports
+ - switch_case_on_newline
+ - trailing_closure
+ - trailing_newline
+ - unneeded_parentheses_in_closure_argument
+ - vertical_parameter_alignment_on_call
+ - vertical_whitespace_closing_braces
+ - vertical_whitespace_opening_braces
+
+ # Opt-in rules of type "idiomatic" that we’ve decided we want:
+ - anonymous_argument_in_multiline_closure
+ - convenience_type
+ - fallthrough
+ - fatal_error_message
+ - pattern_matching_keywords
+ - redundant_type_annotation
+ - shorthand_optional_binding
+ - static_operator
+ - toggle_bool
+ - xct_specific_matcher
+
+ # Opt-in rules of type "lint" that we’ve decided we want:
+ - array_init
+ - empty_xctest_method
+ - missing_docs
+ - override_in_extension
+ - yoda_condition
+ - private_swiftui_state
+
+file_header:
+ # Comments, except for the required and standard ones at the top of a Package.swift file. The aim of this rule is to make sure that we delete the Xcode-generated boilerplate comment.
+ forbidden_pattern: //(?! (swift-tools-version:|The swift-tools-version declares the minimum version of Swift required to build this package\.))
+
+identifier_name:
+ &no_length_checks # We disable the length checks, for the same reason we disable the rules of type "metrics".
+ min_length:
+ warning: 1
+ max_length:
+ warning: 10000
+
+type_name: *no_length_checks
+
+generic_type_name: *no_length_checks
+
+# For compatibility with SwiftFormat
+trailing_comma:
+ mandatory_comma: true
diff --git a/.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 00000000..54782e32
--- /dev/null
+++ b/.swiftpm/xcode/package.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded
+
+
+
diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/AblyChat.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/AblyChat.xcscheme
new file mode 100644
index 00000000..b1361f74
--- /dev/null
+++ b/.swiftpm/xcode/xcshareddata/xcschemes/AblyChat.xcscheme
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AblyChat.xcworkspace/contents.xcworkspacedata b/AblyChat.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 00000000..56985fe1
--- /dev/null
+++ b/AblyChat.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
diff --git a/AblyChat.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/AblyChat.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 00000000..18d98100
--- /dev/null
+++ b/AblyChat.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved
new file mode 100644
index 00000000..18c2c7de
--- /dev/null
+++ b/AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -0,0 +1,42 @@
+{
+ "originHash" : "f6b591fa76437494c2609ca1208b8583cbc3debe5e659be06bdcb7bc4bb5e457",
+ "pins" : [
+ {
+ "identity" : "ably-cocoa",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/ably/ably-cocoa",
+ "state" : {
+ "revision" : "7f639c609e50053abd4590f34333f9472645558a",
+ "version" : "1.2.33"
+ }
+ },
+ {
+ "identity" : "delta-codec-cocoa",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/ably/delta-codec-cocoa",
+ "state" : {
+ "revision" : "3ee62ea40a63996b55818d44b3f0e56d8753be88",
+ "version" : "1.3.3"
+ }
+ },
+ {
+ "identity" : "msgpack-objective-c",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/rvi/msgpack-objective-C",
+ "state" : {
+ "revision" : "3e36b48e04ecd756cb927bd5f5b9bf6d45e475f9",
+ "version" : "0.4.0"
+ }
+ },
+ {
+ "identity" : "swift-argument-parser",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-argument-parser",
+ "state" : {
+ "revision" : "41982a3656a71c768319979febd796c6fd111d5c",
+ "version" : "1.5.0"
+ }
+ }
+ ],
+ "version" : 3
+}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..da93f6ee
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,37 @@
+# Contributing
+
+## Requirements
+
+- The Xcode version [mentioned in the README](./README.md#requirements)
+- [Mint](https://github.com/yonaskolb/Mint) package manager
+- Node.js (any recent version should be fine)
+
+## Setup
+
+1. `mint bootstrap` — this will take quite a long time (~5 minutes on my machine) the first time you run it
+2. `npm install`
+
+## Running the tests
+
+Either:
+
+- `swift test`, or
+- open `AblyChat.xcworkspace` in Xcode and test the `AblyChat` scheme
+
+## Linting
+
+To check formatting and code quality, run `swift run BuildTool lint`. Run with `--fix` to first automatically fix things where possible.
+
+## Development guidelines
+
+- The aim of the [example app](README.md#example-app) is that it demonstrate all of the core functionality of the SDK. So if you add a new feature, try to add something to the example app to demonstrate this feature.
+
+## Building for Swift 6
+
+At the time of writing (August 2024), the latest version of Swift to ship with a release version of Xcode is Swift 5.10. However, in the next few months Apple will launch Swift 6, which refines the strict concurrency checking introduced in Swift 5.10. So, once that releases we might decide that we want to switch to using Swift 6 for our SDK. But, more importantly, we want to be sure that the SDK can be integrated into a user’s application that uses Swift 6. So, in CI, in addition to Swift 5 language mode, we also try building the SDK and example app in Swift 6 language mode using the latest Xcode 16 beta. (If this turns out to cause a lot of problems due to the quality of the beta software, we can reconsider this.)
+
+### Multiple `Package.swift` files
+
+We have a separate manifest file, `Package@swift-6.swift`, which a Swift compiler supporting Swift 6 will use instead of `Package.swift` (see [documentation of this SPM feature](https://github.com/swiftlang/swift-package-manager/blob/74f06f8a7fd6b4c729e474dee34db66319d90759/Documentation/Usage.md#version-specific-manifest-selection)). This file only exists because if you try to use `.enableUpcomingFeature` for a feature that is enabled by default in Swift 6, you’ll get an error `error: upcoming feature 'BareSlashRegexLiterals' is already enabled as of Swift version 6`. (I don’t know if there’s a better way of handling this.)
+
+So, we need to make sure we keep `Package.swift` and `Package@swift-6.swift` in sync manually.
diff --git a/COPYRIGHT b/COPYRIGHT
new file mode 100644
index 00000000..625d86cf
--- /dev/null
+++ b/COPYRIGHT
@@ -0,0 +1 @@
+Copyright 2024 Ably Real-time Ltd (ably.com)
diff --git a/Example/AblyChatExample.xcodeproj/project.pbxproj b/Example/AblyChatExample.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..685c63a9
--- /dev/null
+++ b/Example/AblyChatExample.xcodeproj/project.pbxproj
@@ -0,0 +1,394 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 56;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 21971DFF2C60D89C0074B8AE /* AblyChat in Frameworks */ = {isa = PBXBuildFile; productRef = 21971DFE2C60D89C0074B8AE /* AblyChat */; };
+ 21F09AA02C60CAF00025AF73 /* AblyChatExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21F09A9F2C60CAF00025AF73 /* AblyChatExampleApp.swift */; };
+ 21F09AA22C60CAF00025AF73 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21F09AA12C60CAF00025AF73 /* ContentView.swift */; };
+ 21F09AA42C60CAF20025AF73 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 21F09AA32C60CAF20025AF73 /* Assets.xcassets */; };
+ 21F09AA82C60CAF20025AF73 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 21F09AA72C60CAF20025AF73 /* Preview Assets.xcassets */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 21F09A9C2C60CAF00025AF73 /* AblyChatExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AblyChatExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 21F09A9F2C60CAF00025AF73 /* AblyChatExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AblyChatExampleApp.swift; sourceTree = ""; };
+ 21F09AA12C60CAF00025AF73 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
+ 21F09AA32C60CAF20025AF73 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
+ 21F09AA52C60CAF20025AF73 /* AblyChatExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AblyChatExample.entitlements; sourceTree = ""; };
+ 21F09AA72C60CAF20025AF73 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 21F09A992C60CAF00025AF73 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 21971DFF2C60D89C0074B8AE /* AblyChat in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 21971DFD2C60D89C0074B8AE /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+ 21F09A932C60CAF00025AF73 = {
+ isa = PBXGroup;
+ children = (
+ 21F09A9E2C60CAF00025AF73 /* AblyChatExample */,
+ 21F09A9D2C60CAF00025AF73 /* Products */,
+ 21971DFD2C60D89C0074B8AE /* Frameworks */,
+ );
+ sourceTree = "";
+ };
+ 21F09A9D2C60CAF00025AF73 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 21F09A9C2C60CAF00025AF73 /* AblyChatExample.app */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 21F09A9E2C60CAF00025AF73 /* AblyChatExample */ = {
+ isa = PBXGroup;
+ children = (
+ 21F09A9F2C60CAF00025AF73 /* AblyChatExampleApp.swift */,
+ 21F09AA12C60CAF00025AF73 /* ContentView.swift */,
+ 21F09AA32C60CAF20025AF73 /* Assets.xcassets */,
+ 21F09AA52C60CAF20025AF73 /* AblyChatExample.entitlements */,
+ 21F09AA62C60CAF20025AF73 /* Preview Content */,
+ );
+ path = AblyChatExample;
+ sourceTree = "";
+ };
+ 21F09AA62C60CAF20025AF73 /* Preview Content */ = {
+ isa = PBXGroup;
+ children = (
+ 21F09AA72C60CAF20025AF73 /* Preview Assets.xcassets */,
+ );
+ path = "Preview Content";
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 21F09A9B2C60CAF00025AF73 /* AblyChatExample */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 21F09AAB2C60CAF20025AF73 /* Build configuration list for PBXNativeTarget "AblyChatExample" */;
+ buildPhases = (
+ 21F09A982C60CAF00025AF73 /* Sources */,
+ 21F09A992C60CAF00025AF73 /* Frameworks */,
+ 21F09A9A2C60CAF00025AF73 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = AblyChatExample;
+ packageProductDependencies = (
+ 21971DFE2C60D89C0074B8AE /* AblyChat */,
+ );
+ productName = AblyChatExample;
+ productReference = 21F09A9C2C60CAF00025AF73 /* AblyChatExample.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 21F09A942C60CAF00025AF73 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ BuildIndependentTargetsInParallel = 1;
+ LastSwiftUpdateCheck = 1540;
+ LastUpgradeCheck = 1540;
+ TargetAttributes = {
+ 21F09A9B2C60CAF00025AF73 = {
+ CreatedOnToolsVersion = 15.4;
+ };
+ };
+ };
+ buildConfigurationList = 21F09A972C60CAF00025AF73 /* Build configuration list for PBXProject "AblyChatExample" */;
+ compatibilityVersion = "Xcode 14.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 21F09A932C60CAF00025AF73;
+ productRefGroup = 21F09A9D2C60CAF00025AF73 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 21F09A9B2C60CAF00025AF73 /* AblyChatExample */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 21F09A9A2C60CAF00025AF73 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 21F09AA82C60CAF20025AF73 /* Preview Assets.xcassets in Resources */,
+ 21F09AA42C60CAF20025AF73 /* Assets.xcassets in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 21F09A982C60CAF00025AF73 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 21F09AA22C60CAF00025AF73 /* ContentView.swift in Sources */,
+ 21F09AA02C60CAF00025AF73 /* AblyChatExampleApp.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 21F09AA92C60CAF20025AF73 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
+ 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;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ ENABLE_USER_SCRIPT_SANDBOXING = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu17;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_TREAT_WARNINGS_AS_ERRORS = 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;
+ LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_STRICT_CONCURRENCY = complete;
+ SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
+ };
+ name = Debug;
+ };
+ 21F09AAA2C60CAF20025AF73 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
+ 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;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_USER_SCRIPT_SANDBOXING = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu17;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_TREAT_WARNINGS_AS_ERRORS = 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;
+ LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ MTL_FAST_MATH = YES;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_STRICT_CONCURRENCY = complete;
+ SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
+ };
+ name = Release;
+ };
+ 21F09AAC2C60CAF20025AF73 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ CODE_SIGN_ENTITLEMENTS = AblyChatExample/AblyChatExample.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_ASSET_PATHS = "\"AblyChatExample/Preview Content\"";
+ ENABLE_PREVIEWS = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_KEY_CFBundleDisplayName = "Ably Chat";
+ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;
+ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
+ "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 14.0;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = com.ably.AblyChatExample;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = auto;
+ SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx";
+ SUPPORTS_MACCATALYST = NO;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2,3";
+ TVOS_DEPLOYMENT_TARGET = 17.0;
+ };
+ name = Debug;
+ };
+ 21F09AAD2C60CAF20025AF73 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
+ CODE_SIGN_ENTITLEMENTS = AblyChatExample/AblyChatExample.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_ASSET_PATHS = "\"AblyChatExample/Preview Content\"";
+ ENABLE_PREVIEWS = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_KEY_CFBundleDisplayName = "Ably Chat";
+ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
+ "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
+ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;
+ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
+ "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 14.0;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = com.ably.AblyChatExample;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = auto;
+ SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx";
+ SUPPORTS_MACCATALYST = NO;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2,3";
+ TVOS_DEPLOYMENT_TARGET = 17.0;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 21F09A972C60CAF00025AF73 /* Build configuration list for PBXProject "AblyChatExample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 21F09AA92C60CAF20025AF73 /* Debug */,
+ 21F09AAA2C60CAF20025AF73 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 21F09AAB2C60CAF20025AF73 /* Build configuration list for PBXNativeTarget "AblyChatExample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 21F09AAC2C60CAF20025AF73 /* Debug */,
+ 21F09AAD2C60CAF20025AF73 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+
+/* Begin XCSwiftPackageProductDependency section */
+ 21971DFE2C60D89C0074B8AE /* AblyChat */ = {
+ isa = XCSwiftPackageProductDependency;
+ productName = AblyChat;
+ };
+/* End XCSwiftPackageProductDependency section */
+ };
+ rootObject = 21F09A942C60CAF00025AF73 /* Project object */;
+}
diff --git a/Example/AblyChatExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/AblyChatExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 00000000..919434a6
--- /dev/null
+++ b/Example/AblyChatExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/Example/AblyChatExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/AblyChatExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 00000000..18d98100
--- /dev/null
+++ b/Example/AblyChatExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Example/AblyChatExample/AblyChatExample.entitlements b/Example/AblyChatExample/AblyChatExample.entitlements
new file mode 100644
index 00000000..f2ef3ae0
--- /dev/null
+++ b/Example/AblyChatExample/AblyChatExample.entitlements
@@ -0,0 +1,10 @@
+
+
+
+
+ com.apple.security.app-sandbox
+
+ com.apple.security.files.user-selected.read-only
+
+
+
diff --git a/Example/AblyChatExample/AblyChatExampleApp.swift b/Example/AblyChatExample/AblyChatExampleApp.swift
new file mode 100644
index 00000000..8f7fbab0
--- /dev/null
+++ b/Example/AblyChatExample/AblyChatExampleApp.swift
@@ -0,0 +1,11 @@
+import AblyChat
+import SwiftUI
+
+@main
+struct AblyChatExampleApp: App {
+ var body: some Scene {
+ WindowGroup {
+ ContentView()
+ }
+ }
+}
diff --git a/Example/AblyChatExample/Assets.xcassets/AccentColor.colorset/Contents.json b/Example/AblyChatExample/Assets.xcassets/AccentColor.colorset/Contents.json
new file mode 100644
index 00000000..eb878970
--- /dev/null
+++ b/Example/AblyChatExample/Assets.xcassets/AccentColor.colorset/Contents.json
@@ -0,0 +1,11 @@
+{
+ "colors" : [
+ {
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Example/AblyChatExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/AblyChatExample/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 00000000..532cd729
--- /dev/null
+++ b/Example/AblyChatExample/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,63 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "platform" : "ios",
+ "size" : "1024x1024"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "16x16"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "16x16"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "32x32"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "32x32"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "128x128"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "128x128"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "256x256"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "256x256"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "512x512"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "512x512"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Example/AblyChatExample/Assets.xcassets/Contents.json b/Example/AblyChatExample/Assets.xcassets/Contents.json
new file mode 100644
index 00000000..73c00596
--- /dev/null
+++ b/Example/AblyChatExample/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Example/AblyChatExample/ContentView.swift b/Example/AblyChatExample/ContentView.swift
new file mode 100644
index 00000000..6856f825
--- /dev/null
+++ b/Example/AblyChatExample/ContentView.swift
@@ -0,0 +1,21 @@
+import AblyChat
+import SwiftUI
+
+struct ContentView: View {
+ /// Just used to check that we can successfully import and use the AblyChat library. TODO remove this once we start building the library
+ @State private var ablyChatClient = AblyChatClient()
+
+ var body: some View {
+ VStack {
+ Image(systemName: "globe")
+ .imageScale(.large)
+ .foregroundStyle(.tint)
+ Text("Hello, world!")
+ }
+ .padding()
+ }
+}
+
+#Preview {
+ ContentView()
+}
diff --git a/Example/AblyChatExample/Preview Content/Preview Assets.xcassets/Contents.json b/Example/AblyChatExample/Preview Content/Preview Assets.xcassets/Contents.json
new file mode 100644
index 00000000..73c00596
--- /dev/null
+++ b/Example/AblyChatExample/Preview Content/Preview Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..d9a10c0d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,176 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644
index 00000000..e5fda951
--- /dev/null
+++ b/MAINTAINERS.md
@@ -0,0 +1 @@
+This repository is owned by the Ably Ecosystems team.
diff --git a/Mintfile b/Mintfile
new file mode 100644
index 00000000..98ff1ee0
--- /dev/null
+++ b/Mintfile
@@ -0,0 +1,2 @@
+realm/SwiftLint@0.55.1
+nicklockwood/SwiftFormat@0.54.3
diff --git a/Package.resolved b/Package.resolved
new file mode 100644
index 00000000..18c2c7de
--- /dev/null
+++ b/Package.resolved
@@ -0,0 +1,42 @@
+{
+ "originHash" : "f6b591fa76437494c2609ca1208b8583cbc3debe5e659be06bdcb7bc4bb5e457",
+ "pins" : [
+ {
+ "identity" : "ably-cocoa",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/ably/ably-cocoa",
+ "state" : {
+ "revision" : "7f639c609e50053abd4590f34333f9472645558a",
+ "version" : "1.2.33"
+ }
+ },
+ {
+ "identity" : "delta-codec-cocoa",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/ably/delta-codec-cocoa",
+ "state" : {
+ "revision" : "3ee62ea40a63996b55818d44b3f0e56d8753be88",
+ "version" : "1.3.3"
+ }
+ },
+ {
+ "identity" : "msgpack-objective-c",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/rvi/msgpack-objective-C",
+ "state" : {
+ "revision" : "3e36b48e04ecd756cb927bd5f5b9bf6d45e475f9",
+ "version" : "0.4.0"
+ }
+ },
+ {
+ "identity" : "swift-argument-parser",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-argument-parser",
+ "state" : {
+ "revision" : "41982a3656a71c768319979febd796c6fd111d5c",
+ "version" : "1.5.0"
+ }
+ }
+ ],
+ "version" : 3
+}
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 00000000..e00adcc9
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,75 @@
+// swift-tools-version: 5.10
+
+import PackageDescription
+
+let package = Package(
+ name: "AblyChat",
+ platforms: [
+ .macOS(.v11),
+ .iOS(.v14),
+ .tvOS(.v14),
+ ],
+ products: [
+ .library(
+ name: "AblyChat",
+ targets: [
+ "AblyChat",
+ ]
+ ),
+ ],
+ dependencies: [
+ .package(
+ url: "https://github.com/ably/ably-cocoa",
+ from: "1.2.0"
+ ),
+ .package(
+ url: "https://github.com/apple/swift-argument-parser",
+ from: "1.5.0"
+ ),
+ ],
+ targets: [
+ .target(
+ name: "AblyChat",
+ dependencies: [
+ .product(
+ name: "Ably",
+ package: "ably-cocoa"
+ ),
+ ],
+ swiftSettings: [
+ // We build with strict concurrency checking enabled, because:
+ //
+ // 1. in theory it’s a useful language feature that reduces
+ // bugs
+ // 2. it will be unavoidable if we migrate to Swift 6, so let’s
+ // future-proof ourselves
+ //
+ // This is the first time that I’ll have used strict
+ // concurrency checking, so I don’t know what kind of impact it
+ // might have; I’ve seen anecdotes that it can make developers’
+ // lives tricky.
+ .enableExperimentalFeature("StrictConcurrency"),
+ ]
+ ),
+ .testTarget(
+ name: "AblyChatTests",
+ dependencies: [
+ "AblyChat",
+ ]
+ ),
+ .executableTarget(
+ name: "BuildTool",
+ dependencies: [
+ .product(
+ name: "ArgumentParser",
+ package: "swift-argument-parser"
+ ),
+ ],
+ swiftSettings: [
+ // See justification above.
+ .enableExperimentalFeature("StrictConcurrency"),
+ .enableUpcomingFeature("BareSlashRegexLiterals"),
+ ]
+ ),
+ ]
+)
diff --git a/Package@swift-6.swift b/Package@swift-6.swift
new file mode 100644
index 00000000..adbd46f1
--- /dev/null
+++ b/Package@swift-6.swift
@@ -0,0 +1,56 @@
+// swift-tools-version: 6.0
+
+import PackageDescription
+
+let package = Package(
+ name: "AblyChat",
+ platforms: [
+ .macOS(.v11),
+ .iOS(.v14),
+ .tvOS(.v14),
+ ],
+ products: [
+ .library(
+ name: "AblyChat",
+ targets: [
+ "AblyChat",
+ ]
+ ),
+ ],
+ dependencies: [
+ .package(
+ url: "https://github.com/ably/ably-cocoa",
+ from: "1.2.0"
+ ),
+ .package(
+ url: "https://github.com/apple/swift-argument-parser",
+ from: "1.5.0"
+ ),
+ ],
+ targets: [
+ .target(
+ name: "AblyChat",
+ dependencies: [
+ .product(
+ name: "Ably",
+ package: "ably-cocoa"
+ ),
+ ]
+ ),
+ .testTarget(
+ name: "AblyChatTests",
+ dependencies: [
+ "AblyChat",
+ ]
+ ),
+ .executableTarget(
+ name: "BuildTool",
+ dependencies: [
+ .product(
+ name: "ArgumentParser",
+ package: "swift-argument-parser"
+ ),
+ ]
+ ),
+ ]
+)
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..091a8b06
--- /dev/null
+++ b/README.md
@@ -0,0 +1,36 @@
+# Ably Chat SDK for Swift
+
+This is the repository for the Swift version of the Ably Chat SDK. We aim to build the same functionality that’s available in the [JavaScript SDK](https://github.com/ably/ably-chat-js).
+
+> [!IMPORTANT]
+> This SDK is currently in the early stages of development and is not ready to be used.
+
+## Supported Platforms
+
+- macOS 11 and above
+- iOS 14 and above
+- tvOS 14 and above
+
+## Requirements
+
+Xcode 15.3 (i.e. a compiler that supports Swift 5.10) or later.
+
+## Installation
+
+The SDK is distributed as a Swift package and can hence be installed using Xcode or by adding it as a dependency in your package’s `Package.swift`. We’ll add detailed instructions when we release the first version of the SDK.
+
+## Example app
+
+This repository contains an example app, written using SwiftUI, which demonstrates how to use the SDK. The code for this app is in the [`Example` directory](Example).
+
+In order to allow the app to use modern SwiftUI features, it supports the following OS versions:
+
+- macOS 14 and above
+- iOS 17 and above
+- tvOS 17 and above
+
+To run the app, open the `AblyChat.xcworkspace` workspace in Xcode and run the `AblyChatExample` target. If you wish to run it on an iOS or tvOS device, you’ll need to set up code signing.
+
+## Contributing
+
+For information on how to contribute to this repository, please see the [contributing guidelines](CONTRIBUTING.md).
diff --git a/Sources/AblyChat/AblyChat.swift b/Sources/AblyChat/AblyChat.swift
new file mode 100644
index 00000000..dc0816df
--- /dev/null
+++ b/Sources/AblyChat/AblyChat.swift
@@ -0,0 +1,7 @@
+import Ably
+
+/// Temporary class just used to check that the example app and tests can use the library. TODO remove this once we start building the library
+public class AblyChatClient {
+ /// Initializes an instance of `AblyChatClient`.
+ public init() {}
+}
diff --git a/Sources/BuildTool/BuildTool.swift b/Sources/BuildTool/BuildTool.swift
new file mode 100644
index 00000000..159792a9
--- /dev/null
+++ b/Sources/BuildTool/BuildTool.swift
@@ -0,0 +1,191 @@
+import ArgumentParser
+import Foundation
+
+@main
+@available(macOS 14, *)
+struct BuildTool: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(
+ subcommands: [
+ BuildAndTestLibrary.self,
+ BuildExampleApp.self,
+ GenerateMatrices.self,
+ Lint.self,
+ ]
+ )
+}
+
+@available(macOS 14, *)
+struct BuildAndTestLibrary: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(abstract: "Build and test the AblyChat library")
+
+ @Option var platform: Platform
+ @Option var swiftVersion: Int
+
+ mutating func run() async throws {
+ let destinationSpecifier = try await platform.resolve()
+ let scheme = "AblyChat"
+
+ try await XcodeRunner.runXcodebuild(action: nil, scheme: scheme, destination: destinationSpecifier, swiftVersion: swiftVersion)
+ try await XcodeRunner.runXcodebuild(action: "test", scheme: scheme, destination: destinationSpecifier, swiftVersion: swiftVersion)
+ }
+}
+
+@available(macOS 14, *)
+struct BuildExampleApp: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(abstract: "Build the AblyChatExample example app")
+
+ @Option var platform: Platform
+ @Option var swiftVersion: Int
+
+ mutating func run() async throws {
+ let destinationSpecifier = try await platform.resolve()
+
+ try await XcodeRunner.runXcodebuild(action: nil, scheme: "AblyChatExample", destination: destinationSpecifier, swiftVersion: swiftVersion)
+ }
+}
+
+struct GenerateMatrices: ParsableCommand {
+ static let configuration = CommandConfiguration(
+ abstract: "Generate a build matrix that can be used for specifying which GitHub jobs to run",
+ discussion: """
+ Outputs a key=value string which, when appended to $GITHUB_OUTPUT, sets the job’s `matrix` output to a JSON object which can be used for generating builds. This allows us to make sure that our various matrix jobs use consistent parameters.
+
+ This object has the following structure:
+
+ {
+ withoutPlatform: { tooling: Tooling }[]
+ withPlatform: { tooling: Tooling, platform: PlatformArgument }[]
+ }
+
+ where Tooling is
+
+ {
+ xcodeVersion: string
+ swiftVersion: number
+ }
+
+ and PlatformArgument is a value that can be passed as the --platform argument of the build-and-test-library or build-example-app commands.
+ """
+ )
+
+ mutating func run() throws {
+ let tooling = [
+ [
+ "xcodeVersion": "15.3",
+ "swiftVersion": 5,
+ ],
+ [
+ "xcodeVersion": "16-beta",
+ "swiftVersion": 6,
+ ],
+ ]
+
+ let matrix: [String: Any] = [
+ "withoutPlatform": [
+ "tooling": tooling,
+ ],
+ "withPlatform": [
+ "tooling": tooling,
+ "platform": Platform.allCases.map(\.rawValue),
+ ],
+ ]
+
+ // I’m assuming the JSONSerialization output has no newlines
+ let keyValue = try "matrix=\(String(decoding: JSONSerialization.data(withJSONObject: matrix), as: UTF8.self))"
+ fputs("\(keyValue)\n", stderr)
+ print(keyValue)
+ }
+}
+
+@available(macOS 14, *)
+struct Lint: AsyncParsableCommand {
+ static let configuration = CommandConfiguration(abstract: "Checks code formatting and quality.")
+
+ enum Error: Swift.Error {
+ case malformedSwiftVersionFile
+ case malformedPackageManifestFile
+ case mismatchedVersions(swiftVersionFileVersion: String, packageManifestFileVersion: String)
+ case packageLockfilesHaveDifferentContents(paths: [String])
+ }
+
+ @Flag(name: .customLong("fix"), help: .init("Fixes linting errors where possible before linting"))
+ var shouldFix = false
+
+ mutating func run() async throws {
+ if shouldFix {
+ try await fix()
+ try await lint()
+ } else {
+ try await lint()
+ }
+ }
+
+ func lint() async throws {
+ try await ProcessRunner.run(executableName: "mint", arguments: ["run", "swiftformat", "--lint", "."])
+ try await ProcessRunner.run(executableName: "mint", arguments: ["run", "swiftlint"])
+ try await ProcessRunner.run(executableName: "npm", arguments: ["run", "prettier:check"])
+ try await checkSwiftVersionFile()
+ try await comparePackageLockfiles()
+ }
+
+ func fix() async throws {
+ try await ProcessRunner.run(executableName: "mint", arguments: ["run", "swiftformat", "."])
+ try await ProcessRunner.run(executableName: "mint", arguments: ["run", "swiftlint", "--fix"])
+ try await ProcessRunner.run(executableName: "npm", arguments: ["run", "prettier:fix"])
+ }
+
+ /// Checks that the Swift version specified by the `Package.swift`’s `"swift-tools-version"` matches that in the `.swift-version` file (which is used to tell SwiftFormat the minimum version of Swift supported by our code). Per [SwiftFormat#1496](https://github.com/nicklockwood/SwiftFormat/issues/1496) it’s currently our responsibility to make sure they’re kept in sync.///
+ func checkSwiftVersionFile() async throws {
+ async let swiftVersionFileContents = loadUTF8StringFromFile(at: ".swift-version")
+ async let packageManifestFileContents = loadUTF8StringFromFile(at: "Package.swift")
+
+ guard let swiftVersionFileMatch = try await /^(\d+\.\d+)\n$/.firstMatch(in: swiftVersionFileContents) else {
+ throw Error.malformedSwiftVersionFile
+ }
+
+ let swiftVersionFileVersion = String(swiftVersionFileMatch.1)
+
+ guard let packageManifestFileMatch = try await /^\/\/ swift-tools-version: (\d+\.\d+)\n/.firstMatch(in: packageManifestFileContents) else {
+ throw Error.malformedPackageManifestFile
+ }
+
+ let packageManifestFileVersion = String(packageManifestFileMatch.1)
+
+ if swiftVersionFileVersion != packageManifestFileVersion {
+ throw Error.mismatchedVersions(
+ swiftVersionFileVersion: swiftVersionFileVersion,
+ packageManifestFileVersion: packageManifestFileVersion
+ )
+ }
+ }
+
+ /// Checks that the SPM-managed Package.resolved matches the Xcode-managed one. (I still don’t fully understand _why_ there are two files).
+ func comparePackageLockfiles() async throws {
+ let lockfilePaths = ["Package.resolved", "AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved"]
+ let lockfileContents = try await withThrowingTaskGroup(of: String.self) { group in
+ for lockfilePath in lockfilePaths {
+ group.addTask {
+ try await loadUTF8StringFromFile(at: lockfilePath)
+ }
+ }
+
+ var result: [String] = []
+ for try await fileContents in group {
+ result.append(fileContents)
+ }
+
+ return try await group.reduce(into: []) { accum, fileContents in
+ accum.append(fileContents)
+ }
+ }
+
+ if Set(lockfileContents).count > 1 {
+ throw Error.packageLockfilesHaveDifferentContents(paths: lockfilePaths)
+ }
+ }
+
+ private func loadUTF8StringFromFile(at path: String) async throws -> String {
+ let (data, _) = try await URLSession.shared.data(from: .init(filePath: path))
+ return String(decoding: data, as: UTF8.self)
+ }
+}
diff --git a/Sources/BuildTool/DestinationFetcher.swift b/Sources/BuildTool/DestinationFetcher.swift
new file mode 100644
index 00000000..fb0cdf15
--- /dev/null
+++ b/Sources/BuildTool/DestinationFetcher.swift
@@ -0,0 +1,41 @@
+import Foundation
+
+@available(macOS 14, *)
+enum DestinationFetcher {
+ static func fetchDeviceUDID(destinationPredicate: DestinationPredicate) async throws -> String {
+ let simctlAvailableDevicesOutput = try await fetchSimctlAvailableDevicesOutput()
+
+ let runtimeIdentifier = "com.apple.CoreSimulator.SimRuntime.\(destinationPredicate.runtime)"
+ let deviceTypeIdentifier = "com.apple.CoreSimulator.SimDeviceType.\(destinationPredicate.deviceType)"
+
+ let matchingDevices = (simctlAvailableDevicesOutput.devices[runtimeIdentifier] ?? []).filter { $0.deviceTypeIdentifier == deviceTypeIdentifier }
+
+ guard !matchingDevices.isEmpty else {
+ throw Error.simulatorLookupFailed(message: "Couldn’t find a simulator with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); available devices are \(simctlAvailableDevicesOutput.devices)")
+ }
+
+ guard matchingDevices.count == 1 else {
+ throw Error.simulatorLookupFailed(message: "Found multiple simulators with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); matching devices are \(matchingDevices)")
+ }
+
+ return matchingDevices[0].udid
+ }
+
+ struct SimctlOutput: Codable {
+ var devices: [String: [Device]]
+
+ struct Device: Codable {
+ var udid: String
+ var deviceTypeIdentifier: String
+ }
+ }
+
+ private static func fetchSimctlAvailableDevicesOutput() async throws -> SimctlOutput {
+ let data = try await ProcessRunner.runAndReturnStdout(
+ executableName: "xcrun",
+ arguments: ["simctl", "list", "--json", "devices", "available"]
+ )
+
+ return try JSONDecoder().decode(SimctlOutput.self, from: data)
+ }
+}
diff --git a/Sources/BuildTool/DestinationPredicate.swift b/Sources/BuildTool/DestinationPredicate.swift
new file mode 100644
index 00000000..82b24586
--- /dev/null
+++ b/Sources/BuildTool/DestinationPredicate.swift
@@ -0,0 +1,7 @@
+import Foundation
+
+/// Specifies the attributes to use when searching for a simulator device.
+struct DestinationPredicate {
+ var runtime: String
+ var deviceType: String
+}
diff --git a/Sources/BuildTool/DestinationSpecifier.swift b/Sources/BuildTool/DestinationSpecifier.swift
new file mode 100644
index 00000000..25f1f8c6
--- /dev/null
+++ b/Sources/BuildTool/DestinationSpecifier.swift
@@ -0,0 +1,15 @@
+import Foundation
+
+enum DestinationSpecifier {
+ case platform(String)
+ case deviceID(String)
+
+ var xcodebuildArgument: String {
+ switch self {
+ case let .platform(platform):
+ "platform=\(platform)"
+ case let .deviceID(deviceID):
+ "id=\(deviceID)"
+ }
+ }
+}
diff --git a/Sources/BuildTool/DestinationStrategy.swift b/Sources/BuildTool/DestinationStrategy.swift
new file mode 100644
index 00000000..5acdd4d2
--- /dev/null
+++ b/Sources/BuildTool/DestinationStrategy.swift
@@ -0,0 +1,6 @@
+import Foundation
+
+enum DestinationStrategy {
+ case fixed(platform: String)
+ case lookup(destinationPredicate: DestinationPredicate)
+}
diff --git a/Sources/BuildTool/Error.swift b/Sources/BuildTool/Error.swift
new file mode 100644
index 00000000..1978ed97
--- /dev/null
+++ b/Sources/BuildTool/Error.swift
@@ -0,0 +1,6 @@
+import Foundation
+
+enum Error: Swift.Error {
+ case terminatedWithExitCode(Int32)
+ case simulatorLookupFailed(message: String)
+}
diff --git a/Sources/BuildTool/Platform.swift b/Sources/BuildTool/Platform.swift
new file mode 100644
index 00000000..8145d827
--- /dev/null
+++ b/Sources/BuildTool/Platform.swift
@@ -0,0 +1,38 @@
+import ArgumentParser
+import Foundation
+
+enum Platform: String, CaseIterable {
+ case macOS
+ case iOS
+ case tvOS
+
+ var destinationStrategy: DestinationStrategy {
+ switch self {
+ case .macOS:
+ .fixed(platform: "macOS")
+ case .iOS:
+ .lookup(destinationPredicate: .init(runtime: "iOS-17-5", deviceType: "iPhone-15"))
+ case .tvOS:
+ .lookup(destinationPredicate: .init(runtime: "tvOS-17-5", deviceType: "Apple-TV-4K-3rd-generation-4K"))
+ }
+ }
+
+ /// Determines which `destination` argument should be passed to `xcodebuild` for this platform.
+ ///
+ /// It does this by finding a simulator device matching the device type and OS version that we wish to use for this platform.
+ @available(macOS 14, *)
+ func resolve() async throws -> DestinationSpecifier {
+ switch destinationStrategy {
+ case let .fixed(platform):
+ .platform(platform)
+ case let .lookup(destinationPredicate):
+ try await .deviceID(DestinationFetcher.fetchDeviceUDID(destinationPredicate: destinationPredicate))
+ }
+ }
+}
+
+extension Platform: ExpressibleByArgument {
+ init?(argument: String) {
+ self.init(rawValue: argument)
+ }
+}
diff --git a/Sources/BuildTool/ProcessRunner.swift b/Sources/BuildTool/ProcessRunner.swift
new file mode 100644
index 00000000..cb47fbd8
--- /dev/null
+++ b/Sources/BuildTool/ProcessRunner.swift
@@ -0,0 +1,79 @@
+import Foundation
+
+@available(macOS 14, *)
+enum ProcessRunner {
+ private static let queue = DispatchQueue(label: "ProcessRunner")
+
+ // There’s probably a better way to implement these, which doesn’t involve having to use a separate dispatch queue. There’s a proposal for a Subprocess API coming up in Foundation which will marry Process with Swift concurrency.
+
+ static func run(executableName: String, arguments: [String]) async throws {
+ try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in
+ queue.async {
+ let process = Process()
+ process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
+ process.arguments = [executableName] + arguments
+
+ do {
+ try process.run()
+ } catch {
+ continuation.resume(throwing: error)
+ return
+ }
+
+ process.waitUntilExit()
+
+ if process.terminationStatus != 0 {
+ continuation.resume(throwing: Error.terminatedWithExitCode(process.terminationStatus))
+ return
+ }
+
+ continuation.resume()
+ }
+ }
+ }
+
+ static func runAndReturnStdout(executableName: String, arguments: [String]) async throws -> Data {
+ try await withCheckedThrowingContinuation { continuation in
+ queue.async {
+ let process = Process()
+ process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
+ process.arguments = [executableName] + arguments
+
+ let standardOutput = Pipe()
+ process.standardOutput = standardOutput
+
+ do {
+ try process.run()
+ } catch {
+ continuation.resume(throwing: error)
+ return
+ }
+
+ var stdoutData = Data()
+ while true {
+ do {
+ if let data = try standardOutput.fileHandleForReading.readToEnd() {
+ stdoutData.append(data)
+ } else {
+ break
+ }
+ } catch {
+ process.terminate()
+ process.waitUntilExit()
+ continuation.resume(throwing: error)
+ return
+ }
+ }
+
+ process.waitUntilExit()
+
+ if process.terminationStatus != 0 {
+ continuation.resume(throwing: Error.terminatedWithExitCode(process.terminationStatus))
+ return
+ }
+
+ continuation.resume(returning: stdoutData)
+ }
+ }
+ }
+}
diff --git a/Sources/BuildTool/XcodeRunner.swift b/Sources/BuildTool/XcodeRunner.swift
new file mode 100644
index 00000000..9171bd70
--- /dev/null
+++ b/Sources/BuildTool/XcodeRunner.swift
@@ -0,0 +1,22 @@
+import Foundation
+
+@available(macOS 14, *)
+enum XcodeRunner {
+ static func runXcodebuild(action: String?, scheme: String, destination: DestinationSpecifier, swiftVersion: Int) async throws {
+ var arguments: [String] = []
+
+ if let action {
+ arguments.append(action)
+ }
+
+ arguments.append(contentsOf: ["-scheme", scheme])
+ arguments.append(contentsOf: ["-destination", destination.xcodebuildArgument])
+
+ arguments.append(contentsOf: [
+ "SWIFT_TREAT_WARNINGS_AS_ERRORS=YES",
+ "SWIFT_VERSION=\(swiftVersion)",
+ ])
+
+ try await ProcessRunner.run(executableName: "xcodebuild", arguments: arguments)
+ }
+}
diff --git a/Tests/AblyChatTests/AblyChatTests.swift b/Tests/AblyChatTests/AblyChatTests.swift
new file mode 100644
index 00000000..054ea7fe
--- /dev/null
+++ b/Tests/AblyChatTests/AblyChatTests.swift
@@ -0,0 +1,8 @@
+@testable import AblyChat
+import XCTest
+
+final class AblyChatTests: XCTestCase {
+ func testExample() throws {
+ XCTAssertNoThrow(AblyChatClient())
+ }
+}
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 00000000..1240c3b6
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,30 @@
+{
+ "name": "ably-chat-swift-dev-tooling",
+ "version": "0.1.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "ably-chat-swift-dev-tooling",
+ "version": "0.1.0",
+ "devDependencies": {
+ "prettier": "^3.3.3"
+ }
+ },
+ "node_modules/prettier": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz",
+ "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
+ "dev": true,
+ "bin": {
+ "prettier": "bin/prettier.cjs"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/prettier/prettier?sponsor=1"
+ }
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 00000000..a8797216
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "ably-chat-swift-dev-tooling",
+ "version": "0.1.0",
+ "description": "Development tooling for the ably-chat-swift repo",
+ "devDependencies": {
+ "prettier": "^3.3.3"
+ },
+ "scripts": {
+ "prettier:check": "prettier --check .",
+ "prettier:fix": "prettier --write ."
+ }
+}