Skip to content
Merged

SPM #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy DocC Documentation

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Build Documentation
run: |
swift package --allow-writing-to-directory ./docs \
generate-documentation \
--target NavigationSplitViewKit \
--output-path ./docs \
--transform-for-static-hosting \
--hosting-base-path NavigationSplitView

- name: Add .nojekyll and index redirect
run: |
touch docs/.nojekyll
cat > docs/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting to NavigationSplitViewKit Documentation</title>
<meta http-equiv="refresh" content="0; url=./documentation/navigationsplitviewkit/">
<link rel="canonical" href="./documentation/navigationsplitviewkit/">
</head>
<body>
<p>Redirecting to <a href="./documentation/navigationsplitviewkit/">NavigationSplitViewKit Documentation</a>...</p>
<script>window.location.href = "./documentation/navigationsplitviewkit/";</script>
</body>
</html>
EOF

- name: Upload artifact
if: github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: "./docs"

deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Xcode
.DS_Store
build/
DerivedData/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint

# Swift Package Manager
.build/
.swiftpm/
Package.resolved

# Documentation
docs/
DocsArchive/
DocsBuild/

# Tuist
.tuist/
Derived/
*.xcodeproj
*.xcworkspace

# macOS
.DS_Store
10 changes: 10 additions & 0 deletions Demo/NavigationSplitViewDemo/App/NavigationSplitViewDemoApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SwiftUI

@main
struct NavigationSplitViewDemoApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Demo/NavigationSplitViewDemo/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
57 changes: 57 additions & 0 deletions Demo/NavigationSplitViewDemo/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import NavigationSplitViewKit
import SwiftUI

struct ContentView: View {

@Environment(\.horizontalSizeClass) private var horizontalSizeClass
private let library = ColorLibrary()
@State private var navigationModel = NavigationModel()

var body: some View {
@Bindable var model = navigationModel

NavigationSplitView(columnVisibility: $model.columnVisibility) {
List(library.categories, selection: $model.selectedCategory) { category in
NavigationLink(value: category) {
Text(category.name)
}
}
.navigationTitle("Categories")
} content: {
CategoryView(
category: model.selectedCategory,
selection: $model.selectedColor
)
} detail: {
DetailView(color: $model.selectedColor)
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button {
model.showInspector.toggle()
} label: {
Label("Inspector", systemImage: "sidebar.right")
}
}
}
}
.navigationSplitViewStyle(.automatic)
.inspector(isPresented: $model.showInspector) {
InspectorPanel(color: model.selectedColor) {
model.showInspector = false
}
}
.task {
model.bootstrap(using: library.categories, sizeClass: horizontalSizeClass)
}
.onChange(of: horizontalSizeClass) { _, newValue in
model.handleSizeClassChange(newValue)
}
.onChange(of: model.selectedCategory) { _, _ in
model.handleCategoryChange(sizeClass: horizontalSizeClass)
}
}
}

#Preview {
ContentView()
}
38 changes: 38 additions & 0 deletions Demo/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import ProjectDescription

let project = Project(
name: "NavigationSplitViewDemo",
targets: [
.target(
name: "NavigationSplitViewDemo",
destinations: [.iPhone, .iPad, .mac],
product: .app,
bundleId: "com.example.NavigationSplitViewDemo",
deploymentTargets: .multiplatform(
iOS: "17.0",
macOS: "14.0"
),
infoPlist: .extendingDefault(
with: [
"UILaunchScreen": [:],
"UISupportedInterfaceOrientations": [
"UIInterfaceOrientationPortrait",
"UIInterfaceOrientationLandscapeLeft",
"UIInterfaceOrientationLandscapeRight",
],
"UISupportedInterfaceOrientations~ipad": [
"UIInterfaceOrientationPortrait",
"UIInterfaceOrientationPortraitUpsideDown",
"UIInterfaceOrientationLandscapeLeft",
"UIInterfaceOrientationLandscapeRight",
],
]
),
sources: ["NavigationSplitViewDemo/**"],
resources: ["NavigationSplitViewDemo/Assets.xcassets"],
dependencies: [
.project(target: "NavigationSplitViewKit", path: "..")
]
)
]
)
87 changes: 87 additions & 0 deletions Demo/TUIST_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Tuist Setup for NavigationSplitViewDemo

## Configuration

The demo app is configured to support:
- ✅ **iPhone** - iOS 17.0+
- ✅ **iPad** - iOS 17.0+ (native iPad support)
- ✅ **Mac** - macOS 14.0+ (native Mac support, NOT Designed for iPad)

## Features Configured

### Platform Support
- `destinations: [.iPhone, .iPad, .mac]` - Native support for all platforms
- iPhone: portrait + landscape
- iPad: all orientations
- Mac: native application

### Deployment Targets
- iOS: 17.0
- macOS: 14.0

## Installation & Generation

### 1. Install Tuist (if not already installed)

```bash
curl -Ls https://install.tuist.io | bash
```

Or with Homebrew:
```bash
brew install tuist
```

### 2. Generate Xcode Project

From the Demo directory:
```bash
cd Demo
tuist generate
```

This will create:
- `NavigationSplitViewDemo.xcodeproj` - with native Mac support
- Proper framework linking to parent library
- All assets and resources configured

### 3. Build & Run

Open the generated project:
```bash
open NavigationSplitViewDemo.xcodeproj
```

Then:
- **For iPhone/iPad**: Select iPhone/iPad simulator or device
- **For Mac**: Select "My Mac" as destination → native macOS app

## What Changed vs. Original

| Before | After |
|--------|-------|
| `destinations: .iOS` | `destinations: [.iPhone, .iPad, .mac]` |
| iPhone only | **Native Mac support** |
| "Designed for iPad" | **Native Mac application** |
| No macOS option | macOS 14.0+ support |

## Notes

- The app will be a **native macOS application**, not "Designed for iPad"
- Full NavigationSplitView adaptive layout works on all platforms
- macOS features adaptive UI with proper column visibility
- All SwiftUI features work natively on Mac

## Troubleshooting

If you get "tuist: command not found":
1. Install Tuist: `curl -Ls https://install.tuist.io | bash`
2. Add to PATH if needed: `export PATH="/usr/local/bin:$PATH"`
3. Run `tuist generate` again

## Next Steps

After generating:
1. Open project in Xcode
2. Select "My Mac" as destination
3. Build & Run → Native macOS app! 🎉
Loading