MacOS error: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
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
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:
- ObjectiveGit.framework could not be found
- Drag framework to the {Project file} > {Target} > Build Phases -> Embedded Binaries
- Create an Objective-C bridging header with File > New File... > macOS: Objective-C File> {Any name, Empty File}
- When prompted to configure an Objective-C bridging header: Create Bridging Header
- Import framework:
import ObjectiveGitin any swift file you want to use it in, or#import <ObjectiveGit/ObjectiveGit.h>in your...-Bridging-Header.hfile for access from any swift file in your project.
- Fix
Curl: could not resolve <domain>error- In {Project file} > {Target} > Signing & Capabilities > App Sandbox > Network >
- Check: Outgoing Connections (Client)
- Fix framework CodeSign errors
- Clean Project (Product > Clean Build Folder, or Shift+Cmd+K)
- In {Project file} > {Target} > Signing & Capabilities > Hardened Runtime >
- Check: Disable Library Validation
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!
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.