根据官方文档,加入realm.framework静态库到工程之后,编译,有可能提示如下错误:
Undefined symbols for architecture arm64:
"_inflate", referenced from:
realm::util::compression::inflate(char const*, unsigned long, char*, unsigned long) in Realm(compression-iphoneos.o)
"_deflate", referenced from:
realm::util::compression::deflate(char const*, unsigned long, char*, unsigned long, unsigned long&, int) in Realm(compression-iphoneos.o)
"_inflateEnd", referenced from:
realm::util::compression::inflate(char const*, unsigned long, char*, unsigned long) in Realm(compression-iphoneos.o)
"_deflateInit_", referenced from:
realm::util::compression::deflate_bound(char const*, unsigned long, unsigned long&, int) in Realm(compression-iphoneos.o)
realm::util::compression::deflate(char const*, unsigned long, char*, unsigned long, unsigned long&, int) in Realm(compression-iphoneos.o)
"_deflateBound", referenced from:
realm::util::compression::deflate_bound(char const*, unsigned long, unsigned long&, int) in Realm(compression-iphoneos.o)
realm::util::compression::deflate(char const*, unsigned long, char*, unsigned long, unsigned long&, int) in Realm(compression-iphoneos.o)
"_inflateInit_", referenced from:
realm::util::compression::inflate(char const*, unsigned long, char*, unsigned long) in Realm(compression-iphoneos.o)
"_deflateEnd", referenced from:
realm::util::compression::deflate_bound(char const*, unsigned long, unsigned long&, int) in Realm(compression-iphoneos.o)
realm::util::compression::deflate(char const*, unsigned long, char*, unsigned long, unsigned long&, int) in Realm(compression-iphoneos.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
那么加入库"libz.tbd"即可解决问题,官方文档并没有提示要加这个库。