Skip to content

Commit 94813a4

Browse files
authored
Merge pull request #30 from SoundBlaster/egor/spm
SPM
2 parents 3404da4 + 2c88df5 commit 94813a4

41 files changed

Lines changed: 1743 additions & 14 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Deploy DocC Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
build:
21+
runs-on: macos-14
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Xcode
27+
uses: maxim-lobanov/setup-xcode@v1
28+
with:
29+
xcode-version: latest-stable
30+
31+
- name: Build Documentation
32+
run: |
33+
swift package --allow-writing-to-directory ./docs \
34+
generate-documentation \
35+
--target NavigationSplitViewKit \
36+
--output-path ./docs \
37+
--transform-for-static-hosting \
38+
--hosting-base-path NavigationSplitView
39+
40+
- name: Add .nojekyll and index redirect
41+
run: |
42+
touch docs/.nojekyll
43+
cat > docs/index.html << 'EOF'
44+
<!DOCTYPE html>
45+
<html>
46+
<head>
47+
<meta charset="utf-8">
48+
<title>Redirecting to NavigationSplitViewKit Documentation</title>
49+
<meta http-equiv="refresh" content="0; url=./documentation/navigationsplitviewkit/">
50+
<link rel="canonical" href="./documentation/navigationsplitviewkit/">
51+
</head>
52+
<body>
53+
<p>Redirecting to <a href="./documentation/navigationsplitviewkit/">NavigationSplitViewKit Documentation</a>...</p>
54+
<script>window.location.href = "./documentation/navigationsplitviewkit/";</script>
55+
</body>
56+
</html>
57+
EOF
58+
59+
- name: Upload artifact
60+
if: github.event_name == 'push'
61+
uses: actions/upload-pages-artifact@v3
62+
with:
63+
path: "./docs"
64+
65+
deploy:
66+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
67+
needs: build
68+
runs-on: ubuntu-latest
69+
environment:
70+
name: github-pages
71+
url: ${{ steps.deployment.outputs.page_url }}
72+
steps:
73+
- name: Deploy to GitHub Pages
74+
id: deployment
75+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Xcode
2+
.DS_Store
3+
build/
4+
DerivedData/
5+
*.pbxuser
6+
!default.pbxuser
7+
*.mode1v3
8+
!default.mode1v3
9+
*.mode2v3
10+
!default.mode2v3
11+
*.perspectivev3
12+
!default.perspectivev3
13+
*.xccheckout
14+
*.moved-aside
15+
*.xcuserstate
16+
*.xcscmblueprint
17+
18+
# Swift Package Manager
19+
.build/
20+
.swiftpm/
21+
Package.resolved
22+
23+
# Documentation
24+
docs/
25+
DocsArchive/
26+
DocsBuild/
27+
28+
# Tuist
29+
.tuist/
30+
Derived/
31+
*.xcodeproj
32+
*.xcworkspace
33+
34+
# macOS
35+
.DS_Store
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SwiftUI
2+
3+
@main
4+
struct NavigationSplitViewDemoApp: App {
5+
var body: some Scene {
6+
WindowGroup {
7+
ContentView()
8+
}
9+
}
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "ios",
6+
"size" : "1024x1024"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import NavigationSplitViewKit
2+
import SwiftUI
3+
4+
struct ContentView: View {
5+
6+
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
7+
private let library = ColorLibrary()
8+
@State private var navigationModel = NavigationModel()
9+
10+
var body: some View {
11+
@Bindable var model = navigationModel
12+
13+
NavigationSplitView(columnVisibility: $model.columnVisibility) {
14+
List(library.categories, selection: $model.selectedCategory) { category in
15+
NavigationLink(value: category) {
16+
Text(category.name)
17+
}
18+
}
19+
.navigationTitle("Categories")
20+
} content: {
21+
CategoryView(
22+
category: model.selectedCategory,
23+
selection: $model.selectedColor
24+
)
25+
} detail: {
26+
DetailView(color: $model.selectedColor)
27+
.toolbar {
28+
ToolbarItem(placement: .primaryAction) {
29+
Button {
30+
model.showInspector.toggle()
31+
} label: {
32+
Label("Inspector", systemImage: "sidebar.right")
33+
}
34+
}
35+
}
36+
}
37+
.navigationSplitViewStyle(.automatic)
38+
.inspector(isPresented: $model.showInspector) {
39+
InspectorPanel(color: model.selectedColor) {
40+
model.showInspector = false
41+
}
42+
}
43+
.task {
44+
model.bootstrap(using: library.categories, sizeClass: horizontalSizeClass)
45+
}
46+
.onChange(of: horizontalSizeClass) { _, newValue in
47+
model.handleSizeClassChange(newValue)
48+
}
49+
.onChange(of: model.selectedCategory) { _, _ in
50+
model.handleCategoryChange(sizeClass: horizontalSizeClass)
51+
}
52+
}
53+
}
54+
55+
#Preview {
56+
ContentView()
57+
}

Demo/Project.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import ProjectDescription
2+
3+
let project = Project(
4+
name: "NavigationSplitViewDemo",
5+
targets: [
6+
.target(
7+
name: "NavigationSplitViewDemo",
8+
destinations: [.iPhone, .iPad, .mac],
9+
product: .app,
10+
bundleId: "com.example.NavigationSplitViewDemo",
11+
deploymentTargets: .multiplatform(
12+
iOS: "17.0",
13+
macOS: "14.0"
14+
),
15+
infoPlist: .extendingDefault(
16+
with: [
17+
"UILaunchScreen": [:],
18+
"UISupportedInterfaceOrientations": [
19+
"UIInterfaceOrientationPortrait",
20+
"UIInterfaceOrientationLandscapeLeft",
21+
"UIInterfaceOrientationLandscapeRight",
22+
],
23+
"UISupportedInterfaceOrientations~ipad": [
24+
"UIInterfaceOrientationPortrait",
25+
"UIInterfaceOrientationPortraitUpsideDown",
26+
"UIInterfaceOrientationLandscapeLeft",
27+
"UIInterfaceOrientationLandscapeRight",
28+
],
29+
]
30+
),
31+
sources: ["NavigationSplitViewDemo/**"],
32+
resources: ["NavigationSplitViewDemo/Assets.xcassets"],
33+
dependencies: [
34+
.project(target: "NavigationSplitViewKit", path: "..")
35+
]
36+
)
37+
]
38+
)

Demo/TUIST_SETUP.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Tuist Setup for NavigationSplitViewDemo
2+
3+
## Configuration
4+
5+
The demo app is configured to support:
6+
-**iPhone** - iOS 17.0+
7+
-**iPad** - iOS 17.0+ (native iPad support)
8+
-**Mac** - macOS 14.0+ (native Mac support, NOT Designed for iPad)
9+
10+
## Features Configured
11+
12+
### Platform Support
13+
- `destinations: [.iPhone, .iPad, .mac]` - Native support for all platforms
14+
- iPhone: portrait + landscape
15+
- iPad: all orientations
16+
- Mac: native application
17+
18+
### Deployment Targets
19+
- iOS: 17.0
20+
- macOS: 14.0
21+
22+
## Installation & Generation
23+
24+
### 1. Install Tuist (if not already installed)
25+
26+
```bash
27+
curl -Ls https://install.tuist.io | bash
28+
```
29+
30+
Or with Homebrew:
31+
```bash
32+
brew install tuist
33+
```
34+
35+
### 2. Generate Xcode Project
36+
37+
From the Demo directory:
38+
```bash
39+
cd Demo
40+
tuist generate
41+
```
42+
43+
This will create:
44+
- `NavigationSplitViewDemo.xcodeproj` - with native Mac support
45+
- Proper framework linking to parent library
46+
- All assets and resources configured
47+
48+
### 3. Build & Run
49+
50+
Open the generated project:
51+
```bash
52+
open NavigationSplitViewDemo.xcodeproj
53+
```
54+
55+
Then:
56+
- **For iPhone/iPad**: Select iPhone/iPad simulator or device
57+
- **For Mac**: Select "My Mac" as destination → native macOS app
58+
59+
## What Changed vs. Original
60+
61+
| Before | After |
62+
|--------|-------|
63+
| `destinations: .iOS` | `destinations: [.iPhone, .iPad, .mac]` |
64+
| iPhone only | **Native Mac support** |
65+
| "Designed for iPad" | **Native Mac application** |
66+
| No macOS option | macOS 14.0+ support |
67+
68+
## Notes
69+
70+
- The app will be a **native macOS application**, not "Designed for iPad"
71+
- Full NavigationSplitView adaptive layout works on all platforms
72+
- macOS features adaptive UI with proper column visibility
73+
- All SwiftUI features work natively on Mac
74+
75+
## Troubleshooting
76+
77+
If you get "tuist: command not found":
78+
1. Install Tuist: `curl -Ls https://install.tuist.io | bash`
79+
2. Add to PATH if needed: `export PATH="/usr/local/bin:$PATH"`
80+
3. Run `tuist generate` again
81+
82+
## Next Steps
83+
84+
After generating:
85+
1. Open project in Xcode
86+
2. Select "My Mac" as destination
87+
3. Build & Run → Native macOS app! 🎉

0 commit comments

Comments
 (0)