Following Hello World tutorial on macos fails #8

Closed
opened 2024-03-26 15:29:50 +01:00 by jrwren · 5 comments
jrwren commented 2024-03-26 15:29:50 +01:00 (Migrated from github.com)

Describe the bug

Following https://github.com/AparokshaUI/adwaita-swift/blob/main/user-manual/Basics/HelloWorld.md on macos 14.4 and get import error

To Reproduce

Do the tutorial on macos 14.4

See it fail on swift run step.

Expected behavior

What the tutorial says.

Additional context

$ swift run
Fetching https://github.com/AparokshaUI/Adwaita
Fetched https://github.com/AparokshaUI/Adwaita from cache (1.53s)
Computing version for https://github.com/AparokshaUI/Adwaita
Computed https://github.com/AparokshaUI/Adwaita at 0.2.4 (0.26s)
Fetching https://github.com/david-swift/LevenshteinTransformations
Fetched https://github.com/david-swift/LevenshteinTransformations from cache (0.36s)
Computing version for https://github.com/david-swift/LevenshteinTransformations
Computed https://github.com/david-swift/LevenshteinTransformations at 0.1.2 (0.27s)
Creating working copy for https://github.com/david-swift/LevenshteinTransformations
Working copy of https://github.com/david-swift/LevenshteinTransformations resolved at 0.1.2
Creating working copy for https://github.com/AparokshaUI/Adwaita
Working copy of https://github.com/AparokshaUI/Adwaita resolved at 0.2.4
warning: 'helloworld': dependency 'adwaita' is not used by any target
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/module.modulemap:2:12: error: header '/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h' not found
    header "/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h"
           ^
/Users/jrwren/src/HelloWorld/Sources/main.swift:1:8: error: could not build Objective-C module 'Adwaita'
import Adwaita
       ^
/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/module.modulemap:2:12: error: header '/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h' not found
    header "/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h"
           ^
/Users/jrwren/src/HelloWorld/Sources/main.swift:1:8: error: could not build Objective-C module 'Adwaita'
import Adwaita
       ^
error: fatalError
### Describe the bug Following https://github.com/AparokshaUI/adwaita-swift/blob/main/user-manual/Basics/HelloWorld.md on macos 14.4 and get import error ### To Reproduce Do the tutorial on macos 14.4 See it fail on swift run step. ### Expected behavior What the tutorial says. ### Additional context ``` $ swift run Fetching https://github.com/AparokshaUI/Adwaita Fetched https://github.com/AparokshaUI/Adwaita from cache (1.53s) Computing version for https://github.com/AparokshaUI/Adwaita Computed https://github.com/AparokshaUI/Adwaita at 0.2.4 (0.26s) Fetching https://github.com/david-swift/LevenshteinTransformations Fetched https://github.com/david-swift/LevenshteinTransformations from cache (0.36s) Computing version for https://github.com/david-swift/LevenshteinTransformations Computed https://github.com/david-swift/LevenshteinTransformations at 0.1.2 (0.27s) Creating working copy for https://github.com/david-swift/LevenshteinTransformations Working copy of https://github.com/david-swift/LevenshteinTransformations resolved at 0.1.2 Creating working copy for https://github.com/AparokshaUI/Adwaita Working copy of https://github.com/AparokshaUI/Adwaita resolved at 0.2.4 warning: 'helloworld': dependency 'adwaita' is not used by any target Building for debugging... error: emit-module command failed with exit code 1 (use -v to see invocation) /Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/module.modulemap:2:12: error: header '/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h' not found header "/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h" ^ /Users/jrwren/src/HelloWorld/Sources/main.swift:1:8: error: could not build Objective-C module 'Adwaita' import Adwaita ^ /Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/module.modulemap:2:12: error: header '/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h' not found header "/Users/jrwren/src/HelloWorld/.build/arm64-apple-macosx/debug/Adwaita.build/Adwaita-Swift.h" ^ /Users/jrwren/src/HelloWorld/Sources/main.swift:1:8: error: could not build Objective-C module 'Adwaita' import Adwaita ^ error: fatalError ```
david-swift commented 2024-03-26 17:40:01 +01:00 (Migrated from github.com)

Sorry, there is a step missing in that tutorial.

You have to add the dependency to the HelloWorld target as well:

targets: [
    // Targets are the basic building blocks of a package, defining a module or a test suite.
    // Targets can depend on other targets in this package and products from dependencies.
    .executableTarget(
        name: "HelloWorld",
        dependencies: [.product(name: "Adwaita", package: "Adwaita")]
    ),
]

Thank you for reporting this! Does it work after adding the dependency to the target?

Sorry, there is a step missing in that tutorial. You have to add the dependency to the HelloWorld target as well: ```swift targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .executableTarget( name: "HelloWorld", dependencies: [.product(name: "Adwaita", package: "Adwaita")] ), ] ``` Thank you for reporting this! Does it work after adding the dependency to the target?
jrwren commented 2024-03-26 17:42:42 +01:00 (Migrated from github.com)

It goes further and gives a different error:

error: the executable 'HelloWorld' requires macos 10.13, but depends on the product 'Adwaita' which requires macos 10.15; consider changing the executable 'HelloWorld' to require macos 10.15 or later, or the product 'Adwaita' to require macos 10.13 or earlier.
error: the executable 'HelloWorld' requires macos 10.13, but depends on the product 'Adwaita' which requires macos 10.15; consider changing the executable 'HelloWorld' to require macos 10.15 or later, or the product 'Adwaita' to require macos 10.13 or earlier.

Thanks for the help. I'll send a PR for the tutorial if that is acceptable.

It goes further and gives a different error: ``` error: the executable 'HelloWorld' requires macos 10.13, but depends on the product 'Adwaita' which requires macos 10.15; consider changing the executable 'HelloWorld' to require macos 10.15 or later, or the product 'Adwaita' to require macos 10.13 or earlier. error: the executable 'HelloWorld' requires macos 10.13, but depends on the product 'Adwaita' which requires macos 10.15; consider changing the executable 'HelloWorld' to require macos 10.15 or later, or the product 'Adwaita' to require macos 10.13 or earlier. ``` Thanks for the help. I'll send a PR for the tutorial if that is acceptable.
jrwren commented 2024-03-26 17:46:20 +01:00 (Migrated from github.com)

I added

       platforms: [
        .macOS(.v10_15)
    ],

and it builds and runs. THANKS!

I added ``` platforms: [ .macOS(.v10_15) ], ``` and it builds and runs. THANKS!
david-swift commented 2024-03-27 06:32:00 +01:00 (Migrated from github.com)

I've followed the tutorial on macOS myself now and got the error 'main' attribute cannot be used in a module that contains top-level code. As soon as I renamed the main.swift to HelloWorld.swift the error disappeared. I'll have to add this to the tutorial if there's no more elegant solution.

I'll add the macOS version specification to the tutorial as well.

I've followed the tutorial on macOS myself now and got the error `'main' attribute cannot be used in a module that contains top-level code`. As soon as I renamed the `main.swift` to `HelloWorld.swift` the error disappeared. I'll have to add this to the tutorial if there's no more elegant solution. I'll add the macOS version specification to the tutorial as well.
david-swift commented 2024-03-29 11:30:56 +01:00 (Migrated from github.com)

I added the file name thing as well in 409dfb6. Thanks for reporting!

I added the file name thing as well in 409dfb6. Thanks for reporting!
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#8
No description provided.