0

I'm developing a Flutter plugin (in Swift) trying to wrap an Obj-C framework. I was able to import the Header files in MyPlugin.h file, but now how do I use the framework without a Bridging Header? I'm just getting not found in scope.

If I were to generate a Bridging Header, I ran into another error using bridging headers with framework targets is unsupported

This is my podspec file, I had to set DEFINES_MODULE to NO in order to build the project without running into Include of non-modular header inside framework module error

Pod::Spec.new do |s|
  s.name             = 'lisnr'
  s.version          = '1.0.0'
  s.summary          = 'Flutter plugin for LISNR'
  s.description      = <<-DESC
  Flutter plugin for LISNR.
                       DESC
  s.homepage         = 'redacted'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'redacted' => 'redacted' }
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.dependency 'Flutter'
  s.platform = :ios, '8.0'

  s.preserve_paths = 'radius.framework'
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework radius' }
  s.vendored_frameworks = 'radius.framework'

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

The other codes are pretty much generated by the Flutter CLI.

2
  • "Include of non-modular header inside framework module". This error might be related to the access level of your headers declared in the framework. Have you tried to mark those headers exposed through the framework's umbrella header as public instead of project/private? Commented Nov 10, 2020 at 11:22
  • Yes, the plugin-umbrella.h is public on Build Phases Headers. I don't know if it matters, but it's under the Pods project. Also, the framework container only Headers folder, no Modules folder found Commented Nov 10, 2020 at 13:46

1 Answer 1

5

You need a module map. You can either write it manually and put in the framework or do it with a script. See how I did it here for the Spotify SDK which is an ObjC framework.

The script for you would be something like that:

#!/bin/sh

MODULE_DIR="MY_PATH/radius.framework" # You framework's path
mkdir -p "${MODULE_DIR}"
printf "module radius {\n\
header \"Headers/radius.h\"\n\
export *\n\
}" > "${MODULE_DIR}/module.map"
Sign up to request clarification or add additional context in comments.

5 Comments

That did it! Thanks! Never knew I would just need a module map, I thought the umbrella.h would have done it. Many thanks!
Hi, appreciate for you script, but what if the sdk just provide a binary file(radius.a, etc), how can I create module.map in this situation ?
It shouldn’t matter if it is a binary framework. The headers should still be public and visible as source code. Now if you only have a “.a” file then you are missing the header files. Those should be provided along the “.a” file from the vendor of the SDK.
@LiuJQ please consider upvoting the answer if it helped you
@FotiDim Yeah, I did.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.