Skip to content

Commit 0051937

Browse files
committed
Messagevisor Swift SDK
0 parents  commit 0051937

39 files changed

Lines changed: 4627 additions & 0 deletions

‎.editorconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
10+
[Makefile]
11+
indent_style = tab

‎.github/workflows/checks.yml‎

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Checks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: checks-${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
swift:
17+
name: Swift 6.2.1
18+
runs-on: macos-15
19+
timeout-minutes: 30
20+
steps:
21+
- name: Check out repository
22+
uses: actions/checkout@v7
23+
24+
- name: Set up Xcode
25+
uses: maxim-lobanov/setup-xcode@v1
26+
with:
27+
xcode-version: "16.2"
28+
29+
- name: Set up Swift
30+
uses: swift-actions/setup-swift@v2.4.0
31+
with:
32+
swift-version: "6.2.1"
33+
34+
- name: Show toolchain versions
35+
run: |
36+
swift --version
37+
xcodebuild -version
38+
39+
- name: Build
40+
run: swift build
41+
42+
- name: Check Swift 6 concurrency
43+
run: make strict-concurrency
44+
45+
- name: Test
46+
run: swift test
47+
48+
- name: Release build
49+
run: swift build -c release
50+
51+
- name: Test with Thread Sanitizer
52+
env:
53+
MACOSX_DEPLOYMENT_TARGET: "13.0"
54+
run: swift test --sanitize=thread
55+
56+
apple-platforms:
57+
name: ${{ matrix.name }} compile check
58+
runs-on: macos-15
59+
timeout-minutes: 20
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
include:
64+
- name: iOS
65+
sdk: iphonesimulator
66+
triple: arm64-apple-ios13.0-simulator
67+
- name: tvOS
68+
sdk: appletvsimulator
69+
triple: arm64-apple-tvos13.0-simulator
70+
- name: watchOS
71+
sdk: watchsimulator
72+
triple: arm64-apple-watchos6.0-simulator
73+
- name: visionOS
74+
sdk: xrsimulator
75+
triple: arm64-apple-xros1.0-simulator
76+
steps:
77+
- name: Check out repository
78+
uses: actions/checkout@v7
79+
80+
- name: Set up Xcode
81+
uses: maxim-lobanov/setup-xcode@v1
82+
with:
83+
xcode-version: "16.2"
84+
85+
- name: Set up Swift
86+
uses: swift-actions/setup-swift@v2.4.0
87+
with:
88+
swift-version: "6.2.1"
89+
90+
- name: Show toolchain versions
91+
run: |
92+
swift --version
93+
xcodebuild -version
94+
95+
- name: Compile public libraries
96+
run: |
97+
for target in Messagevisor MessagevisorICU MessagevisorInterpolation MessagevisorMissingTranslations; do
98+
swift build \
99+
--target "$target" \
100+
--triple "${{ matrix.triple }}" \
101+
--sdk "$(xcrun --sdk '${{ matrix.sdk }}' --show-sdk-path)" \
102+
--scratch-path "/tmp/messagevisor-${{ matrix.sdk }}-$target"
103+
done
104+
105+
integration:
106+
name: Public consumers and project-1
107+
runs-on: macos-15
108+
timeout-minutes: 30
109+
steps:
110+
- name: Check out Swift SDK
111+
uses: actions/checkout@v7
112+
113+
- name: Set up Xcode
114+
uses: maxim-lobanov/setup-xcode@v1
115+
with:
116+
xcode-version: "16.2"
117+
118+
- name: Set up Swift
119+
uses: swift-actions/setup-swift@v2.4.0
120+
with:
121+
swift-version: "6.2.1"
122+
123+
- name: Set up Node.js
124+
uses: actions/setup-node@v7
125+
with:
126+
node-version-file: .nvmrc
127+
package-manager-cache: false
128+
129+
- name: Initialize Messagevisor project-1
130+
env:
131+
npm_config_yes: "true"
132+
run: |
133+
mkdir project-1
134+
cd project-1
135+
npx @messagevisor/cli init --project=1
136+
137+
- name: Install Messagevisor project-1 dependencies
138+
working-directory: project-1
139+
run: npm install
140+
141+
- name: Validate Messagevisor project-1
142+
working-directory: project-1
143+
run: |
144+
npm run lint
145+
npm run build
146+
npm run test
147+
148+
- name: Verify clean package consumers
149+
run: make verify-consumers
150+
151+
- name: Run project tests against Swift SDK
152+
run: >-
153+
swift run messagevisor-swift test --projectDirectoryPath=project-1
154+
--onlyFailures --target=swift --normalizeSpaces --withIcuModule
155+
--withInterpolationModule

‎.github/workflows/release.yml‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Release validation
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: release-${{ github.ref }}
13+
cancel-in-progress: false
14+
15+
jobs:
16+
validate:
17+
runs-on: macos-15
18+
timeout-minutes: 30
19+
steps:
20+
- name: Check out repository
21+
uses: actions/checkout@v7
22+
23+
- name: Set up Xcode
24+
uses: maxim-lobanov/setup-xcode@v1
25+
with:
26+
xcode-version: "16.2"
27+
28+
- name: Validate semantic version tag
29+
shell: bash
30+
run: |
31+
if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z][0-9A-Za-z.-]*)?$ ]]; then
32+
echo "Expected a semantic version tag with a v prefix" >&2
33+
exit 1
34+
fi
35+
36+
version="${GITHUB_REF_NAME#v}"
37+
38+
if ! grep -Fq "from: \"$version\"" README.md; then
39+
echo "README installation version does not match $GITHUB_REF_NAME" >&2
40+
exit 1
41+
fi
42+
43+
if ! grep -Fq "## $version" CHANGELOG.md; then
44+
echo "CHANGELOG does not contain a $version release" >&2
45+
exit 1
46+
fi
47+
48+
if ! grep -Fq "messagevisorSwiftVersion = \"$version\"" Sources/MessagevisorCLI/main.swift; then
49+
echo "Swift CLI version does not match $GITHUB_REF_NAME" >&2
50+
exit 1
51+
fi
52+
53+
echo "Validating Messagevisor Swift $version"
54+
55+
- name: Set up Swift
56+
uses: swift-actions/setup-swift@v2.4.0
57+
with:
58+
swift-version: "6.2.1"
59+
60+
- name: Show toolchain versions
61+
run: |
62+
swift --version
63+
xcodebuild -version
64+
65+
- name: Test
66+
run: swift test
67+
68+
- name: Check Swift 6 concurrency
69+
run: make strict-concurrency
70+
71+
- name: Build release products
72+
run: swift build -c release
73+
74+
- name: Verify clean package consumers
75+
run: make verify-consumers

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.build/
2+
.swiftpm/
3+
Package.resolved
4+
.DS_Store
5+
DerivedData/
6+
*.xcodeproj
7+
xcuserdata/

‎.nvmrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24.16.0

‎AGENTS.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Messagevisor Swift SDK
2+
3+
This repository is the native Swift port of Messagevisor for Apple platforms.
4+
5+
Before runtime work, read `/Users/fahad/Projects/messagevisor/PORT.md`. The behavioral source of truth is `/Users/fahad/Projects/messagevisor/messagevisor/packages/sdk`; the real cross-SDK fixture project is `/Users/fahad/Projects/messagevisor/messagevisor/projects/project-1`.
6+
7+
Key rules:
8+
9+
- Preserve portable JavaScript SDK semantics while using idiomatic Swift and Foundation APIs.
10+
- Never add locale-specific output rewrites merely to match JavaScript `Intl`. Record meaningful Apple output differences explicitly with `expectedByRuntime.swift`; the project runner must evaluate every formatting assertion. `--normalizeSpaces` may equate only ordinary, no-break, and narrow no-break spaces.
11+
- Keep `MessagevisorChild` free of root-owned datafile/module mutation APIs.
12+
- Preserve `could not parse datafile` for invalid datafile diagnostics.
13+
- Keep the bundled `Tests/MessagevisorTests/Resources/conformance/sdk-v1.json` synchronized with the monorepo fixture.
14+
- The SDK README is the source of truth for future extracted website documentation.
15+
16+
Verification:
17+
18+
```sh
19+
swift build
20+
swift test
21+
make test-project-1
22+
```

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Initial Messagevisor Swift SDK for Apple platforms.

‎CODE_OF_CONDUCT.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our pledge
4+
5+
We pledge to make participation in the Messagevisor community harassment-free for everyone. We will act in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
6+
7+
## Our standards
8+
9+
Positive behavior includes empathy, respect for different viewpoints, constructive feedback, accountability, and focusing on what is best for the community. Unacceptable behavior includes harassment, sexualized conduct, trolling, personal attacks, publishing private information, or other conduct inappropriate in a professional setting.
10+
11+
## Scope and enforcement
12+
13+
This Code applies in project spaces and whenever someone officially represents the project. Maintainers may remove or reject contributions and participation that violate these standards.
14+
15+
Report unacceptable behavior to [messagevisor-conduct@googlegroups.com](mailto:messagevisor-conduct@googlegroups.com). Reports will be reviewed promptly, fairly, and with respect for the reporter's privacy and security.
16+
17+
This Code is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.

‎CONTRIBUTING.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Contributing
2+
3+
Thanks for helping improve Messagevisor Swift. Please open an issue before a large API or portability change so its relationship with the JavaScript source of truth can be agreed first. By participating, you agree to follow the [Code of Conduct](CODE_OF_CONDUCT.md). Report vulnerabilities through [SECURITY.md](SECURITY.md), not a public issue.
4+
5+
Read the workspace's `messagevisor/PORT.md` before changing portable runtime behavior. Use Foundation localization APIs and keep formatting generic. Locale-specific labels, fixture-specific output rewrites, and silent skipping do not belong in the SDK.
6+
7+
Before opening a change, run:
8+
9+
```sh
10+
swift build
11+
swift test
12+
make test-project-1
13+
```
14+
15+
Use `expectedByRuntime.swift` for deliberate Apple-vs-JavaScript expectations. The project runner compares every evaluation and has no formatter-skipping mode. Its reference Make targets normalize only ordinary, no-break, and narrow no-break spaces so space-only differences do not make fixtures noisy.

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2026 Fahad Heylaal (https://fahad19.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

0 commit comments

Comments
 (0)