Skip to content

Commit 689d0a2

Browse files
feat: integrates macro targets into swift package (maplibre#73)
* feat: integrates macro targets into swift package * feat: integrates macro targets into swift package * feat: integrates macro targets into swift package * feat: integrates macro targets into swift package * feat: integrates macro targets into swift package * feat: integrates macro targets into swift package * feat: integrates macro targets into swift package * feat: internal macro * Update CHANGELOG.md Co-authored-by: Ian Wagner <[email protected]> --------- Co-authored-by: Ian Wagner <[email protected]>
1 parent cb05115 commit 689d0a2

File tree

9 files changed

+472
-48
lines changed

9 files changed

+472
-48
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,45 @@ name: Test
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
format-lint:
1111
runs-on: macos-15
1212

1313
steps:
14-
- name: Checkout maplibre-swiftui-dsl-playground
15-
uses: actions/checkout@v4
14+
- name: Checkout maplibre-swiftui-dsl-playground
15+
uses: actions/checkout@v4
1616

17-
- name: Check format
18-
run: swiftformat . --lint
17+
- name: Check format
18+
run: swiftformat . --lint
1919

2020
test:
2121
runs-on: macos-15
2222
strategy:
2323
matrix:
24-
scheme: [
25-
MapLibreSwiftUI-Package
26-
]
24+
scheme: [MapLibreSwiftUI-Package]
2725
destination: [
28-
# TODO: Add more destinations
29-
'platform=iOS Simulator,name=iPhone 16,OS=18.1'
30-
]
26+
# TODO: Add more destinations (snapshot testing is the problem)
27+
"platform=iOS Simulator,name=iPhone 16,OS=18.1",
28+
# 'platform=watchOS Simulator,name=Apple Watch Ultra 2 (49mm)',
29+
# "platform=iOS Simulator,name=iPad (10th generation),OS=16.4",
30+
# "platform=iOS Simulator,name=iPhone 15,OS=17.2",
31+
]
3132
name: ${{ matrix.destination }}
3233

3334
steps:
34-
- name: Install tools
35-
run: brew update && brew upgrade xcbeautify
35+
- name: Install tools
36+
run: brew update && brew upgrade xcbeautify
3637

37-
- uses: maxim-lobanov/setup-xcode@v1
38-
with:
39-
xcode-version: latest-stable
38+
- uses: maxim-lobanov/setup-xcode@v1
39+
with:
40+
xcode-version: latest-stable
4041

41-
- name: Checkout maplibre-swiftui-dsl-playground
42-
uses: actions/checkout@v4
42+
- name: Checkout maplibre-swiftui-dsl-playground
43+
uses: actions/checkout@v4
4344

44-
- name: Test ${{ matrix.scheme }} on ${{ matrix.destination }}
45-
run: xcodebuild -scheme ${{ matrix.scheme }} test -skipMacroValidation -destination '${{ matrix.destination }}' | xcbeautify && exit ${PIPESTATUS[0]}
46-
45+
- name: Test ${{ matrix.scheme }} on ${{ matrix.destination }}
46+
run: xcodebuild -scheme ${{ matrix.scheme }} test -skipMacroValidation -destination '${{ matrix.destination }}' | xcbeautify && exit ${PIPESTATUS[0]}

.swiftpm/xcode/xcshareddata/xcschemes/MapLibreSwiftUI-Package.xcscheme

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@
4848
ReferencedContainer = "container:">
4949
</BuildableReference>
5050
</BuildActionEntry>
51+
<BuildActionEntry
52+
buildForTesting = "YES"
53+
buildForRunning = "YES"
54+
buildForProfiling = "YES"
55+
buildForArchiving = "YES"
56+
buildForAnalyzing = "YES">
57+
<BuildableReference
58+
BuildableIdentifier = "primary"
59+
BlueprintIdentifier = "MapLibreSwiftMacros"
60+
BuildableName = "MapLibreSwiftMacros"
61+
BlueprintName = "MapLibreSwiftMacros"
62+
ReferencedContainer = "container:">
63+
</BuildableReference>
64+
</BuildActionEntry>
5165
</BuildActionEntries>
5266
</BuildAction>
5367
<TestAction

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Version 0.9.0 - 2025-03-17
9+
10+
- Moves macro targets into this project. No longer depending on separate https://github.com/stadiamaps/maplibre-swift-macros repo.
11+
812
## Version 0.8.0 - 2025-03-17
913

1014
- onMapViewProxyUpdate can now be set up to update in realtime or when animations/scrolling complete (default).

Package.resolved

Lines changed: 14 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ let package = Package(
1919
name: "MapLibreSwiftDSL",
2020
targets: ["MapLibreSwiftDSL"]
2121
),
22+
.library(
23+
name: "MapLibreSwiftMacros",
24+
targets: ["MapLibreSwiftMacros"]
25+
),
2226
],
2327
dependencies: [
2428
.package(url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.10.0"),
25-
.package(url: "https://github.com/stadiamaps/maplibre-swift-macros.git", from: "0.0.5"),
29+
// Macros
30+
.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.0.0" ..< "601.0.0"),
2631
// Testing
27-
.package(url: "https://github.com/Kolos65/Mockable.git", from: "0.2.0"),
32+
.package(url: "https://github.com/Kolos65/Mockable.git", from: "0.3.0"),
2833
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.17.7"),
34+
// Macro Testing
35+
.package(url: "https://github.com/pointfreeco/swift-macro-testing", .upToNextMinor(from: "0.6.0")),
2936
],
3037
targets: [
3138
.target(
@@ -46,7 +53,7 @@ let package = Package(
4653
dependencies: [
4754
.target(name: "InternalUtils"),
4855
.product(name: "MapLibre", package: "maplibre-gl-native-distribution"),
49-
.product(name: "MapLibreSwiftMacros", package: "maplibre-swift-macros"),
56+
"MapLibreSwiftMacros",
5057
],
5158
swiftSettings: [
5259
.enableExperimentalFeature("StrictConcurrency"),
@@ -62,6 +69,19 @@ let package = Package(
6269
]
6370
),
6471

72+
// MARK: Macro
73+
74+
.macro(
75+
name: "MapLibreSwiftMacrosImpl",
76+
dependencies: [
77+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
78+
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
79+
]
80+
),
81+
82+
// Library that exposes a macro as part of its API, which is used in client programs.
83+
.target(name: "MapLibreSwiftMacros", dependencies: ["MapLibreSwiftMacrosImpl"]),
84+
6585
// MARK: Tests
6686

6787
.testTarget(
@@ -78,5 +98,16 @@ let package = Package(
7898
"MapLibreSwiftDSL",
7999
]
80100
),
101+
102+
// MARK: Macro Tests
103+
104+
.testTarget(
105+
name: "MapLibreSwiftMacrosTests",
106+
dependencies: [
107+
"MapLibreSwiftMacrosImpl",
108+
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
109+
.product(name: "MacroTesting", package: "swift-macro-testing"),
110+
]
111+
),
81112
]
82113
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
3+
/// Adds a stored property and modifiers for an attribute that can be styled using a MapLibre style expression.
4+
///
5+
/// Layout and paint properties may be specified using expresisons.
6+
/// Some expressions may suppeort more types of expressions than others (ex: interpolated).
7+
/// TODO: Figure out where these edges are.
8+
/// TODO: Document different types
9+
@attached(member, names: arbitrary)
10+
public macro MLNStyleProperty<T>(_ named: String, supportsInterpolation: Bool = false) = #externalMacro(
11+
module: "MapLibreSwiftMacrosImpl",
12+
type: "MLNStylePropertyMacro"
13+
)
14+
15+
// NOTE: This version of the macro cannot be more specific, but it is assumed that T: MLNRawRepresentable.
16+
// This bound should be reintroduced when the packages are re-merged.
17+
@attached(member, names: arbitrary)
18+
public macro MLNRawRepresentableStyleProperty<T>(_ named: String) = #externalMacro(
19+
module: "MapLibreSwiftMacrosImpl",
20+
type: "MLNRawRepresentableStylePropertyMacro"
21+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SwiftCompilerPlugin
2+
import SwiftSyntaxMacros
3+
4+
@main
5+
struct MapLibreSwiftMacrosPlugin: CompilerPlugin {
6+
let providingMacros: [Macro.Type] = [
7+
MLNStylePropertyMacro.self,
8+
MLNRawRepresentableStylePropertyMacro.self,
9+
]
10+
}

0 commit comments

Comments
 (0)