# iOS: Failed to lookup symbol (dlsym(RTLD\_DEFAULT, \*\*\*)

Original: <https://lifelonglearn.ing/ios-failed-to-lookup-symbol>

Author: [奶爸](https://lifelonglearn.ing/users/3b04650c-8231-499b-8ef0-381fc4d7efb0)

Published: 2022-09-19T10:24:36Z

Updated: 2026-09-27T06:57:43Z

Version: 1

自从做了 Flutter 调用 rust 代码，xcode 的更新过程中遇到很多次这个问题了，记性不好，每次都是重新去解决，现在记录下来。

```plaintext
Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, store_dart_post_cobject): symbol not found)
```

## 静态链接库引入

首先确定你的静态链接库 `.a` 正确的引入到了项目中，你使用的 plugin 的 `.podspec` 文件中定义了静态链接库的位置

```plaintext
s.public_header_files = 'Classes**/*.h'
s.source_files = 'Classes/**/*'
s.static_framework = true
s.vendored_libraries = "**/*.a"
```

在你的 plugin 的 `.podspec` 文件或者 main app 的 **Build Settings** 中应当将静态链接库配置到 ​**ldflag**​，比如 `libmylib.a`就是`-lmylib`

```plaintext
'OTHER_LDFLAGS' => '-lmylib'
```

## 防止被编译器清理

在 Xcode 中打开项目，点开 Runner -> Build Settings 搜索 “Strip” 找到以下两项

* ​**Strip Style**​:：改为 **Non-Global Symbols** 去除非全局符号但保存外部符号。
* ​**Dead Code Striping**​：改为 **No** 防止 xcode 检测不到未在 Swift 代码中使用的 symbol。

参考链接：

* [https://docs.flutter.dev/development/platform-integration/ios/c-interop#stripping-ios-symbols](https://lifelonglearn.ing/r/go?url=aHR0cHM6Ly9kb2NzLmZsdXR0ZXIuZGV2L2RldmVsb3BtZW50L3BsYXRmb3JtLWludGVncmF0aW9uL2lvcy9jLWludGVyb3Ajc3RyaXBwaW5nLWlvcy1zeW1ib2xz)
* [https://github.com/fzyzcjy/flutter\_rust\_bridge/issues/250](https://lifelonglearn.ing/r/go?url=aHR0cHM6Ly9naXRodWIuY29tL2Z6eXpjankvZmx1dHRlcl9ydXN0X2JyaWRnZS9pc3N1ZXMvMjUw)

## Flutter Release 测试 （Archive）

```bash
flutter run -d iPhone --release
```
