Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to make a plug-in package that is not uploaded to the pub and referenced by multiple local flutter projects? #1029

Closed
cyz1901 opened this issue Feb 6, 2023 · 7 comments

Comments

@cyz1901
Copy link

cyz1901 commented Feb 6, 2023

The tutorial seems to need to upload something to github or gitlab, but I use bitbucket....
https://cjycode.com/flutter_rust_bridge/library.html

@welcome
Copy link

welcome bot commented Feb 6, 2023

Hi! Thanks for opening your first issue here! 😄

@cyz1901
Copy link
Author

cyz1901 commented Feb 6, 2023

And whether the tutorial needs to be updated
I faced some confusing places
截屏2023-02-06 14 31 46
截屏2023-02-06 14 32 02

@cyz1901
Copy link
Author

cyz1901 commented Feb 6, 2023

How should Cargo.toml content be generated?

and we will flutter pub add library_name after our plugin library upload to pub or github?

@cyz1901
Copy link
Author

cyz1901 commented Feb 6, 2023

And i flow guide try to add flutter_rust_bridge to project
https://cjycode.com/flutter_rust_bridge/integrate.html

found

Error (Xcode): Undefined symbol: _drop_dart_object

Error (Xcode): Undefined symbol: _free_WireSyncReturn

Error (Xcode): Undefined symbol: _get_dart_object

Error (Xcode): Undefined symbol: _new_dart_opaque

Error (Xcode): Undefined symbol: _store_dart_post_cobject

Error (Xcode): Undefined symbol: _wire_greet

cargo.toml

[package]
name = "rust-native"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
flutter_rust_bridge = "1"

[lib]
crate-type = ["staticlib", "cdylib", "lib"]

apple m1

Flutter 3.3.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision eb6d86ee27 (4 months ago) • 2022-10-04 22:31:45 -0700
Engine • revision c08d7d5efc
Tools • Dart 2.18.2 • DevTools 2.15.0

@fzyzcjy
Copy link
Owner

fzyzcjy commented Feb 6, 2023

IMHO it should not be hard to migrate from github/gitlab to bitbucket

also cc @GregoryConrad who implemented the helpful doc in #899

@GregoryConrad
Copy link
Contributor

Hi @cyz1901 !

Bitbucket is not a problem, although the CI workflows given in the docs will not work (because they are for GitHub actions) and you would have to adapt them to Bitbucket's equivalent. Also, you will need to set up the platform-specific build processes (i.e., the 3 CMakes and 2 podspecs) to point to the native libraries released on Bitbucket and not GitHub (unless you are only building the library locally and never publishing, in which case you wouldn't have to worry about that).

There are two Cargo.tomls. One is at your repository root and defines the Rust workspace to help IDEs and define the build output location. The second Cargo.toml is in /packages/library_name/native to define your project's output types, dependencies, etc. It looks like you made your own Cargo.toml, which is incorrect. Both Cargo.tomls are generated for you in the script here: https://cjycode.com/flutter_rust_bridge/library/dart_only.html

The export dart line is to export your Dart-only base library in your flutter wrapper. This is typically not a best practice in general, but is required for creating a library here because the flutter wrapper bundles the platform-specific binaries which require an exact version of the Dart-only base. The Dart-only package cannot export the assets (which it would be nice to have) until the Native Assets feature is released sometime in the future with Dart 3.

and we will flutter pub add library_name after our plugin library upload to pub or github?

That command will only work if you publish library_name to pub. Otherwise, it will error out. Also, you would need to add flutter_library_name for flutter, and library_name for dart-only.

Your missing Xcode symbols are one (or both) of two things:

  1. You did not follow https://cjycode.com/flutter_rust_bridge/library/platform_setup/ios_and_macos.html correctly, and perhaps missed the Swift file
  2. You did not populate /ios/Frameworks/ or /macos/Frameworks/ with the XCFramework built from build-apple.sh with the correct name (something like library_name-v0.0.0.xcframework.zip)

Try to take some time to really read through the guide and understand it. Based on the errors you are having (with Xcode and the Cargo.tomls) it looks like you missed pieces here and there. Creating a native library (especially Rust) with the state of Dart as it is now is very tricky to do correctly and the guide tries to help you as much as possible, but it takes some time to digest all the material. I really wish it was easier, and it will be once native assets are released, but in the meantime it is a bit painful.

If you really want to get into it right away with an example, take a look at mimir. Mimir is my library that I based that section of the docs around.

@cyz1901 cyz1901 closed this as completed Feb 9, 2023
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants