Search code examples
fluttercocoapods

Flutter Plugin with xcframework only works with device not in ios simulator


I have created a flutter plugin. By running the example app in Flutter I get this error:

Error: Swift Compiler Error (Xcode): No such module 'AusweisApp2'

Here is my folder structure:

enter image description here

podspec file:

Pod::Spec.new do |s|       
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.dependency 'Flutter'
  s.platform = :ios, '11.0'
  s.vendored_frameworks = 'Frameworks/AusweisApp2.xcframework'
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework AusweisApp2' }

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

The App works on device but not on ios simulators. You can download the xcframework here https://github.com/Governikus/AusweisApp2-SDK-iOS

Update:

  • In Flutter 2.2.1 it works
  • In Flutter 2.5.3 it works not
  • in Flutter 2.8.0 it works
  • in Flutter 2.8.1 it works not
  • in Flutter 2.10.3 it works not

Solution

  • Flutter/Xcode builds the app for the simulator in arm64 and x86_64 architecture for some reason. You can simply exclude the arm64 architecture by adding this line to your podspec:

    s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386 arm64' }