I was trying to use a pod that was written in Obj-C and my project is Swift-only.
I got this error include of a non-modular header inside framework module
in the import statement of a dependency inside the framework .h file.
The pod spec of the library is:
Pod::Spec.new do |s|
s.name = 'flutter_vlc_player'
s.version = '0.0.3'
s.summary = 'A new Flutter project.'
s.description = <<-DESC
A new Flutter project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'MobileVLCKit', '~> 3.3.10'
s.static_framework = true
s.ios.deployment_target = '9.0'
end
The dependency is MobileVLCKit
.
I found some reports about similar issues:
- https://github.com/CocoaPods/CocoaPods/issues/7619
- https://github.com/CocoaPods/CocoaPods/issues/8668
- Importing CommonCrypto in a Swift framework
- http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/
- Include of non-modular header inside framework module
It seems like the Module Map of the project is missing, I want to do a PR to fix this in the library and it allows to work with Swift projects. However, I don’t know how I should configure the podspec of the library. I’ve seen stuff like in the podspec:
s.script_phase = {
:name => 'CommonCrypto',
:script => 'COMMON_CRYPTO_DIR="${SDKROOT}/usr/include/CommonCrypto"
if [ -f "${COMMON_CRYPTO_DIR}/module.modulemap" ]
then
echo "CommonCrypto already exists, skipping"
else
# This if-statement means we will only run the main script if the
# CommonCrypto.framework directory doesn not exist because otherwise
# the rest of the script causes a full recompile for anything
# where CommonCrypto is a dependency
# Do a "Clean Build Folder" to remove this directory and trigger
# the rest of the script to run
FRAMEWORK_DIR="${BUILT_PRODUCTS_DIR}/CommonCrypto.framework"
if [ -d "${FRAMEWORK_DIR}" ]; then
echo "${FRAMEWORK_DIR} already exists, so skipping the rest of the script."
exit 0
fi
mkdir -p "${FRAMEWORK_DIR}/Modules"
echo "module CommonCrypto [system] {
header \"${SDKROOT}/usr/include/CommonCrypto/CommonCrypto.h\"
export *
}" >> "${FRAMEWORK_DIR}/Modules/module.modulemap"
ln -sf "${SDKROOT}/usr/include/CommonCrypto" "${FRAMEWORK_DIR}/Headers"
fi',
:execution_position => :before_compile
}
However , I don’t know how to properly do this. Should I create a file called ModuleMap.h inside the library /Classes folder? And then put something like below?
framework module MixModuleFramework { umbrella header "MixModuleFramework.h" export * module * { export * } }
I don’t want to use the Allow Non-modular Includes in Framework Modules inside the project. I want to fix the library to its work with other projects.
When I try to run pod lib lint --no-clean
error: include of non-modular header inside framework module 'flutter_vlc_player.FlutterVlcPlayerPlugin': 'MobileVLCKit/MobileVLCKit.framework/Headers/MobileVLCKit.h' [-Werror,-Wnon-modular-include-in-framework-module]
From Xcode errors:
Include of non-modular header inside framework module 'flutter_vlc_player.FlutterVlcPlayerPlugin': '/var/folders/k7/1ptshnq15zn3nz6bgp7sj8h88w6vb6/T/CocoaPods-Lint-20200423-87288-nosd33-flutter_vlc_player/Pods/MobileVLCKit/MobileVLCKit.framework/Headers/MobileVLCKit.h'
It seems that cocoapods auto generates some modulemap
framework module flutter_vlc_player {
umbrella header "flutter_vlc_player-umbrella.h"
export *
module * { export * }
}
Still, I'm super noob on this modulemap issue and it does not allow projects that uses swift to build the app. So, how can I make the custom module app and let the podspec known that? Or, is there any other configuration that must to be done?