libgit2 / objective-git

Objective-C bindings to libgit2
MIT License
1.16k stars 280 forks source link

MacOS error: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib #699

Open marcuswestin opened 4 years ago

marcuswestin commented 4 years ago

Hi, I would love help getting ObjectiveGit running on macOS.

I'm on Catalina 10.15.1 and Xcode Version 11.1.

I'm building using Carthage, following all the steps. iOS seems to work fine. MacOS does not:

dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /Users/.../Build/Products/Debug/.../Contents/Frameworks/ObjectiveGit.framework/Versions/A/ObjectiveGit
  Reason: image not found

Looking in /usr/local/opt/openssl/lib/ I see libcrypto.1.1.dylib, but not libcrypto.1.0.0.dylib.

(If relevant at all, I was able to get https://www.github.com/SwiftGit2/SwiftGit2 to run on macOS)

Any pointers would be super, super appreciated!

Thanks

marcuswestin commented 4 years ago

I finally got ObjectiveGit working on macOS 10.15.1 Catalina and Xcode 11! Here's a quick recap of the problems I ran into and the eventual solution - hopefully useful for anyone running into similar issues dow: the road.

Problem & Solution:

First I tried installing the latest release (0.14.2) with carthage, using Cartfile entry:

github "libgit2/objective-git"

But then macOS fails with error:

dyld:
  Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: ...
  Reason: image not found

After many different attempts, I finally managed to get everything working by forking the repository, creating a branch off of the latest release, and using that as my Cartfile dependency:

github.com "marcuswestin/objective-git" "0.14.2-fork-for-catalina-xcode11"

I had to jump through a few additional hoops to get everything finally working, not necessarily related to this library, but worth noting:

This makes it work! Why? I'm not certain, but my guess is that because the latest libgit2/objective-git release has binary builds, Carthage downloads and uses those, but they don't work with Catalina. However, when using the branch build, Carthage has to build from source - and then it works!

noahlt commented 4 years ago

I faced the exact same problem (Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib) and solved it by building Objective Git like so:

carthage update --platform macOS --no-use-binaries

This was just using @marcuswestin's intuition that the solution was to force Carthage to build from source, and finding the --no-use-binaries flag to do that explicitly.