{"id":13778777,"url":"https://github.com/posix88/SafePreviewDevice","last_synced_at":"2025-05-11T12:31:49.869Z","repository":{"id":44937213,"uuid":"259871247","full_name":"posix88/SafePreviewDevice","owner":"posix88","description":"Safe and fast access to SwiftUI PreviewDevice","archived":false,"fork":false,"pushed_at":"2022-01-17T14:07:36.000Z","size":23,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-31T15:51:14.704Z","etag":null,"topics":["previewdevice","swift","swift-library","swift-package-manager","swiftui","swiftui-components","swiftui-framework","swiftui-helper","tool","xcode"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posix88.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-29T08:41:39.000Z","updated_at":"2023-01-30T23:43:12.000Z","dependencies_parsed_at":"2022-09-04T00:52:28.769Z","dependency_job_id":null,"html_url":"https://github.com/posix88/SafePreviewDevice","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posix88%2FSafePreviewDevice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posix88%2FSafePreviewDevice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posix88%2FSafePreviewDevice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posix88%2FSafePreviewDevice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posix88","download_url":"https://codeload.github.com/posix88/SafePreviewDevice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225048986,"owners_count":17412905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["previewdevice","swift","swift-library","swift-package-manager","swiftui","swiftui-components","swiftui-framework","swiftui-helper","tool","xcode"],"created_at":"2024-08-03T18:00:57.368Z","updated_at":"2024-11-17T14:30:55.751Z","avatar_url":"https://github.com/posix88.png","language":"Swift","funding_links":[],"categories":["Preview"],"sub_categories":["Content"],"readme":"# SafePreviewDevice\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/swift-5.1-orange.svg\" alt=\"Swift: 5.1\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/posix88/SafePreviewDevice/releases\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/version-0.1.0-blue.svg\"\n        alt=\"Version: 0.1.0\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"#\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Platforms-iOS%20|%20tvOS%20|%20watchOS|%20macOS-green.svg\"\n        alt=\"Platforms: iOS – tvOS – watchOS - macOS\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/piknotech/SFSafeSymbols/blob/stable/LICENSE.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-MIT-lightgrey.svg\" alt=\"License: MIT\"\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/apple/swift-package-manager\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg\" alt=\"SwiftPM: Compatible\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://cocoapods.org/pods/SafePreviewDevice\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/CocoaPods-compatible-4BC51D.svg?style=flat\" alt=\"CocoaPods: Compatible\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Motivation\n\nAt WWDC 2019, Apple announced SwiftUI a new library for building UI in a simple and fast way.  \nXcode’s SwiftUI preview lets us show our application design in multiple screen sizes at the same time using the `.previewDevice()` modifier. Currently, this needs to be provided with the exact name of the device you want to test:  e.g. “iPhone XS Max”.\n\n```swift\n.previewDevice(PreviewDevice(rawValue: \"iPhone XS Max\"))\n```\nor even better\n\n```swift\n.previewDevice(.iPhone7)\n```\n\nThis framework comes to rescue for everyone that is looking for an easy way to select their preview device or they just don't remember every iOS 13 device name (like me 😀)\n\n## System Requirements\n\nSupported platforms are `iOS (13.0)`, `tvOS (13.0)`, `watchOS (6.0)` and `macOS (10.15)` and of course `Xcode 11`.\n\n## Installation\n\n`SafePreviewDevice` can be installed via Swift Package Manager.\n\n### Swift Package Manager\n\nTo integrate using Apple's Swift package manager, add the following as a dependency to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/posix88/SafePreviewDevice.git\", .upToNextMajor(from: \"0.1.0\"))\n```\n\nand run `swift package update`.\n\nOtherwise, you can simply go to File -\u003e Swift Packages -\u003e Add Package Dependency and paste the repo's URL: `https://github.com/posix88/SafePreviewDevice`\n\n### CocoaPods\n\nAdd the following entry to your Podfile:\n\n```rb\npod 'SafePreviewDevice'\n```\n\nThen run `pod install`.\n\n## Usage\n\nSimply import this framework in your `SwiftUI` file and add one of this `View` modifier to your preview:\n\n### Display a preview device\n```swift\n.previewDevice(.iPhone7)\n```\nThis modifier will change the displayed device in the Xcode SwiftUI preview.\n\n### Change the preview device name\n```swift\n.previewDeviceName(.iPhone7)\n```\nThis modifier will change the displayed device name in the Xcode SwiftUI preview.\n\n## What's new 🚀\n\n### Display a named preview device\n```swift\n.previewNamedDevice(.iPhone7)\n```\nThis modifier is the union between the first APIs. \nIt will change the displayed device in the Xcode SwiftUI preview setting also the device name.\n\n### Display a preview device applying the color scheme\n```swift\n.previewDevice(.iPhone7, withColorScheme: .dark)\n```\nThis modifier will change the displayed device in the Xcode SwiftUI preview. It also applies the selected color scheme.\n\n### Display a named preview device applying the color scheme\n```swift\n.previewNamedDevice(.iPhone7, withColorScheme: .dark)\n```\nThis modifier will change the displayed named device in the Xcode SwiftUI preview. It also applies the selected color scheme.\n\n### Display a group of named preview device applying a list of color scheme\n```swift\n.previewDevices([.iPhone7, .iPhoneSE, .iPhoneX], withColorScheme: [.dark, .light])\n```\nThis modifier provides an inline alternative to \n```swift\nGroup {\n    MyView().previewDevice(.iPhone7, withColorScheme: .dark)\n    MyView().previewDevice(.iPhone7, withColorScheme: .light)\n    MyView().previewDevice(.iPhoneSE, withColorScheme: .dark)\n    MyView().previewDevice(.iPhoneSE, withColorScheme: .light)\n    MyView().previewDevice(.iPhoneX, withColorScheme: .dark)\n    MyView().previewDevice(.iPhoneX, withColorScheme: .light)\n}\n```\n\n## Contributing\n\n- If you **need help** or you'd like to **ask a general question**, open an issue.\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n\n## Acknowledgements\n\nMade with ❤️ in Milan by [Antonino Musolino](https://twitter.com/NinoMusolino).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposix88%2FSafePreviewDevice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposix88%2FSafePreviewDevice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposix88%2FSafePreviewDevice/lists"}