今日已更新 412 条资讯 | 累计 19972 条内容
关于我们

标签:#SwiftUI

找到 7 篇相关文章

AI 资讯

Stop Rebuilding the Same SwiftUI Components: A Guide to DesignFoundation

"I'll just write a quick button style... and a text field with validation... and a card component..." Two weeks later you have a bespoke design system that only half the app uses, three slightly different buttons, and nothing shipped. If you're building with an AI coding agent, the drift problem is worse, not better. Ask Claude, Cursor, or Codex to "add a settings screen" three separate times and you'll get three different paddings, three different corner radii, and a button style that quietly forked itself somewhere around commit 40. Agents are great at writing plausible SwiftUI and bad at remembering what the rest of your app already decided. DesignFoundation is an open-source SwiftUI package that gives you a token-based theming engine, 25 components, and 6 feedback/overlay modifiers that all read from the same theme. You set it once at the app root, and everything underneath updates. That's the whole idea — and it ships with CLAUDE.md , AGENTS.md , and Cursor rules already written, so an agent working in your repo reaches for DFButton instead of inventing a new one. In this tutorial you'll go from zero to a themed, consistent SwiftUI UI — without writing a single custom button style. What We're Building By the end you'll have: A working app that uses DesignFoundation's theme system A themed form with inputs, validation states, and feedback components A custom theme built from tokens An understanding of how the style system composes Requirements: Xcode 16+, iOS 18+ / macOS 15+ target, Swift 6. Installation Via Xcode File → Add Package Dependencies Paste https://github.com/NerdSnipe-Inc/design-foundation Set the version rule to Up to Next Major from 1.0.0 Add DesignFoundation to your target Via Package.swift dependencies : [ . package ( url : "https://github.com/NerdSnipe-Inc/design-foundation" , from : "1.0.0" ) ], targets : [ . target ( name : "YourApp" , dependencies : [ "DesignFoundation" ]) ] Step 1: One Line Instead of a ThemeManager Singleton Every app that

2026-07-07 原文 →
AI 资讯

Stop Rebuilding Auth, Onboarding, and Dashboards: DesignFoundationPro

Part 2 of 2. This tutorial builds on Part 1 — DesignFoundation core . If you haven't added the base package and theme yet, start there. The core package gives you tokens and primitives. DesignFoundationPro adds what comes next — 29 blocks, 47 screens, 18 navigation shells, and 9 runnable composition examples across auth, onboarding, charts, data tables, and full product verticals. The docs claim ~87% fewer lines of code versus building from scratch. That's the bet. This matters even more if an AI coding agent is doing the building. Ask an agent for a CRM screen and a settings screen in the same session and, without guardrails, you'll get two different takes on spacing, two different sidebar behaviors, and a table that's native on Mac in one screen and a scroll view pretending to be a table in the other. Pro ships with that guardrail already in place — more on that in Where to go from here. How the two packages relate Pro sits on top of Foundation and re-exports it. Import only DesignFoundationPro and you get everything from both: YourApp your models, data, routing DesignFoundationPro 29 blocks · 47 screens · 18 shells · 9 examples DesignFoundation tokens · primitives · validation · theme engine · MIT Access: Foundation is MIT and public. Pro is a commercial add-on — repo access is granted after purchase. Licenses are lifetime (no subscription); annual updates are $39/year and entirely optional. Pricing: $149 individual · $449 team (up to 5 devs). Before buying, browse everything in DFPlayground — a free macOS app that lets you preview all 29 blocks, 47 screens, and 18 shells with live theming. Step 1: Add DesignFoundationPro Pro declares Foundation as its own dependency and re-exports it via @_exported import DesignFoundation . Add only the Pro package — Foundation comes with it automatically. The Pro repo URL is provided after purchase — contact nerdsnipe.inc@gmail.com or visit the Pro page to get access. dependencies : [ . package ( url : "https://github.com/NerdS

2026-07-07 原文 →
开发者

SwiftUI Adds New Document Protocol, Improves Performance, and More

Announced at WWDC 2026, the latest SwiftUI release brings a new Document protocol for efficient disk access and snapshot-based updates, along with improved APIs for reordering items in lists, grids, and sections. In addition, it expands presentation features, such as swipe actions on any view, better AsyncImage caching, and lazy state initialization for Observable types to boost performance. By Sergio De Simone

2026-07-03 原文 →
AI 资讯

How to add license keys to a SwiftUI macOS app (in under an hour)

You built a Mac app, you want to sell it outside the App Store, and now you need licensing: a key the customer enters, an activation that sticks, and feature gates that hold up offline. Here's how to do it in an afternoon without standing up a backend. Note: this is cross-posted from the Keylight blog . I build Keylight, so this uses it as the worked example — the shape of the solution applies whatever SDK you choose. The three things licensing actually has to do Strip away the marketing and every licensing system does exactly three jobs: Activate — turn a key the user pastes in into proof-of-purchase bound to this device. Verify — on every launch, confirm that proof is still valid, including offline . Gate — unlock features based on the tier/entitlements the license carries. If you build this by hand you're writing a server, a crypto layer, and a state machine. The point of an SDK is to skip all three. 1. Add the SDK Add the Swift package in Xcode (File ▸ Add Package Dependencies) pointing at the Keylight Swift SDK, then configure it once with your tenant key at app launch: import Keylight let keylight = Keylight ( tenant : "your_tenant_key" ) 2. Activate a key Give the user a text field and call activate . This is the one online step — it exchanges the key for a signed, device-bound lease that's stored locally: do { try await keylight . activate ( key : enteredKey ) // lease stored — the app is now licensed on this device } catch { // show the user why: invalid key, device limit reached, etc. } 3. Verify on launch (offline-safe) On every subsequent launch you don't hit the network. The SDK verifies the stored lease's Ed25519 signature locally and hands you a state: switch keylight . checkOnLaunch () { case . licensed ( let lease ): unlockApp ( entitlements : lease . entitlements ) case . trial ( let daysLeft ): runTrial ( daysLeft : daysLeft ) case . expired , . invalid : showActivationScreen () } No server call, so the app opens instantly and works on a plane. Th

2026-06-27 原文 →
AI 资讯

Building an unofficial Dumpert client for Apple TV with Swift 6 and SwiftUI

Dumpert is a Dutch video site I've watched for years, but there's never been an Apple TV app, so I built one. DumpertTV is an unofficial, open-source tvOS client. Here's how it's put together and a few things that were more interesting than I expected. Disclaimer up front: this project is not affiliated with Dumpert or DPG Media B.V. It's an independent app that uses the public Dumpert API. The stack Swift 6 with strict concurrency ( complete mode) across every target SwiftUI for all UI, tvOS 18+ XcodeGen so the .xcodeproj is generated from a project.yml and never committed CloudKit , GroupActivities (SharePlay), Vision , AVKit , Swift Testing One actor for the network, one source of truth for the UI The whole networking layer is an actor . That makes per-request state like ETags and retry bookkeeping thread-safe without a single lock: actor DumpertAPIClient { private var etags : [ URL : String ] = [:] func fetch < T : Decodable > ( _ endpoint : APIEndpoint ) async throws -> T { // Exponential backoff on 5xx + network errors; honours 304 Not Modified. try await fetchWithRetry ( endpoint , attempt : 0 ) } } The UI reads from a single @Observable @MainActor repository injected through the SwiftUI environment — no Combine, no view models competing over the same state: @Observable @MainActor final class VideoRepository { private(set) var hotshiz : [ MediaItem ] = [] let apiClient : APIClientProtocol // protocol-backed for testing } ContentView () . environment ( videoRepository ) Views just read repository.hotshiz ; updates flow automatically. With Swift 6's strict concurrency on, the compiler kept me honest about every actor hop. Things that were trickier than expected tvOS focus + a top tab bar. Getting a Netflix-style hero carousel to behave with the focus engine took real care. It also made automating screenshots interesting — scripted remote input doesn't reliably drive the simulator, so I added #if DEBUG launch-argument hooks to jump straight to any tab/category f

2026-06-04 原文 →