How To Use Objective-C Framework In Swift Without Bridging Header?
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.
Answer
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"
Related Questions
- → Shopify iOS SDK - issue converting BuyProductVariant to BuyProduct
- → BigCommerce and shopify API
- → How to print the cart items,remove cart items in shopify ios sdk?
- → How to keep the user logged in or check if the user is logged in or not in Shopify?
- → How to covert a custom class into json array or json dictionary in objective c?
- → React Native Debug iOS Component in XCode
- → Error tokenizing data. C error: EOF following escape character
- → data type understanding of Parse database
- → How to save the response From My server , and How can i access That data
- → Bulk creation of components in React Native
- → How to mute AVAudioPlayer if music from another app is playing in spritekit
- → Swift Array memory address changes when referring to the same variable
- → String encryption in Objective-C decrypt in C#