Simulate any device and settings on one simulator or device.

Overview

SwiftUI-Simulator

Enables the following settings without settings or restarting the simulator or real device.

  • Any device screen
  • Light/Dark mode
  • Locale
  • Calendar
  • TimeZone
  • Dynamic Type Sizes
  • Rotate
  • Legibility Weight (Not working in latest iOS and Xcode preview)
2022-04-14.15.16.50.mov

No more restarting or settings!

And following:

  • Show safe area and size.
  • Show device information.
  • Show cheet sheets. (useful for development)

Note: This is only a simulation and may differ from how it looks on a simulator or real device.

Quick Start

  1. Install via Swift Package Manager.
let package = Package(
    dependencies: [
        .package(url: "https://github.com/YusukeHosonuma/SwiftUI-Simulator.git", from: "1.3.0"),
    ],
    targets: [
        .target(name: "<your-target-name>", dependencies: [
             .product(name: "SwiftUISimulator", package: "SwiftUI-Simulator"),
        ]),
    ]
)
  1. Surround the your app's root view with SimulatorView.
import SwiftUISimulator

@main
struct ExampleApp: App {
    var body: some Scene {
        WindowGroup {
            SimulatorView { // ✅ Please surround the your app's root view with `SimulatorView`.
                ContentView()
            }
        }
    }
}
  1. Launch on any simulator or device. (Large screen is recommended)
iPhone 13 Pro Max iPad Pro (12.9-inch)
image image

Requirements

  • iOS 14+ (iPhone / iPad)
    • Dynamic Type Sizes is supports in iOS 15+

Limitation

  • This OSS supports SwiftUI app only.
    • For example, it may not work if you have resolve locale by yourself. (e.g. use SwiftGen)
  • sheet() and fullScreenCover() are not working currently. #37

Configurations

You can specify default devices, locale identifiers, calendar identifiers and timezone.

SimulatorView(
    defaultDevices: [.iPhone11, .iPhone13ProMax],       // Set<Device>
    defaultLocaleIdentifiers: ["it", "fr"],             // Set<String>
    defaultCalendarIdentifiers: [.gregorian, .iso8601], // Set<Calendar.Identifier>
    defaultTimeZones: [.europeParis, .europeBerlin]     // Set<TimeZones>
    accentColorName: "MyAccentColor",                   // when not use default accent color name in Assets.
) {
    RootView()
}

This is useful if you want to share with your team.

Contributions

Issues and PRs are welcome, even for minor improvements and corrections.

FAQ

Q. How it works?
A. Perhaps as you might imagine, this is achieved by overriding SwiftUI's Environment.

Q. How to disable this simulator?
A. Disable Simulator in setting menu.

image

Author

Yusuke Hosonuma / @tobi462

You might also like...
How to add Keyboard Shortcuts to any SwiftUI App with UIKeyCommand
How to add Keyboard Shortcuts to any SwiftUI App with UIKeyCommand

SwiftUI-Keyboard-Demo This tiny project was built to show how simple it is to add keyboard shortcuts (with UIKeyCommand) to any SwiftUI app. After imp

A Meetings app where the user is presented with the number of meetings created , join any them , edit the varied details also keeping the track of the history of the meetings.
A Meetings app where the user is presented with the number of meetings created , join any them , edit the varied details also keeping the track of the history of the meetings.

Meetings A Meetings app where the user is presented with the number of meetings created , join any them , edit the varied details also keeping the tra

iOS App that allows a pilot to check drone photo collection after a mapping mission for any issues
iOS App that allows a pilot to check drone photo collection after a mapping mission for any issues

DronePhotoChecker iOS App that allows a pilot to check drone photo collection after a mapping mission for any issues. Features: Connects to DJI drone

SwiftUIWordpressClient - An iOS application for any WordPress website
SwiftUIWordpressClient - An iOS application for any WordPress website

SwiftUIWordpressClient SwiftUIWordpressClient is an iOS application for any Word

This is a sample app to create a photo selection classifier using CreateML on an iOS Device.
This is a sample app to create a photo selection classifier using CreateML on an iOS Device.

PhotoSelectionClassifier This is a sample app to create a photo selection classifier using CreateML on an iOS Device. Demo In the demo video below, we

PreviewDevice - library with elegant syntax for Preview Device in SwiftUI
PreviewDevice - library with elegant syntax for Preview Device in SwiftUI

PreviewDevice Requirements Xcode 13.x iOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+ Usage Example: import PreviewDevice struc

A SwiftUI app that reads iOS/watchOS/tvOS device model information from Xcode you select.
A SwiftUI app that reads iOS/watchOS/tvOS device model information from Xcode you select.

iVariant A SwiftUI app that reads iOS/watchOS/tvOS device model information from Xcode you select. Preview License iVariant is licensed under MIT. Cop

In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.
In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.

TodoList In this application used the concepts from the beginner level project of SwiftUI_Evolve_1 The following concepts covered in this mini app Swi

An iOS app that visually clones Spotify's app and consumes the official Spotify's Web API to show(and play) songs, podcasts, artists and more.
An iOS app that visually clones Spotify's app and consumes the official Spotify's Web API to show(and play) songs, podcasts, artists and more.

SpotifyClone An iOS app that visually clones Spotify's app and consumes the official Spotify's Web API to show(and play) songs, podcasts, artists and

Comments
  • feature: user custom debug menu

    feature: user custom debug menu

    image
    SimulatorView(debugMenu: {
        Menu {
            Button("Show Alert") { ... }
        } label: {
            Label("Debug", systemImage: "ant.circle")
        }
    }) { ... }
    
    opened by YusukeHosonuma 0
  • "SwiftUI-Simulator"の上にViewが表示される

    sheetやfullScreenCoverの様な上に被るViewあるとシュミレーターが機能しない

    import SwiftUI
    
    struct ContentView: View {
        @State var ShowSheet: Bool = false
        @State var ShowFullScreenCover: Bool = false
        var body: some View {
            NavigationView {
                VStack(spacing: 50) {
                    // ✅ シュミレーターの内に表示される
                    NavigationLink("NavigationLink") {
                        SecondView()
                    }
    
                    // ❌ シュミレーターの上に表示される
                    Button(action: {
                        ShowSheet = true
                    }) {
                        Text("Sheet")
                    }
    
                    // ❌ シュミレーターの上に表示される
                    Button(action: {
                        ShowFullScreenCover = true
                    }) {
                        Text("FullScreenCover")
                    }
                }
            }
            .sheet(isPresented: $ShowSheet) {
                SecondView()
            }
            .fullScreenCover(isPresented: $ShowFullScreenCover) {
                SecondView()
            }
        }
    }
    
    struct SecondView: View {
        @Environment(\.dismiss) var dismiss
        var body: some View {
            Button(action: {
                dismiss()
            }) {
                Text("閉じる")
            }
        }
    }
    

    https://user-images.githubusercontent.com/84154073/164407279-771e4dd9-c328-48fb-886e-26a3134b79ad.mp4

    opened by SNQ-2001 1
Releases(1.6.0)
  • 1.6.0(May 5, 2022)

    New feature of UserDefaults browser

    • Support AppGroup (UserDefaults(suiteName: "xxx"))
    • Support editing and export data.
    image

    Full Changelog: https://github.com/YusukeHosonuma/SwiftUI-Simulator/compare/1.5.0...1.6.0

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(May 1, 2022)

  • 1.4.0(Apr 28, 2022)

  • 1.3.0(Apr 21, 2022)

    What's Changed

    • Feature: customize color of simulator components by @YusukeHosonuma in https://github.com/YusukeHosonuma/SwiftUI-Simulator/pull/36
    • Feature: reset to defaults by @YusukeHosonuma in https://github.com/YusukeHosonuma/SwiftUI-Simulator/pull/32
    • Feature: setting view by @YusukeHosonuma in https://github.com/YusukeHosonuma/SwiftUI-Simulator/pull/31
    • Bugfix: accent color is not working in dark-mode by @YusukeHosonuma in https://github.com/YusukeHosonuma/SwiftUI-Simulator/pull/33
    • Improvement: default value of device for Locale and Calendar by @YusukeHosonuma in https://github.com/YusukeHosonuma/SwiftUI-Simulator/pull/35

    Full Changelog: https://github.com/YusukeHosonuma/SwiftUI-Simulator/compare/1.2.0...1.3.0

    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Apr 18, 2022)

  • 1.1.0(Apr 17, 2022)

Owner
Yusuke Hosonuma
Yusuke Hosonuma
A realistic reflective shimmer to SwiftUI Views that uses device orientation. Position any View relative to device orientation to appear as if through a window or reflected by the screen.

A 3d rotation effect that uses Core Motion to allow SwiftUI views to appear projected in a specific direction and distance relative to the device in r

Ryan Lintott 235 Dec 30, 2022
An iPhone Simulator "Wrapper" for SwiftUI Apps on macOS

SwiftUIPhone Run a SwiftUI app (or any SwiftUI view) in an iPhone Simulator "wrapper", directly on macOS! To be clear, this is not an iPhone Simulator

Justin Kaufman 7 May 20, 2022
DiceChallenge - Hacking with SwiftUI Challenge - Dice simulator

Some Dices Hacking with SwiftUI challenge turned into a real app available at th

Alex Oliveira 0 Jan 11, 2022
Reusable & customizable SwiftUI settings sheet as a Swift package

PackAPrefPane Reusable & customizable SwiftUI settings sheet as a Swift package Features Swift package 100% Swift 99% SwiftUI Simple design Lightweigh

W1W1-M 9 Nov 6, 2022
Mahmoud-Abdelwahab 5 Nov 23, 2022
App Everything in one place (news, weather, stocks and much more)

Dashy Everything in one place (news, weather, stocks and much more) I tried to follow MVVM Pattern, Used Decodable And URLSession instead of thrid-par

Aayush 3 Nov 24, 2021
App which lets two people share their social media details by simply putting one phone on top of the other ("tapping"). Currently in development by Nikita Mounier.

Tap It Tap It enables two people to seamlessly share their social media information (e.g. Instagram, Snapchat, phone number) by simply placing one scr

Nikita Mounier 24 Oct 21, 2022
Weather-app - Created a simple weather app on Xcode using SwiftUI, only shows one location

weather-app Created a simple weather app on Xcode using SwiftUI, only shows one

Rahul Kadiyala 1 Feb 11, 2022
iOS app that allows you to search for any comic character and save your favorites in a list.

iOS App: My Comics Swift exercise ¡Hola mundo! In my Swift learning journey my mentor and I decided to do an app using the Comic Vine API. This API gi

Silvia España Gil 5 Dec 13, 2022
iOS On-Device Game Cheat Creation/Sharing Platform and Software

CheatManager CheatManager is a mobile platform, used for installation/distribution/creation of mobile game cheats/hacks. This platform is completely d

Project Manticore 49 Jan 2, 2023