fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.14k stars 285 forks source link

Error (Xcode): duplicated symbols `_wrapped_os_log_error` #2271

Closed patmuk closed 2 weeks ago

patmuk commented 2 weeks ago

Describe the bug

after code generation, when I run flutter run I get this error:

Launching lib/main.dart on iPhone 15 in debug mode...
Running pod install...                                             660ms
Running Xcode build...                                                  
Xcode build done.                                           14.2s
Failed to build iOS app
Error (Xcode): 7 duplicate symbols

Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)

Could not build the application for the simulator.
Error launching application on iPhone 15.

Steps to reproduce

flutter pub get
flutter_rust_bridge_codegen generate --config-file flutter_rust_bridge.yaml
dart run build_runner build
flutter run

I did this on my own project, not the frb sample, but after upgrading to the latest frb version. Any idea what might be the issue? Or how I can debug this?

Logs

In Xcode I see

duplicate symbol '_wrapped_os_log_error' in:
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][191](wrapper.o)
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][167](wrapper.o)
duplicate symbol '_wrapped_os_log_default' in:
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][191](wrapper.o)
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][167](wrapper.o)
duplicate symbol '_wrapped_os_log_fault' in:
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][191](wrapper.o)
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][167](wrapper.o)
duplicate symbol '_wrapped_os_log_info' in:
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][191](wrapper.o)
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][167](wrapper.o)
duplicate symbol '_wrapped_os_log_debug' in:
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][191](wrapper.o)
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][167](wrapper.o)
duplicate symbol '_wrapped_os_log_with_type' in:
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][191](wrapper.o)
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][167](wrapper.o)
duplicate symbol '_wrapped_get_default_log' in:
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][191](wrapper.o)
    /Users/patmuk/Library/Developer/Xcode/DerivedData/Runner-blmuhmhlinujwtcnoyumofmstbip/Build/Products/Debug-iphonesimulator/rust_builder/libapp_core.a[x86_64][167](wrapper.o)
ld: 7 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)

### Expected behavior

_No response_

### Generated binding code

_No response_

### OS

_No response_

### Version of `flutter_rust_bridge_codegen`

2.3.0.

### Flutter info

```shell
flutter doctor -v
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
    • Flutter version 3.24.0 on channel stable at
      /Users/patmuk/code/own/sherry/examples/flutter-rust-bridge_crux_style/.toolchain/flutter-loc
      al/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 80c2e84975 (5 weeks ago), 2024-07-30 23:06:49 +0700
    • Engine revision b8800d88be
    • Dart version 3.5.0
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /nix/store/hdnrd74pv4i0yaxv10jbx8a6yjylaaa7-android-sdk-env/share/android-sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /nix/store/hdnrd74pv4i0yaxv10jbx8a6yjylaaa7-android-sdk-env/share/android-sdk
    • ANDROID_SDK_ROOT =
      /nix/store/hdnrd74pv4i0yaxv10jbx8a6yjylaaa7-android-sdk-env/share/android-sdk
    • Java binary at: /nix/store/74amabksc4za40sgcx9vaq0mph4jnsxm-zulu-ca-jdk-17.0.10/bin/java
    • Java version OpenJDK Runtime Environment Zulu17.48+15-CA (build 17.0.10+7-LTS)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode-15.4.0.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).

[✓] VS Code (version 1.79.2)
    • VS Code at /Users/patmuk/Library/Mobile Documents/com~apple~CloudDocs/Desktop/Visual Studio
      Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • iPhone 15 (mobile)              • B55F6ACA-3F12-4499-B302-B9FC98C36726 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   •
      macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         •
      macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript •
      Google Chrome 127.0.6533.89

[✓] Network resources
    • All expected network resources are available.

Version of clang++

15.0.0

Additional context

No response

fzyzcjy commented 2 weeks ago

First guess: Is it possible because of https://github.com/fzyzcjy/flutter_rust_bridge/pull/2245?

You can disable log feature to avoid compiling that log lib and keep it the old way.

But I wonder why it will have "duplicated symbols"... One wild guess: is it possible you setup your logging, and thus this other logging somehow conflicts?

patmuk commented 2 weeks ago

Oh, that is a very good tip! Indeed, I set up my own logging, and I saw the logging support in the changelog - but did not connect the dots.

I will change that later and reply to this issue!

patmuk commented 2 weeks ago

Yes, that was the issue! I created an instance of the OsLogger - and had the crate specified in the cargo.toml. I assume that this lib got added twice, resulting in duplicated symbols.

Code removed, problem solved. Thanks!

fzyzcjy commented 2 weeks ago

You are welcome!

github-actions[bot] commented 1 day ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.