This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# we're still in the `rust` folder so… | |
inc=../ios/include | |
libs=../ios/libs | |
mkdir ${inc} | |
mkdir ${libs} | |
cp rustylib.h ${inc} | |
cp target/universal/release/librustylib.a ${libs} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it's important to not forget the release flag. | |
cargo lipo --release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd rust | |
cbindgen src/lib.rs -l c > rustylib.h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install the Xcode build tools. | |
xcode-select --install | |
# this cargo subcommand will help you create a universal library for use with iOS. | |
cargo install cargo-lipo | |
# this tool will let you automatically create the C/C++11 headers of the library. | |
cargo install cbindgen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Android targets | |
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android | |
# iOS targets | |
rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd rust | |
cargo init - name rustylib - lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir rust-for-android-ios-flutter | |
cd rust-for-android-ios-flutter | |
mkdir ios android rust flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:async'; | |
import 'package:flutter/services.dart'; | |
import 'package:rusty_flutter_lib/rusty_flutter_lib.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatefulWidget { | |
@override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Flutter | |
import UIKit | |
public class SwiftRustyFlutterLibPlugin: NSObject, FlutterPlugin { | |
public static func register(with registrar: FlutterPluginRegistrar) { | |
let channel = FlutterMethodChannel(name: "rusty_flutter_lib", binaryMessenger: registrar.messenger()) | |
let instance = SwiftRustyFlutterLibPlugin() | |
registrar.addMethodCallDelegate(instance, channel: channel) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.robertohuertas.rusty_flutter_lib | |
// importing the Android library | |
import com.robertohuertas.rusty_android_lib.* | |
import io.flutter.plugin.common.MethodCall | |
import io.flutter.plugin.common.MethodChannel | |
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | |
import io.flutter.plugin.common.MethodChannel.Result | |
import io.flutter.plugin.common.PluginRegistry.Registrar |