iOS Development

ios – The best way to correctly add an area framework dependency to a podspec file?

Spread the love


I am writing a Flutter plugin that reveals native ios screens that use an area kotlin multi platform so I would like so as to add it as a dependency to my plugin podspec file.
I did place it within the supply folder for the ios implementation which is my_flutter_plugin_root_folder/ios/Courses
I did attempt a number of approaches however to no avail.

  1. Following this reply The best way to embrace an area framework in Podspec pointing to this instance https://github.com/tom-xy/PodspecExample/blob/grasp/04_Framework.podspec
    Because the podspec file is in my_flutter_plugin_root_folder/ios I first tried so as to add it as vendored_framework as s.ios.vendored_frameworks="kotlin_mpp.framework" or, utilizing the relative rute to its framework as s.ios.vendored_frameworks="kotlin-mpp/kotlin-mpp/construct/cocoapods/framework/kotlin_mpp.framework" however then pod lib lintfails with - ERROR | [iOS] file patterns: The 'vendored_frameworks' sample didn't match any file. in each circumstances.
  2. Then following this reply Cocoa podspec and path for dependency I attempted including 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}" finish however then the error is - ERROR | [iOS] File Patterns: File patterns should be relative and can't begin with a slash (source_files)..
  3. I modified 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="Courses/kotlin-mmp" finish however then the error is ERROR | [iOS] unknown: Encountered an unknown error (CocoaPods couldn't discover suitable variations for pod "my_yap_native_screens_plugin/kotlin-mmp" None of your spec sources comprise a spec satisfying the dependency:my_native_screens_plugin/kotlin-mmp (= 0.0.1).

I am getting in circles right here. Can you see what I am doing improper?

#
# To study extra a few Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint my_native_screens_plugin.podspec` to validate earlier than publishing.
#
Pod::Spec.new do |s|
  s.title="my_yap_native_screens_plugin"
  s.model          = '0.0.1'
  s.abstract          = 'A brand new Flutter plugin undertaking.'
  s.description      = <<-DESC
A brand new Flutter plugin undertaking.
                       DESC
  s.homepage="http://instance.com"
  s.license          = { :file => '../LICENSE' }
  s.writer           = { 'Your Firm' => '[email protected]' }
  s.supply           = { :path => '.' }
  s.source_files="Courses/**/*"

  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/Playing cards', '122.0.1'
  # s.dependency 'MaterialComponents/Playing 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/Courses/kotlin-mpp' in instance/ios/Podfile
  # unknown: Encountered an unknown error (Unable to discover 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}"
  # finish
  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="Courses/kotlin_mmp"
  finish
  # s.subspec 'kotlin-mmp' do |ss|
  #   ss.source_files="Courses/kotlin-mmp"
  # finish
  # # 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/construct/cocoapods/framework/kotlin_mpp.framework"
  # s.ios.vendored_frameworks="ios/Courses/kotlin-mpp/kotlin-mpp/construct/cocoapods/framework/kotlin_mpp.framework"
  # s.preserve_path="kotlin-mpp/kotlin-mpp/construct/cocoapods/framework/*.framework"


  s.platform = :ios, '15.0'

  # s.static_framework = true
  # Flutter.framework doesn't comprise 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' }
finish


and that is the kotlin multi platform podspec file:

Pod::Spec.new do |spec|
    spec.title="kotlin_mpp"
    spec.model                  = '0.8.31'
    spec.homepage="https://xxxxxxx"
    spec.supply                   = { :git => "Not Printed", :tag => "Cocoapods/#{spec.title}/#{spec.model}" }
    spec.authors=""
    spec.license=""
    spec.abstract                  = 'xxxxx'
    
    spec.vendored_frameworks      = "construct/cocoapods/framework/kotlin_mpp.framework"
    spec.libraries                = "c++"
    spec.module_name              = "#{spec.title}_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 construct job invocation attributable to COCOAPODS_SKIP_KOTLIN_BUILD setting 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
        }
    ]
                
finish

Leave a Reply

Your email address will not be published. Required fields are marked *