I’m writing a Flutter plugin that shows native ios screens that use a local kotlin multi platform so I need to add it as a dependency to my plugin podspec file.
I did place it in the source folder for the ios implementation which is my_flutter_plugin_root_folder/ios/Classes
I did try a few approaches but to no avail.
- Following this answer How to include a local framework in Podspec pointing to this example https://github.com/tom-xy/PodspecExample/blob/master/04_Framework.podspec
As the podspec file is inmy_flutter_plugin_root_folder/iosI first tried to add it asvendored_frameworkass.ios.vendored_frameworks="kotlin_mpp.framework"or, using the relative rute to its framework ass.ios.vendored_frameworks="kotlin-mpp/kotlin-mpp/build/cocoapods/framework/kotlin_mpp.framework"but thenpod lib lintfails with- ERROR | [iOS] file patterns: The 'vendored_frameworks' pattern did not match any file.in both cases. - Then following this answer Cocoa podspec and path for dependency I tried adding it as a subspec as
s.ios.dependency 'my_native_screens_plugin/kotlin-mmp' s.subspec 'my_native_screens_plugin' do |ss| ss.source_files="/my_native_screens_plugin/**/*.{h,m}" endbut then the error is- ERROR | [iOS] File Patterns: File patterns must be relative and cannot start with a slash (source_files).. - I changed it to a relative path
s.ios.dependency 'my_yap_native_screens_plugin/kotlin-mmp' s.subspec 'my_native_screens_plugin' do |ss| ss.source_files="Classes/kotlin-mmp" endbut then the error isERROR | [iOS] unknown: Encountered an unknown error (CocoaPods could not find compatible versions for pod "my_yap_native_screens_plugin/kotlin-mmp" None of your spec sources contain a spec satisfying the dependency:my_native_screens_plugin/kotlin-mmp (= 0.0.1).
I’m going in circles here. Can you spot what I’m doing wrong?
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint my_native_screens_plugin.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name="my_yap_native_screens_plugin"
s.version = '0.0.1'
s.summary = 'A new Flutter plugin project.'
s.description = <<-DESC
A new Flutter plugin project.
DESC
s.homepage="http://example.com"
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => '[email protected]' }
s.source = { :path => '.' }
s.source_files="Classes/**/*"
s.dependency 'Flutter'
s.dependency 'MaterialComponents/Snackbar', '122.0.1'
# s.dependency 'MaterialComponents/Snackbar', :modular_headers => true
s.dependency 'MaterialComponents/TextFields', '122.0.1'
# s.dependency 'MaterialComponents/TextFields', :modular_headers => true
s.dependency 'MaterialComponents/TextFields+Theming', '122.0.1'
# s.dependency 'MaterialComponents/TextFields+Theming', :modular_headers => true
s.dependency 'MaterialComponents/Cards', '122.0.1'
# s.dependency 'MaterialComponents/Cards', :modular_headers => true
s.dependency 'MaterialComponents/BottomNavigation', '122.0.1'
# s.dependency 'MaterialComponents/BottomNavigation', :modular_headers => true
s.dependency 'MaterialComponents/Chips', '122.0.1'
# s.dependency 'MaterialComponents/Chips', :modular_headers => true
s.dependency 'MaterialComponents/Chips+Theming', '122.0.1'
# s.dependency 'MaterialComponents/Chips+Theming', :modular_headers => true
s.dependency 'MaterialComponents/Tabs+TabBarView', '122.0.1'
# s.dependency 'MaterialComponents/Tabs+TabBarView', :modular_headers => true
s.dependency 'MaterialComponents/Buttons', '122.0.1'
# s.dependency 'MaterialComponents/Buttons', :modular_headers => true
s.dependency 'MBProgressHUD', '1.2.0'
# s.dependency 'MBProgressHUD', :modular_headers => true
s.dependency 'Firebase/CoreOnly', '10.9.0'
# s.dependency 'Firebase/CoreOnly', :modular_headers => true
s.dependency 'Firebase/Analytics', '10.9.0'
# s.dependency 'Firebase/Analytics', :modular_headers => true
s.dependency 'Firebase/Auth', '10.9.0'
# s.dependency 'Firebase/Auth', :modular_headers => true
s.dependency 'Firebase/Crashlytics', '10.9.0'
# s.dependency 'Firebase/Crashlytics', :modular_headers => true
s.dependency 'IQKeyboardManagerSwift', '6.5.10'
s.dependency 'IGListKit', '4.0.0'
# s.dependency 'IGListKit', :modular_headers => true
s.dependency 'SwiftRichString', '3.7.2'
s.dependency 'JTAppleCalendar', '8.0.5'
s.dependency 'SDWebImage', '5.13.1'
# s.dependency 'SDWebImage', :modular_headers => true
s.dependency 'YPImagePicker', '5.2.2'
s.dependency 'PanModal', '1.2.7'
s.dependency 'lottie-ios', '3.4.0'
# s.dependency 'TouchDraw', '2.1.2'
# s.dependency 'kotlin-mpp', '0.8.31' # plus pod 'kotlin_mpp', :path => '../../ios/Classes/kotlin-mpp' in example/ios/Podfile
# unknown: Encountered an unknown error (Unable to find a specification for `kotlin-mpp (= 0.8.31)` depended upon by `my_native_screens_plugin`
# s.ios.dependency 'YourPodName/YourPodDependencyFolder'
# s.ios.dependency 'my_native_screens_plugin/Class/**/*.{h,m}'
# s.subspec 'YourPodName' do |ss|
# ss.source_files="../YourPodName/**/*.{h,m}"
# end
s.ios.dependency 'my_native_screens_plugin/kotlin_mmp'
s.subspec 'my_native_screens_plugin' do |ss|
# ss.source_files="/my_native_screens_plugin/**/*.{h,m}"
ss.source_files="Classes/kotlin_mmp"
end
# s.subspec 'kotlin-mmp' do |ss|
# ss.source_files="Classes/kotlin-mmp"
# end
# # s.dependency 'MDFInternationalization', '3.0.0'
# # s.dependency 'MDFTextAccessibility', '2.0.1'
# s.ios.vendored_frameworks="kotlin_mpp.framework"
# # s.dependency 'QuickTableViewController', '1.3.0' # used for settings VC now flutter
# s.ios.vendored_frameworks="kotlin-mpp/kotlin-mpp/build/cocoapods/framework/kotlin_mpp.framework"
# s.ios.vendored_frameworks="ios/Classes/kotlin-mpp/kotlin-mpp/build/cocoapods/framework/kotlin_mpp.framework"
# s.preserve_path="kotlin-mpp/kotlin-mpp/build/cocoapods/framework/*.framework"
s.platform = :ios, '15.0'
# s.static_framework = true
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', 'VALID_ARCHS' => 'armv7 arm64' }
s.swift_version = '5.0'
# s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC -lsqlite3' }
end
and this is the kotlin multi platform podspec file:
Pod::Spec.new do |spec|
spec.name="kotlin_mpp"
spec.version = '0.8.31'
spec.homepage="https://xxxxxxx"
spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
spec.authors=""
spec.license=""
spec.summary = 'xxxxx'
spec.vendored_frameworks = "build/cocoapods/framework/kotlin_mpp.framework"
spec.libraries = "c++"
spec.module_name = "#{spec.name}_umbrella"
spec.ios.deployment_target="11.0"
spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':kotlin-mpp',
'PRODUCT_MODULE_NAME' => 'kotlin_mpp',
}
spec.script_phases = [
{
:name => 'Build kotlin_mpp',
:execution_position => :before_compile,
:shell_path => '/bin/sh',
:script => <<-SCRIPT
if [ "YES" = "$COCOAPODS_SKIP_KOTLIN_BUILD" ]; then
echo "Skipping Gradle build task invocation due to COCOAPODS_SKIP_KOTLIN_BUILD environment variable set to \"YES\""
exit 0
fi
set -ev
REPO_ROOT="$PODS_TARGET_SRCROOT"
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT/.." $KOTLIN_PROJECT_PATH:syncFramework \
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
-Pkotlin.native.cocoapods.archs="$ARCHS" \
-Pkotlin.native.cocoapods.configuration=$CONFIGURATION \
-Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \
-Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \
-Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"
SCRIPT
}
]
end




