Not able to run the app #72

Closed
opened 2025-09-30 21:02:34 +02:00 by jj11 · 3 comments

Describe the bug

Throws an error not sure why?

 swift build
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/home/joker/Desktop/Bare-Swift/Sources/main.swift:4:1: error: 'main' attribute cannot be used in a module that contains top-level code
 1 | import Adwaita
   | |- note: top-level code defined in this source file
   | `- note: pass '-parse-as-library' to compiler invocation if this is intentional
 2 |
 3 |
 4 | @main
   | `- error: 'main' attribute cannot be used in a module that contains top-level code
 5 | struct BareSwiftApp: App {
 6 |
/home/joker/Desktop/Bare-Swift/Sources/main.swift:4:1: error: 'main' attribute cannot be used in a module that contains top-level code
 1 | import Adwaita
   | |- note: top-level code defined in this source file
   | `- note: pass '-parse-as-library' to compiler invocation if this is intentional
 2 |
 3 |
 4 | @main
   | `- error: 'main' attribute cannot be used in a module that contains top-level code
 5 | struct BareSwiftApp: App {
 6 |

To Reproduce

  1. Create swift package
  2. Add the simple hello word text and build it

Expected behavior

Should build without error?

Additional context

No response

### Describe the bug Throws an error not sure why? ``` swift build Building for debugging... error: emit-module command failed with exit code 1 (use -v to see invocation) /home/joker/Desktop/Bare-Swift/Sources/main.swift:4:1: error: 'main' attribute cannot be used in a module that contains top-level code 1 | import Adwaita | |- note: top-level code defined in this source file | `- note: pass '-parse-as-library' to compiler invocation if this is intentional 2 | 3 | 4 | @main | `- error: 'main' attribute cannot be used in a module that contains top-level code 5 | struct BareSwiftApp: App { 6 | /home/joker/Desktop/Bare-Swift/Sources/main.swift:4:1: error: 'main' attribute cannot be used in a module that contains top-level code 1 | import Adwaita | |- note: top-level code defined in this source file | `- note: pass '-parse-as-library' to compiler invocation if this is intentional 2 | 3 | 4 | @main | `- error: 'main' attribute cannot be used in a module that contains top-level code 5 | struct BareSwiftApp: App { 6 | ``` ### To Reproduce 1. Create swift package 2. Add the simple hello word text and build it ### Expected behavior Should build without error? ### Additional context _No response_
jj11 added the
bug
label 2025-09-30 21:02:34 +02:00
Author
import Adwaita


@main
struct BareSwiftApp: App {

    let app = AdwaitaApp(id: "com.bare.swift")

    var scene: Scene {
        Window(id: "main") { window in
            Text("Hello World!!")

        }
        .defaultSize(width: 450, height: 300)
    }
}

``` import Adwaita @main struct BareSwiftApp: App { let app = AdwaitaApp(id: "com.bare.swift") var scene: Scene { Window(id: "main") { window in Text("Hello World!!") } .defaultSize(width: 450, height: 300) } } ```
Author

Am I missing anything?

Am I missing anything?
Author

No worries my bad, closing it!! found the fix

No worries my bad, closing it!! found the fix
jj11 closed this issue 2025-09-30 21:06:03 +02:00
Sign in to join this conversation.
No Milestone
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: aparoksha/adwaita-swift#72
No description provided.