Sample Code Library
Enhance and expand your knowledge of Apple technologies by exploring the full library of sample code projects.
Featured at WWDC25
Explore samples that highlight new APIs featured at this year’s conference.
Topics
WWDC25
Adding intelligent app features with generative modelsAdopting App Intents to support system experiencesAdopting SwiftData for a Core Data appAuthoring Apple Immersive VideoAVCam: Building a camera appBringing advanced speech-to-text capabilities to your appBuilding a workout app for iPhone and iPadBuilding peer-to-peer appsBuilding rich SwiftUI text experiencesCanyon Crosser: Building a volumetric hike-planning appCapturing Cinematic videoCapturing Spatial Audio in your iOS appCode-along: Elevating an app with Swift concurrencyConverting projected video to Apple Projected Media ProfileCreating a seamless multiview playback experienceDrawing a triangle with Metal 4Editing Spatial Audio with an audio mixEnhancing your app’s privacy and security with quantum-secure workflowsEnhancing your app with machine learning-based video effectsEnhancing your custom text engine with Writing ToolsFiltering traffic by URLGenerate dynamic game content with guided generation and toolsImplementing a background delivery extensionImplementing a store in your app using the StoreKit APILandmarks: Applying a background extension effectLandmarks: Building an app with Liquid GlassLandmarks: Displaying custom activity badgesLandmarks: Extending horizontal scrolling under a sidebar or inspectorLandmarks: Refining the system provided Liquid Glass effect in toolbarsLanguage IntrospectorLocalizing LandmarksLogging symptoms associated with a medicationManaging location-based remindersOptimizing home electricity usagePerforming fast account creation with passkeysPetite Asteroids: Building a volumetric visionOS gamePlaying immersive media with AVKitPlaying immersive media with RealityKitPresenting images in RealityKitRecognizing tables within a documentRendering hover effects in Metal immersive appsScheduling an alarm with AlarmKitSearching, displaying, and navigating to placesSupporting real-time ML inference on the CPUSynchronizing group gameplay with TabletopKitTracking accessories in volumetric windowsTracking a handheld accessory as a virtual sculpting toolUnderstanding StoreKit workflows
Accelerate
Adding a bokeh effect to imagesAdjusting saturation and applying tone mappingAdjusting the brightness and contrast of an imageAdjusting the hue of an imageApplying biquadratic filters to a music loopApplying tone curve adjustments to imagesApplying transformations to selected colors in an imageApplying vImage operations to video sample buffersBlurring an imageCalculating the dominant colors in an imageCompressing and decompressing files with stream compressionCompressing an image using linear algebraConverting color images to grayscaleConverting luminance and chrominance planes to an ARGB imageCreating an audio unit extension using the vDSP libraryCropping to the subject in a chroma-keyed imageEqualizing audio with discrete cosine transforms (DCTs)Finding the sharpest image in a sequence of captured imagesHalftone descreening with 2D fast Fourier transformImproving the quality of quantized images with ditheringIntegrating vImage pixel buffers into a Core Image workflowReducing artifacts with custom resampling filtersRotating a cube by transforming its verticesSharing texture data between the Model I/O framework and the vImage librarySignal extraction from noiseSolving systems of linear equations with LAPACKSpecifying histograms with vImageTraining a neural network to recognize digitsUsing vImage pixel buffers to generate video effectsVisualizing sound as an audio spectrogram
Accessibility
Accessibility design for Mac CatalystCreating accessible viewsDelivering an exceptional accessibility experienceEnhancing the accessibility of your SwiftUI appIntegrating accessibility into your appResponding to changes in the flashing lights settingTranslating text within your appWWDC21 Challenge: Large Text ChallengeWWDC21 Challenge: Speech Synthesizer SimulatorWWDC21 Challenge: VoiceOver MazeWWDC22 Challenge: Learn Switch Control through gaming
App frameworks
Building a Localized Food-Ordering AppBuilding a resumable upload server with SwiftNIOContinuing User Activities with HandoffDisplaying Human-Friendly ContentFruta: Building a feature-rich app with SwiftUIIncreasing App Usage with Suggestions Based on User ActivitiesInteracting with App Clip Codes in ARSynchronizing App Preferences with iCloudUsing JSON with custom types
App Intents and SiriKit
Accelerating app interactions with App IntentsAdding Shortcuts for Wind DownBooking Rides with SiriKitDefining your app’s Focus filterHandling Payment Requests with SiriKitHandling Workout Requests with SiriKitIntegrating Your App with Siri Event SuggestionsMaking your app’s functionality available to SiriManaging Audio with SiriKitProviding Hands-Free App Control with IntentsSoup Chef: Accelerating App Interactions with ShortcutsSoup Chef with App Intents: Migrating custom intents
AppKit
Add Functionality to Finder with Action ExtensionsCreating and Customizing the Touch BarDeveloping a Document-Based AppIntegrating a Toolbar and Touch Bar into Your AppNavigating Hierarchical Data Using Outline and Split ViewsOrganize Your User Interface with a Stack ViewSupporting Collection View Drag and Drop Through File PromisesSupporting Drag and Drop Through File PromisesSupporting Table View Drag and Drop Through File Promises
App services
Accessing a person’s contact data using Contacts and ContactsUIAccessing Calendar using EventKit and EventKitUIAdopting SwiftData for a Core Data appBuild an Educational Assessment AppBuild Mail App ExtensionsChecking IDs with the Verifier APIConfiguring a home automation deviceConfiguring the PencilKit tool pickerCreating a data visualization dashboard with Swift ChartsCreating a Sticker App with a Custom LayoutCustomizing Scribble with InteractionsDownloading essential assets in the backgroundDrawing with PencilKitExample Order PackagesFetching weather forecasts with WeatherKitHandling Communication Notifications and Focus Status UpdatesHandling Different Data Types in Core DataHighlighting app features with TipKitIceCreamBuilder: Building an iMessage ExtensionImplementing Alert Push NotificationsImplementing a virtual conference extensionImplementing Background Push NotificationsImplementing Wallet ExtensionsIncorporating ClassKit into an Educational AppInspecting, Modifying, and Constructing PencilKit DrawingsIntegrating the Apple Maps Server API into Java server applicationsInteracting with a home automation networkLinking Data Between Two Core Data StoresLoading and displaying a large data feedManaging location-based remindersOffering Apple Pay in Your AppRefreshing and Maintaining Your App Using Background TasksRetrieve Power and Performance Metrics and Log InsightsSharing CloudKit Data with Other iCloud UsersSharing Core Data objects between iCloud usersShowcase App Data in SpotlightSynchronizing a local store to the cloudSynchronizing files using file provider extensionsUpdating your app package installer to use the new Service Management APIUploading App PreviewsVisualizing your app’s dataVoIP calling with CallKit
ARKit
Adding realistic reflections to an AR experienceBuilding local experiences with room trackingCapturing Body Motion in 3DCombining user face-tracking and world trackingCreating a collaborative sessionCreating a fog effect using scene depthCreating a multiuser AR experienceCreating an immersive ar experience with audioCreating screen annotations for objects in an AR experienceDetecting Images in an AR ExperienceDisplaying a point cloud using scene depthEffecting People Occlusion in Custom RenderersOccluding virtual content with peoplePlacing objects and handling 3D interactionRecognizing and Labeling Arbitrary ObjectsSaving and loading world dataScanning and Detecting 3D ObjectsStreaming an AR experienceTracking and altering imagesTracking and visualizing facesTracking and visualizing planesTracking geographic locations in ARVisualizing and interacting with a reconstructed scene
Audio and music
Adding synthesized speech to callsBecoming a now playable appBuilding a Custom Catalog and Matching AudioBuilding an Audio Server Plug-in and Driver ExtensionBuilding a signal generatorCapturing stereo audio from built-In microphonesCapturing system audio with Core Audio tapsClassifying Live Audio Input with a Built-in Sound ClassifierCreating a custom speech synthesizerCreating an audio device driverCreating an Audio Server Driver Plug-inCreating custom audio effectsDelivering Rich App Experiences with HapticsDiscovering a third-party media-streaming deviceEncoding and decoding audioExplore more content with MusicKitGenerating spatial audio from a multichannel audio streamGetting motion-activity data from headphonesIncorporating Audio Effects and InstrumentsIncorporating MIDI 2 into your appsIntegrating CarPlay with Your Music AppIntegrating CarPlay with Your Navigation AppIntegrating CarPlay with your quick-ordering appPerforming offline audio processingPlaying a Custom Haptic Pattern from a FilePlaying Collision-Based Haptic PatternsPlaying custom audio with your own playerPlaying Haptics on Game ControllersRecognizing speech in live audioShazamKit Dance Finder with Managed SessionTransferring Data Between Bluetooth Low Energy DevicesUpdating Continuous and Transient Haptic Parameters in Real TimeUsing Core Bluetooth ClassicUsing MusicKit to Integrate with Apple MusicUsing voice processing
Authentication
Accessing Keychain Items with Face ID or Touch IDConnecting to a service with passkeysImplementing User Authentication with Sign in with AppleLogging a User into Your App with Face ID or Touch IDSimplifying User Authentication in a tvOS App
AVFoundation
Adding a display mask rectangle metadata track to a movie fileAVCamBarcode: detecting barcodes and facesAVCam: Building a camera appAVCamFilter: Applying filters to a capture streamAVMultiCamPiP: Capturing from Multiple CamerasCapturing consistent color imagesCapturing depth using the LiDAR cameraConverting side-by-side 3D video to multiview HEVC and spatial videoDebugging AVFoundation audio mixes, compositions, and video compositionsEditing and playing HDR videoEnhancing live video by leveraging TrueDepth camera dataIntegrating AirPlay for long-form video appsProcessing spatial video with a custom video compositorProviding an integrated view of your timeline when playing HLS interstitialsReading multiview 3D video filesStreaming depth data from the TrueDepth cameraSupporting Continuity Camera in your macOS appSupporting coordinated media playbackSupporting remote interactions in tvOSUsing AVFoundation to play and persist HTTP live streamsUsing HEVC video with alphaWriting fragmented MPEG-4 files for HTTP Live Streaming
CoreML and CreateML
Classifying Images with Vision and Core MLCounting human body action repetitions in a live video feedCreating a model from tabular dataDetecting human actions in a live video feedDetecting human body poses in an imageFinding answers to questions in a text documentIntegrating a Core ML Model into Your AppPersonalizing a Model with On-Device UpdatesUnderstanding a Dice Roll with Vision and Object DetectionUsing Core ML for semantic image segmentation
Developer tools
Autosizing views for localization in iOSConfiguring your app to use alternate app iconsCreating custom modelers for intelligent instrumentsLocalization-friendly layouts in macOSProviding an edge-to-edge, full-screen experience in your iPad app running on a MacProviding touch gesture equivalents using Touch AlternativesSlothCreator: Building DocC documentation in Xcode
Games
Adding Recurring Leaderboards to Your GameCreating real-time gamesCreating tabletop gamesCreating turn-based gamesImplementing playing card overlap and physical characteristicsInteracting with virtual content blended with passthroughSimulating dice rolls as a component for your gameSupporting Game Controllers
Graphics
Building Widgets Using WidgetKit and SwiftUICreate a 3D model of an interior room by guiding the user through an AR experienceCustom GraphicsEmoji Rangers: Supporting Live Activities, interactivity, and animationsGenerating an animation with a Core Image Render DestinationMerging multiple scans into a single structurePDF WidgetsPostprocessing a Scene With Custom SymbolsProviding custom models for captured rooms and structure exportsSchema definitions for third-party DCCsWriting spatial photos
Health
Accessing a User’s Clinical RecordsAccessing Data from a SMART Health CardBuild a workout app for Apple WatchBuilding a multidevice workout appBuilding an App to Notify Users of COVID-19 ExposureCreating a Mobility Health AppReading and Writing HealthKit Series DataVisualizing HealthKit State of Mind in visionOS
Location and MapKit
Adopting live updates in Core LocationAnnotating a Map with Custom DataDecluttering a Map with MapKit Annotation ClusteringDisplaying an Indoor MapDisplaying an updating path of a user’s location historyDisplaying Indoor Maps with MapKit JSDisplaying overlays on a mapExplore a location with a highly detailed map and Look AroundFinding devices with precisionImplementing interactions between users in close proximityImplementing proximity-based interactions between a phone and watchImplementing spatial interactions with third-party accessoriesInteracting with nearby points of interestMonitoring location changes with Core LocationOptimizing Map Views with Filtering and Camera ConstraintsRanging for BeaconsSharing Your Location to Find a Park
Metal
Accelerating ray tracing and motion blur using MetalAccelerating ray tracing using MetalAchieving smooth frame rates with a Metal display linkAdding custom functions to a shader graphAdjusting the level of detail using Metal mesh shadersApplying temporal antialiasing and upscaling using MetalFXCalculating primitive visibility using depth testingCapturing Metal commands programmaticallyCombining blit and compute operations in a single passControl the ray tracing process using intersection queriesCreating a 3D application with hydra renderingCreating a custom Metal viewCreating a Metal dynamic libraryCreating and sampling texturesCulling occluded geometry using the visibility result bufferCustomizing a PyTorch operationCustomizing a TensorFlow operationCustomizing render pass setupCustomizing shaders using function pointers and stitchingDrawing a triangle with Metal 4Encoding argument buffers on the GPUEncoding indirect command buffers on the CPUEncoding indirect command buffers on the GPUFiltering images with MPSGraph FFT operationsImplementing a multistage image filter using heaps and eventsImplementing a multistage image filter using heaps and fencesImplementing order-independent transparency with image blocksImproving edge-rendering quality with multisample antialiasing (MSAA)Loading textures and models using Metal fast resource loadingManaging groups of resources with argument buffersMigrating OpenGL code to MetalMixing Metal and OpenGL rendering in a viewModern rendering with MetalPerforming calculations on a GPUProcessing HDR images with MetalReading pixel data from a drawable textureRendering a curve primitive in a ray tracing sceneRendering a scene with deferred lighting in C++Rendering a scene with deferred lighting in Objective-CRendering a scene with deferred lighting in SwiftRendering a scene with forward plus lighting using tile shadersRendering reflections in real time using ray tracingRendering reflections with fewer render passesRendering terrain dynamically with argument buffersRunning a machine learning model on the GPU timelineSelecting device objects for compute processingSelecting device objects for graphics renderingStreaming large images with Metal sparse texturesSupporting Simulator in a Metal appSynchronizing CPU and GPU workTraining a neural network using MPSGraphTraining a Neural Network with Metal Performance ShadersUsing argument buffers with resource heapsUsing function specialization to build pipeline variantsUsing Metal to draw a view’s contents
Photos and video
Bringing Photos picker to your SwiftUI appBrowsing and Modifying Photo AlbumsBuilding a guessing game for visionOSCapturing screen content in macOSControlling a DockKit accessory using your camera appCreating a collaborative photo gallery with SharePlayCreating a Slideshow Project Extension for PhotosDrawing content in a group sessionEncoding video for live streamingEncoding video for low-latency conferencingEncoding video for offline transcodingImplementing an inline Photos pickerPlaying and editing Cinematic mode videoRecording and Streaming Your macOS AppSelecting Photos and Videos in iOS
RealityKit and Reality Composer Pro
Altering RealityKit Rendering with Shader FunctionsAnimating entity rotation with a systemBringing your SceneKit projects to RealityKitBuilding an immersive experience with RealityKitBuilding an object reconstruction appCombining 2D and 3D views in an immersive appComposing interactive 3D content with RealityKit and Reality Composer ProConfiguring Collision in RealityKitConstruct an immersive environment for visionOSControlling Entity Collisions in RealityKitCreating a game with scene understandingCreating an App for Face-Painting in ARCreating a photogrammetry command-line appCreating a Spaceship gameCreating a spatial drawing app with RealityKitDocking a video player in an immersive sceneGenerating interactive geometry with RealityKitImplementing special rendering effects with RealityKit postprocessingIntegrating virtual objects with your environmentLoading entities with ShaderGraph materialsPresenting an artist’s sceneRendering a windowed game in stereoRendering stereoscopic video with RealityKitResponding to gestures on an entityScanning objects using Object CaptureSimulating particles in your visionOS appSimulating physics joints in your RealityKit appSimulating physics with collisions in your visionOS appTracking a handheld accessory as a virtual sculpting toolTransforming entities between RealityKit coordinate spacesTransforming RealityKit entities using gesturesUsing object capture assets in RealityKitWWDC21 Challenge: Framework Freestyle
StoreKit
Determining service entitlement on the serverGenerating a Promotional Offer Signature on the ServerImplementing a store in your app using the StoreKit APIOffering, completing, and restoring in-app purchasesOffering media for sale in your appRequesting App Store reviewsTesting and validating ad impression signatures and postbacks for SKAdNetwork
Swift and SwiftData
Adding and editing persistent data in your appCalling APIs Across Language BoundariesDefining data relationships with enumerations and model classesDeleting persistent data from your appFiltering and sorting persistent dataMaintaining a local copy of server dataMixing Languages in an Xcode projectTicTacFish: Implementing a game using distributed actorsUpdating an app to use strict concurrencyUpdating an App to Use Swift Concurrency
SwiftUI
Add rich graphics to your SwiftUI appAdopting drag and drop using SwiftUIBackyard Birds: Building an app with SwiftData and widgetsBringing multiple windows to your SwiftUI appBringing robust navigation structure to your SwiftUI appBuilding a document-based app using SwiftDataBuilding a great Mac app with SwiftUIComposing custom layouts with SwiftUIControlling the timing and movements of your animationsCreating accessible viewsCreating a tvOS media catalog app in SwiftUICreating custom container viewsCreating visual effects with SwiftUICustomizing window styles and state-restoration behavior in macOSEnhancing your app’s content with tab navigationFocus Cookbook: Supporting and enhancing focus-driven interactions in your SwiftUI appFood Truck: Building a SwiftUI multiplatform appLoading and displaying a large data feedManaging model data in your appMigrating from the Observable Object protocol to the Observable macroMonitoring data changes in your appRestoring your app’s state with SwiftUIWishlist: Planning travel in a SwiftUI app
System
Building a custom peer-to-peer protocolBuilding an NFC Tag-Reader AppBuilding a passthrough file systemBuilding a Simple USB DriverCollecting Network Connection MetricsCommunicating between a DriverKit extension and a client appCommunicating with a Modem on a Serial PortConfiguring a Wi-Fi accessory to join a networkConnecting a network driverConstraining a tool’s launch environmentCreating a MIDI device driverCreating NFC Tags from Your iPhoneEncrypting and Decrypting a Single FileEncrypting and Decrypting a StringEncrypting and Decrypting DirectoriesFiltering Network TrafficHandling Keyboard Events from a Human Interface DeviceHandling Stylus Input from a Human Interface DeviceImplementing netcat with Network FrameworkMonitoring System Events with Endpoint SecurityPerforming Common Cryptographic OperationsReceiving Voice and Text Communications on a Local NetworkRunning GUI Linux in a virtual machine on a MacRunning Linux in a Virtual MachineRunning macOS in a virtual machine on Apple siliconSetting up and authorizing a Bluetooth accessorySetting up a PIR server for URL filteringSharing Wi-Fi network credentialsStoring CryptoKit Keys in the KeychainUsing the Bloom filter tool to configure a URL filter
TV
Adopting Picture in Picture Playback in tvOSBinding JSON data to TVML documentsBuilding a Full Screen Top Shelf ExtensionCreating a Client-Server TVML AppCreating a multiview video playback experience in visionOSCreating immersive experiences using a full-screen layoutDisplaying a Product or Bundle in a Full-Page TemplateImplementing a Hybrid TV App with TVMLKitMapping Apple TV users to app profilesPlaying Media in a Client-Server AppPlaying video content in a standard user interfaceResponding to User InteractionSupporting Continuity Camera in your tvOS appSupporting Multiple Users in Your tvOS AppWorking with Overlays and Parental Controls in tvOS
UIKit
Add Home Screen quick actionsAdding context menus in your appAdding hardware keyboard support to your appAdding menus and shortcuts to the menu bar and user interfaceAdjusting your layout with keyboard layout guideAdopting drag and drop in a custom viewAdopting drag and drop in a table viewAdopting hover support for Apple PencilAdopting iOS Dark ModeAdopting menus and UIActions in your user interfaceAsynchronously loading images into table and collection viewsBuilding a document browser app for custom file formatsBuilding an app with a document browserBuilding and improving your app with Mac CatalystBuilding high-performance lists and collection viewsChanging the appearance of selected and highlighted cellsCreating self-sizing table view cellsCustomizing and resizing sheets in UIKitCustomizing an image picker controllerCustomizing collection view layoutsCustomizing your app’s navigation barData delivery with drag and dropDetecting changes in the preferences windowDisabling the pull-down gesture for a sheetDisplaying searchable content by using a search controllerDisplay text with a custom layoutEnhancing your iPad app with pointer interactionsEnriching your text in text viewsIllustrating the force, altitude, and azimuth properties of touch inputImplementing modern collection viewsImplementing Peek and PopIntegrating pointer interactions into your iPad appLeveraging touch input for drawing appsNavigating an app’s user interface using a keyboardPrefetching collection view dataRestoring your app’s stateSelecting multiple items with a two-finger pan gestureShowing help tags for views and controls using tooltip interactionsSupporting desktop-class features in your iPad appSupporting gesture interaction in your appsSupporting HDR images in your appSupporting multiple windows on iPadSynchronizing documents in the iCloud environmentUIKit Catalog: Creating and customizing views and controlsUpdating collection views using diffable data sourcesUsing suggested searches with a search controllerUsing SwiftUI with UIKitUsing TextKit 2 to interact with text
Vision
Aligning Similar ImagesAnalyzing a selfie and visualizing its contentAnalyzing Image Similarity with Feature PrintApplying Matte Effects to People in Images and VideoApplying visual effects to foreground subjectsBuilding a feature-rich app for sports analysisClassifying images for categorization and searchDetecting animal body poses with VisionDetecting Hand Poses with VisionDetecting human body poses in 3D with VisionDetecting moving objects in a videoDetecting Objects in Still ImagesExtracting phone numbers from text in imagesGenerating high-quality thumbnails from videosHighlighting Areas of Interest in an Image Using SaliencyLocating and displaying recognized textRecognizing Objects in Live CaptureSegmenting and colorizing individuals from a surrounding sceneSelecting a selfie based on capture qualityStructuring recognized text on a documentTracking Multiple Objects or Rectangles in VideoTracking the User’s Face in Real TimeTraining a Create ML Model to Classify Flowers
visionOS
Accessing the main cameraAdding a depth effect to text in visionOSAnimating hand models in visionOSApplying mesh to real-world surroundingsBOT-anistBuilding an immersive media viewing experienceBuilding local experiences with room trackingConnecting iPadOS and visionOS apps over the local networkCreating 2D shapes with SwiftUICreating 3D entities with RealityKitCreating 3D models as movable windowsCreating a 3D painting spaceCreating a foveated streaming client on visionOSCreating an immersive space in visionOSCreating an interactive 3D model in visionOSCreating SwiftUI windows in visionOSDestination VideoDioramaDisplaying a 3D environment through a portalDisplaying an entity that follows a person’s viewDisplaying a stereoscopic imageDisplaying text in visionOSDisplaying video from connected devicesDrawing in the air and on surfaces with a spatial stylusEnabling video reflections in an immersive environmentExploring object tracking with ARKitGenerating procedural texturesHappy BeamHello WorldImplementing adjustable materialImplementing SharePlay for immersive spaces in visionOSIncorporating real-world surroundings in an immersive experienceLocating and decoding barcodes in 3D spaceManipulating entities with solid collisionsObject tracking with Reality Composer Pro experiencesObscuring virtual items in a scene behind real-world itemsPlacing content on detected planesPlacing entities using head and device transformPlaying spatial audioSwift SplashTracking and visualizing hand movementTracking specific points in world space
Watch
Building a productivity app for Apple WatchCreate accessible experiences for watchOSCreating and updating a complication’s timelineCustomizing workouts with WorkoutKitDisplaying essential information on a watch faceInteracting with Bluetooth peripherals during background app refreshProviding Multiple ComplicationsTransferring data with Watch ConnectivityUpdating your app and widgets for watchOS 10
Web
Adopting Declarative Content Blocking in Safari Web ExtensionsAdopting New Safari Web Extension APIsCreating Safari Web Inspector extensionsDeveloping a browser app that uses an alternative browser engineDeveloping a Safari Web ExtensionMessaging a Web Extension’s Native AppModernizing Safari Web ExtensionsPreviewing Metadata using Open GraphViewing Desktop or Mobile Web Content Using a Web View