dart-lang / dart-lang/native

Using dart:ffi with a xcframework containing static binaries (iOS)

Open
#934 10 comments 0 reactions 0 assignees View on GitHub
package:ffi
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

Given the `libcool.xcframework` containing large static binaries like so:

```
Info.plis
├── ios-arm64_armv7_armv7s
│ ├── libcool.a
├── ios-arm64_x86_64-simulator
│ ├── libcool.a

```

and a `bindings.dart` containing the bindings generated with ffigen.

What is the recommended way to use this in my iOS FFI Plugin.

My plugins `podspec` looks like this:

```
# To learn more about a Podspec, see http://guides.cocoapods.org/syntax/podspec.html
Pod::Spec.new do |s|
s.name = 'my_plugin'
s.version = '0.0.1'
s.summary = 'My Plugin.'
s.description = <<-DESC
An iOS implementation of My Plugin.
DESC
s.homepage = 'http://example.com'
s.license = { :type => 'BSD', :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.dependency 'Flutter'
s.platform = :ios, '11.0'

# Flutter.framework does not contain an i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'

s.source = { :http => "path/to/binaries" }
s.ios.vendored_frameworks = "**/libcool.xcframework"
end
```

When opening the dynamic library of the plugin in dart with `DynamicLibrary.open('my_plugin.framework/my_plugin')`
and calling one of the bindings i run into `Invalid argument(s): Failed to lookup symbol '': dlsym(0x7f97b7a3ecb0, lib_cool_method_a): symbol not found`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.