@@ -8,7 +8,7 @@ import "structs.dart";
88
99// bundles all C functions to be exposed to Dart
1010class _ObjectBoxBindings {
11- DynamicLibrary objectbox ;
11+ DynamicLibrary lib ;
1212
1313 // common functions
1414 void Function (Pointer <Int32 > major, Pointer <Int32 > minor, Pointer <Int32 > patch) obx_version;
@@ -134,7 +134,7 @@ class _ObjectBoxBindings {
134134
135135 // TODO return .asFunction() -> requires properly determined static return type
136136 Pointer <NativeFunction <T >> _fn <T extends Function >(String name) {
137- return objectbox .lookup <NativeFunction <T >>(name);
137+ return lib .lookup <NativeFunction <T >>(name);
138138 }
139139
140140 _ObjectBoxBindings () {
@@ -143,14 +143,21 @@ class _ObjectBoxBindings {
143143 libName += ".dll" ;
144144 } else if (Platform .isMacOS) {
145145 libName = "lib" + libName + ".dylib" ;
146+ } else if (Platform .isIOS) {
147+ // this works in combination with `'OTHER_LDFLAGS' => '-framework ObjectBox'` in objectbox.podspec
148+ lib = DynamicLibrary .process ();
149+ // alternatively, if `DynamicLibrary.process()` wasn't faster (it should be though...)
150+ // libName = "ObjectBox.framework/ObjectBox";
146151 } else if (Platform .isAndroid) {
147152 libName = "lib" + libName + "-jni.so" ;
148153 } else if (Platform .isLinux) {
149154 libName = "lib" + libName + ".so" ;
150155 } else {
151- throw Exception ("unsupported platform detected" );
156+ throw Exception ("unsupported platform detected: ${Platform .operatingSystem }" );
157+ }
158+ if (lib == null ) {
159+ lib = DynamicLibrary .open (libName);
152160 }
153- objectbox = DynamicLibrary .open (libName);
154161
155162 // common functions
156163 obx_version = _fn <obx_version_native_t>("obx_version" ).asFunction ();
0 commit comments