# Create SwiftUI App outside of Xcode Project

**URL:** <https://forums.swift.org/t/create-swiftui-app-outside-of-xcode-project/62019>\
**Category:** Using Swift\
**Tags:** packagemanager, swiftui\
**Created:** [December 13, 2022, 8:05pm UTC](https://forums.swift.org/t/create-swiftui-app-outside-of-xcode-project/62019 "2022-12-13T20:05:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![johnfairh](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/johnfairh/32/760_2.png) [@johnfairh](https://forums.swift.org/u/johnfairh)\
**Post date:** [December 13, 2022, 9:01pm UTC](https://forums.swift.org/t/create-swiftui-app-outside-of-xcode-project/62019/2 "2022-12-13T21:01:00Z")

</div>

I have this clip saved away from somewhere to make it work:

```swift
struct MyApp: App {
    init() {
        // Some stuff to make the app work properly when `swift run`.
        // We are before `NSApplicationMain` here so queue it.
        DispatchQueue.main.async {
            NSApp.setActivationPolicy(.regular)
            NSApp.activate(ignoringOtherApps: true)
            NSApp.windows.first?.makeKeyAndOrderFront(nil)
        }
    }
...

```

---

_[View the full topic](https://forums.swift.org/t/create-swiftui-app-outside-of-xcode-project/62019)._
