kabiroberai / node-swift

Create Node modules in Swift
MIT License
492 stars 16 forks source link

Cannot build project due to internal build failure in register.m #41

Open balazserdeszlogmein opened 1 month ago

balazserdeszlogmein commented 1 month ago

Using

builds fail with the following error:

[...]/.build/checkouts/node-swift/Sources/NodeModuleSupport/register.m:3:1: error: declaration of 'int32_t' must be imported from module 'DarwinFoundation.stdint.int32_t' before it is required
    3 | NAPI_MODULE_INIT() {
      | ^
[...]/.build/checkouts/node-swift/Sources/CNodeAPI/vendored/node_api.h:69:22: note: expanded from macro 'NAPI_MODULE_INIT'
   69 |   NAPI_MODULE_EXPORT int32_t NODE_API_MODULE_GET_API_VERSION() {               \
      |                      ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/sys/_types/_int32_t.h:30:33: note: declaration here is not visible
   30 | typedef int                     int32_t;
      |                                 ^
1 error generated.
[0/7] Write swift-version--58304C5D6DBC2206.txt
[...]/node_modules/node-swift/lib/builder.js:259
                throw new Error(`swift build exited with status ${result.status}`);
                      ^

Error: swift build exited with status 1
    at Object.<anonymous> ([...]/node_modules/node-swift/lib/builder.js:259:23)
    at Generator.next (<anonymous>)
    at [...]/node_modules/node-swift/lib/builder.js:8:71
    at new Promise (<anonymous>)
    at __awaiter ([...]/node_modules/node-swift/lib/builder.js:4:12)
    at Object.build ([...]/node_modules/node-swift/lib/builder.js:60:12)
    at [...]/node_modules/node-swift/lib/cli.js:61:23
    at Generator.next (<anonymous>)
    at [...]/node_modules/node-swift/lib/cli.js:32:71
    at new Promise (<anonymous>)

Activating Xcode 15.4 over Xcode 16.0 the build succeeds.

balazserdeszlogmein commented 1 month ago

Btw this is a pretty good package/project, really kudos to you. If you created a DocC page accompanying it, it would soar IMO. It's a steep start right now, because one needs to look at what types are directly translated and how (and with what methods) - e.g. finding out Data has auto-translations via TypedArrays is not gonna be straightforward for beginners.

kabiroberai commented 1 month ago

👋 the fact that it says the error is on line 3 of register.m makes me think you're on an old checkout (line 3 was previously NAPI_MODULE_INIT but is now a blank line). This exact issue should have been fixed by #34 which was included in v1.3.0. Could you please make sure you're on that version? You might want to nuke your DerivedData/Swift Package cache to be certain.

And thank you for the kind words! I agree regarding documentation, just been hard-pressed for time recently. Definitely on the roadmap.