Skip to content

Secured Setup

Efra Espada edited this page Jan 20, 2024 · 1 revision

Due to some limitations when adding the C++ file to the iOS and macOS runner targets and some other (recommended) modifications, you need to fork/clone the repository.

In order to increase the security, it is recommended to modify the code (how the keys are generated) in your repository before use it.

Make your repository private.

Prepare your private repository

Prepare your empty private repository. For example:

https://github.com/YOUR-USERNAME/stringcare

In your machine, duplicate this repo to yours:

// clone original
git clone --bare https://github.com/StringCare/stringcare.git
cd stringcare.git/
git push --mirror https://github.com/YOUR-USERNAME/stringcare.git

// remove old repository
cd ..
rm -rf stringcare

// clone yours
git clone https://github.com/YOUR-USERNAME/stringcare.git

Then include the dependency to the pubspec.yaml file.

dependencies:
    stringcare:
        git:
            url: https://github.com/YOUR-USERNAME/stringcare.git

Since Flutter 2, I noticed dangerous problems when indexing the project after adding the local dependency by path: ../whatever. That's why I recommend to implement the plugin by git: url: https://...

iOS and macOS setup

Add the C++ file to the Runner targets.

You can locate the stringcare.cpp file in your cloned private repository:

stringcare/ios/Classes/stringcare.cpp

If XCode ask for include the Runner-Bridging-Header.h file to the project, do it.

setup

Key setup

This is the default key used when no extra keys are provided.

Implement your own key by changing the pd value:

stringcare/ios/Classes/stringcare.cpp

std::string pd = "your_pasword";

Do the same in the Dart file:

stringcare/lib/src/compile/c_aproximation.dart

String pd = "your_pasword";

Feel free to change anything you want in those files (C++ and Dart). I recommend you change the numeric values of the sign method in those files.

Finish the setup

Once you modify the C++ file as you want, you need to push those changes to your private repository. For updating the plugin from a git repository you can:

// remove stringcare from your pubspec.yaml

flutter pub get

// add stringcare again to your pubspec.yaml

flutter pub get