Skip to content

How to load xcframework #2598

@quetool

Description

@quetool

Hello! This is just a request for help. I am creating an xcframework following your guideline here https://cjycode.com/flutter_rust_bridge/manual/integrate/library/platform-setup/ios-and-macos but I'm not being able to load it.

Important note: I'm writing a flutter plugin that then is installed as dependency for apps.

This is what I have generated in iOS/ folder of the plugin:

Image

As you can see I have Frameworks/libyttrium.framework, which is what I set in the podfile:

Pod::Spec.new do |s|
  s.name                = 'yttrium_dart'
  s.version             = '0.8.36'
  s.summary             = '4337 implementation'
  s.description         = '4337 implementation and Chain Abstraction'
  s.homepage            = 'https://reown.com'
  s.license             = { :file => '../LICENSE' }
  s.author              = { 'Reown' => '[email protected]' }
  s.source              = { :git => 'https://github.com/reown-com/yttrium.git', :tag => s.version.to_s }
  s.source_files        = 'Classes/**/*'
  s.vendored_frameworks = 'Frameworks/libyttrium.framework'
  s.dependency 'Flutter'
  s.platform            = :ios, '13.0'

  # Flutter.framework does not contain a i386 slice.
  s.pod_target_xcconfig = {
    'DEFINES_MODULE' => 'YES',
    'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
    'LD_RUNPATH_SEARCH_PATHS' => '$(inherited) @executable_path/Frameworks',
  }
  s.swift_version = '5.0'

  # If your plugin requires a privacy manifest, for example if it uses any
  # required reason APIs, update the PrivacyInfo.xcprivacy file to describe your
  # plugin's privacy impact, and then uncomment this line. For more information,
  # see https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
  # s.resource_bundles = {'yttrium_dart_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
end

This is how I load it from Dart side:

if (Platform.isAndroid) {
  // Locate the native library file
  final yttrium = ExternalLibrary.open('libyttrium.so');
  // Initialize the Rust library
  await frb.YttriumDart.init(externalLibrary: yttrium);
} else if (Platform.isIOS) {
  // Initialize the Rust library
  await frb.YttriumDart.init();
} else {
  throw 'Yttrium not yet supported on ${Platform.localeName}';
}

I tried different combinations (included ExternalLibrary.process(iKnowHowToUseIt: true)) for iOS but when running the app this is what I see every time:

Failed to load dynamic library 'yttrium.framework/yttrium': dlopen(yttrium.framework/yttrium, 0x0001): tried: 'yttrium.framework/yttrium' (no such file), '/private/preboot/Cryptexes/OSyttrium.framework/yttrium' (no such file), '/private/var/containers/Bundle/Application/BC45AAAD-DD77-44E8-BD27-DCDA14580D16/Runner.app/yttrium.framework/yttrium' (no such file), '/usr/lib/swift/yttrium.framework/yttrium' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/yttrium.framework/yttrium' (no such file), '/private/var/containers/Bundle/Application/BC45AAAD-DD77-44E8-BD27-DCDA14580D16/Runner.app/Frameworks/yttrium.framework/yttrium' (no such file), '/private/var/containers/Bundle/Application/BC45AAAD-DD77-44E8-BD27-DCDA14580D16/Runner.app/Frameworks/yttrium.framework/yttrium' (no such file), '/usr/lib/yttrium.framework/yttrium' (no such file, not in dyld cache), 'yttrium.framework/yttrium' (no such file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaitingWaiting for responses, PR, further discussions, upstream release, etc

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions