{"id":18027717,"url":"https://github.com/divadretlaw/windowscenereader","last_synced_at":"2026-03-03T15:33:10.013Z","repository":{"id":56715631,"uuid":"524002562","full_name":"divadretlaw/WindowSceneReader","owner":"divadretlaw","description":"📱 Access UIWindowScene in SwiftUI","archived":false,"fork":false,"pushed_at":"2024-09-03T17:21:29.000Z","size":35,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-09-19T18:34:54.201Z","etag":null,"topics":["swift","swiftui","uiwindow","uiwindowscenedelegate"],"latest_commit_sha":null,"homepage":"","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/divadretlaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-12T07:55:56.000Z","updated_at":"2024-09-03T17:21:34.000Z","dependencies_parsed_at":"2023-01-20T21:05:12.988Z","dependency_job_id":"7db75444-f24b-40d5-927e-a30b10b0474f","html_url":"https://github.com/divadretlaw/WindowSceneReader","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divadretlaw%2FWindowSceneReader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divadretlaw%2FWindowSceneReader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divadretlaw%2FWindowSceneReader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divadretlaw%2FWindowSceneReader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/divadretlaw","download_url":"https://codeload.github.com/divadretlaw/WindowSceneReader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222183038,"owners_count":16944872,"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":["swift","swiftui","uiwindow","uiwindowscenedelegate"],"created_at":"2024-10-30T08:12:20.907Z","updated_at":"2026-03-03T15:33:09.974Z","avatar_url":"https://github.com/divadretlaw.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WindowSceneReader\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdivadretlaw%2FWindowSceneReader%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/divadretlaw/WindowSceneReader)\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdivadretlaw%2FWindowSceneReader%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/divadretlaw/WindowSceneReader)\n\nAccess the current `UIWindowScene` and `UIWindow` from any SwiftUI view.\n\n## Usage\n\n### SwiftUI Lifecycle\n\nRead the current `UIWindowScene` with `WindowSceneReader`\n\n```swift\n@main\nstruct MyApp: App {\n    var body: some Scene {\n        WindowGroup {\n            WindowSceneReader { windowScene in\n                ContentView()\n            }\n        }\n    }\n}\n```\n\nalternatively, just add `windowScene()` if you only need the window scene on child views.\n\n```swift\n@main\nstruct MyApp: App {\n    var body: some Scene {\n        WindowGroup {\n            ContentView()\n                .windowScene()\n        }\n    }\n}\n```\n\nOn child views the `UIWindowScene` will be available in the `Environment`\n\n### UIKit Lifecycle\n\n```swift\nclass SceneDelegate: UIResponder, UIWindowSceneDelegate {\n    var window: UIWindow?\n    \n    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {\n        if let windowScene = scene as? UIWindowScene {\n            let rootView = ContentView()\n                .windowScene(windowScene)\n            \n            let window = UIWindow(windowScene: windowScene)\n            window.rootViewController = UIHostingController(rootView: rootView)\n            self.window = window\n            window.makeKeyAndVisible()\n    }\n}\n```\n\n## Environment\n\n```swift\n@Environment(\\.windowScene) var windowScene\n```\n\nThe `@Environment(\\.windowScene) var windowScene` defaults to the first connected `UIWindowScene` or `nil` if no `UIWindowScene` is connected.\n\n## License\n\nSee [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivadretlaw%2Fwindowscenereader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivadretlaw%2Fwindowscenereader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivadretlaw%2Fwindowscenereader/lists"}