Unable to update Realm Swift via cocoa pods

I’m unable to update RealmSwift framework via cocoa pods.

This works fine:

target 'swiftuitest' do
  # Comment the next line if you don't want to use dynamic frameworks

  # Pods for swiftuitest
  pod 'RealmSwift', '~> 5.2.0'


But going any higher than 5.2.0 or just removing the version (so it’ll update straight to the latest version) it’ll fail with error:

pod install
Analyzing dependencies
Downloading dependencies
Installing Realm 10.1.4 (was 5.2.0)
[!] /bin/bash -c 
set -e
sh build.sh cocoapods-setup

Downloading dependency: sync 10.1.3 from https://static.realm.io/downloads/sync/realm-sync-xcframework-10.1.3.tar.xz
ld: library not found for -lz
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

This is happening on fresh, hello world SwiftUI project (the same issue is on my real UIKit project so it’s not related to SwiftUI).

I’m using cocoa pods 1.10.0 (latest), I even tried reinstalling it. Any other pod install without any issue. I’ve also update ruby and openssl to the latest version. I tried rebooting my mac and calling the same method on a different network and result it the same. Removing Podfile.lock and Pods directory don’t help either.