hmlongco / Resolver

Swift Ultralight Dependency Injection / Service Locator framework
MIT License
2.14k stars 187 forks source link

Build failure on Ubuntu 20.04 with Resolver (Swift 5.3.3) #148

Closed kristofkalai closed 2 years ago

kristofkalai commented 2 years ago

Resolver.swift:342:56: error: cannot convert value of type 'Int' to expected argument type 'Int32' pthread_mutexattr_settype(&recursiveMutexAttr, PTHREAD_MUTEX_RECURSIVE) (Resolver 1.5.0)

The issue occurs on the default Heroku-20 stack. I have a working Swift-based (Vapor) backend application, and if I wanted to add Resolver as a Swift Package through SPM I get the error mentioned above, and thus the push / deploy fails. If I remove this dependency (and do nothing else), the error goes away (I don't use currently Resolver in my project, so I no more code need to be rewritten if I remove Resolver).

On my local machine (macOS 12+, Xcode 13+, Swift 5+) it works (even in GitHub Action CI it builds successfully). I check and the PTHREAD_MUTEX_RECURSIVE variable is indeed an Int32 on macOS, as it should be. I think it's type maybe differs based on the platform? I cannot check it on Ubuntu 20.04, but it maybe worth a try(?)

One more hint: the line that causes the error can be found in Resolver 1.5.0 and 1.4.0 too, but not in 1.3.0. I tried it out, and if I specify to use the 1.3.0 version, it works perfectly on every platform (local macOS, GitHub Actions, Heroku).

hmlongco commented 2 years ago

You might check out Factory. It doesn't use mutex's. https://github.com/hmlongco/Factory