diff --git a/lib/flutter_pty.dart b/lib/flutter_pty.dart index 0ba652c..c057fea 100644 --- a/lib/flutter_pty.dart +++ b/lib/flutter_pty.dart @@ -11,7 +11,11 @@ const _libName = 'flutter_pty'; final DynamicLibrary _dylib = () { if (Platform.isMacOS || Platform.isIOS) { - return DynamicLibrary.open('$_libName.framework/$_libName'); + // DynamicLibrary.process() resolves symbols from the already-loaded process + // image, which works for both SPM static linking and CocoaPods dynamic + // embedding (in the latter case the framework is already mapped into the + // process by the time any Dart code runs). + return DynamicLibrary.process(); } if (Platform.isAndroid || Platform.isLinux) { return DynamicLibrary.open('lib$_libName.so'); diff --git a/macos/flutter_pty.podspec b/macos/flutter_pty.podspec index ecb41cc..a452820 100644 --- a/macos/flutter_pty.podspec +++ b/macos/flutter_pty.podspec @@ -18,7 +18,7 @@ A new Flutter FFI plugin project. # paths, so Classes contains a forwarder C file that relatively imports # `../src/*` so that the C sources can be shared among all target platforms. s.source = { :path => '.' } - s.source_files = 'Classes/**/*' + s.source_files = 'flutter_pty/Classes/**/*' s.dependency 'FlutterMacOS' s.platform = :osx, '10.11' diff --git a/macos/Classes/flutter_pty.c b/macos/flutter_pty/Classes/flutter_pty.c similarity index 76% rename from macos/Classes/flutter_pty.c rename to macos/flutter_pty/Classes/flutter_pty.c index f2a8ed9..b44c0d3 100644 --- a/macos/Classes/flutter_pty.c +++ b/macos/flutter_pty/Classes/flutter_pty.c @@ -1,3 +1,3 @@ // Relative import to be able to reuse the C sources. // See the comment in ../{projectName}}.podspec for more information. -#include "../../src/flutter_pty.c" +#include "../../../src/flutter_pty.c" diff --git a/macos/flutter_pty/Package.swift b/macos/flutter_pty/Package.swift new file mode 100644 index 0000000..e9bc14a --- /dev/null +++ b/macos/flutter_pty/Package.swift @@ -0,0 +1,19 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "flutter_pty", + platforms: [ + .macOS("10.14") + ], + products: [ + .library(name: "flutter-pty", type: .static, targets: ["flutter_pty"]) + ], + targets: [ + .target( + name: "flutter_pty", + path: "Classes", + publicHeadersPath: "." + ) + ] +)