Skip to content

Commit

Permalink
Merge pull request #290 from cunarist/dynamic-load
Browse files Browse the repository at this point in the history
Use dynamic loading for native libraries on iOS and macOS
  • Loading branch information
temeddix authored Feb 5, 2024
2 parents 88d0ca0 + 4ebbbb3 commit 6078025
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion flutter_ffi_plugin/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -580,7 +580,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -629,7 +629,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
12 changes: 6 additions & 6 deletions flutter_ffi_plugin/lib/src/load_os.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ final rustLibrary = loadRustLibrary();

DynamicLibrary loadRustLibrary() {
if (io.Platform.isLinux) {
return DynamicLibrary.open('libhub.so'); // Dynamic library
return DynamicLibrary.open('libhub.so');
} else if (io.Platform.isAndroid) {
return DynamicLibrary.open('libhub.so'); // Dynamic library
return DynamicLibrary.open('libhub.so');
} else if (io.Platform.isWindows) {
return DynamicLibrary.open('hub.dll'); // Dynamic library
return DynamicLibrary.open('hub.dll');
} else if (io.Platform.isIOS) {
return DynamicLibrary.executable(); // Static library
return DynamicLibrary.open('rinf.framework/rinf');
} else if (io.Platform.isMacOS) {
return DynamicLibrary.executable(); // Static library
return DynamicLibrary.open('rinf.framework/rinf');
} else {
throw UnsupportedError('The operating system is not supported.');
throw UnsupportedError('This operating system is not supported.');
}
}

0 comments on commit 6078025

Please sign in to comment.