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

Draft-work in progress need dicussion! #17

Open
wants to merge 10 commits into
base: ffi1.0
Choose a base branch
from

Conversation

richard457
Copy link
Contributor

  • A draft work in progress on how we can load libraries in the different platform in a more convenient way actually this is what I am trying to do here
    A new package to just hold the platform-specific code
    couchbaselite_dart_flutter_libs
    This package will have the code specific for each platform, the library such as .dll files and .so files will be downloaded as per the platform, the library will be downloaded from URL see example here LIBS I hope we can open discussion on how we can take this route and move forward.

@Rudiksz
Copy link
Owner

Rudiksz commented May 25, 2021

I've seen this approach, and there are some interesting tricks.

However I'm more inclined to just write a tool that does the download. Probably a dart script that reads the pubspec.yaml or pubspeck.lock to get the version number and download the libs and copy them where they have to be. Something you run after pub get. This way you don't need a whole package and a plugin just to download files, which could make CI maybe faster.

With that being said, if you can get it working and tested for all platforms I'm happy to add it as an option. Having multiple options on how to get the artifacts is never a bad thing.

A few things of the top of my head, to get the discussion started:

Windows: the trick with cmake is pretty neat, and while cmake makes me nervous because I'm not too familiar with it, it could be the easiest platform to manage.

Android: like objectbox, the .so libs would have to be included as aar artifact (from Maven, see https://search.maven.org/search?q=a:objectbox-android). This means that the 4 Android libs would have to be packaged and uploaded to maven. Last time I checked how to create a maven account and artifact I gave up after two days of reading the documentation and still not having any idea what I have to do to create an account. Unfortunately I don't have the time or energy to deal with it right now.

macos, ios: this I understand even less because I remember even less about ios. Last time I developed an app for ios was in the objective-c times (2014 maybe?), and I remember almost nothing about what pods are and how to create them.

linux: pfft, 😄 . I won't even bother building the library for linux. Even for a hobby project that's beyond my needs and interests.

@richard457
Copy link
Contributor Author

Good point here, was wondering is there a good reason of not using directly implementation "com.couchbase.lite:couchbase-lite-android:2.8.5" in gradle? I think it is somewhat doable, I guess still researching.

@richard457
Copy link
Contributor Author

@richard457
Copy link
Contributor Author

richard457 commented May 28, 2021

@Rudiksz seems like for windows we need .lib file too! see here https://stackoverflow.com/questions/913691/dll-and-lib-files-what-and-why/913744 I don't know if you can help on that.

@richard457
Copy link
Contributor Author

Any help on how to build the libraries is appreciated. as I fail every time I attempt to do it.

@richard457
Copy link
Contributor Author

Capture

@Rudiksz
Copy link
Owner

Rudiksz commented May 28, 2021

Good point here, was wondering is there a good reason of not using directly implementation "com.couchbase.lite:couchbase-lite-android:2.8.5" in gradle? I think it is somewhat doable, I guess still researching.

That is the Java library and you need to use Flutter's platform channels to use it. There is already a dart plugin for that, but it's Android and iOS only.

@Rudiksz
Copy link
Owner

Rudiksz commented May 28, 2021

@Rudiksz seems like for windows we need .lib file too! see here https://stackoverflow.com/questions/913691/dll-and-lib-files-what-and-why/913744 I don't know if you can help on that.

Dart can look up symbols and functions from the dll directly. That's what the bindings.dart file is for.

@Rudiksz
Copy link
Owner

Rudiksz commented May 28, 2021

Any help on how to build the libraries is appreciated. as I fail every time I attempt to do it.

You need to use this fork of the C library https://github.com/Rudiksz/couchbase-lite-C
There is some extra Dart specific implementation, and a few fixes I had to do make it build on my windows machine and a few for xcode.

I know nothing about building C code, and it took me a lot of trial and error to have it built on my windows machine. I use cmake that I downloaded myself, (instead of some version bundled with some other software) and did trial and error until I got it working.

@richard457
Copy link
Contributor Author

Any help on how to build the libraries is appreciated. as I fail every time I attempt to do it.

You need to use this fork of the C library https://github.com/Rudiksz/couchbase-lite-C
There is some extra Dart specific implementation, and a few fixes I had to do make it build on my windows machine and a few for xcode.

I know nothing about building C code, and it took me a lot of trial and error to have it built on my windows machine. I use cmake that I downloaded myself, (instead of some version bundled with some other software) and did trial and error until I got it working.

If the process can be documented would be a good starting point and for future development going forward.

@richard457
Copy link
Contributor Author

Any help on how to build the libraries is appreciated. as I fail every time I attempt to do it.

You need to use this fork of the C library https://github.com/Rudiksz/couchbase-lite-C
There is some extra Dart specific implementation, and a few fixes I had to do make it build on my windows machine and a few for xcode.
I know nothing about building C code, and it took me a lot of trial and error to have it built on my windows machine. I use cmake that I downloaded myself, (instead of some version bundled with some other software) and did trial and error until I got it working.

If the process can be documented would be a good starting point and for future development going forward.

and I think the right branch to look for is couchbase-lite-C (dart-ffi1)

@richard457
Copy link
Contributor Author

richard457 commented May 29, 2021

In my last attempt, CbliteFlutterLibsPluginRegisterWithRegistrar': identifier not found [E:\demos\couchbase_lite_dart\example_null\build\windows\runner\example_null.vcxproj] Exception: The build process failed. Googling around seems there might be an issue in .dll file

@Rudiksz
Copy link
Owner

Rudiksz commented May 29, 2021

The dll is not meant to be used as a plugin. In fact, the point of this package is to have a dart package independent of flutter and flutter's platform channels.

@richard457
Copy link
Contributor Author

I failed to continue my contribution as I can not build the C library on my local machine, I will be happy to be engaged in any conversation that can move this project forward, I strongly believe that if we want to make this project a success we need first to set up the build instructions in the wiki page of the C libraries. this will help anyone to jump in and develop on this project. @Rudiksz

@Rudiksz
Copy link
Owner

Rudiksz commented Jul 2, 2021

The C library is still in beta status and is hardly even supported by Couchbase. For every platform I had to do a number of fixes to make it build, and they still break at random times. I don't even remember most of them, and I suspect they are specific to my environments. Lately there were also a lot of breaking changes implemented in the upstream repo, and with the changes in dart ffi, the custom code I have to add is a lot less. That should make working with the C part less error-prone, but not yet.

Since both this library and dart's ffi are in beta and in constant evolution, I simply see no reason to spend time setting up a build pipeline yet. Specially seeing that there's not much interest for Couchbase in the Flutter community (Firebase being the de facto standard), and Couchbase does not seem to be interested in supporting Flutter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants