Search code examples
iosionic-frameworkcapacitorionic-nativecapacitor-plugin

Custom capacitor plugin fails with pod dependency


I'm writing my own capacitor plugin based on

https://capacitorjs.com/docs/ios/custom-code https://devdactic.com/build-capacitor-plugin/

but adding it to my main project with

npm install ../MyPlugin

fails

npx cap sync

with

✖ Updating iOS native dependencies with "pod install" (may take several minutes): 
✖ update ios: 
[error] Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "MyPlugin":
  In Podfile:
    MyPlugin (from `../../../my-plugin`)

Specs satisfying the `MyPlugin (from `../../../my-plugin`)` dependency were found, but they required a higher minimum deployment target.

I tried adjusting the podfile required ios version as in `Firebase/Auth` dependency were found, but they required a higher minimum deployment target

to 11 to be in line with my main project

platform :ios, '11.0'

def capacitor_pods
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
  pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios'
end

target 'Plugin' do
  capacitor_pods
end

target 'PluginTests' do
  capacitor_pods
end

but the error still persists. Where should I look to get this going? Thanks


Solution

  • The guide you should be looking at is this one.

    Or this one if you are in Capacitor 2.

    If you migrated your app from Capacitor 2 to Capacitor 3 you might have missed the step where you have to bump the deployment target to iOS 12

    Capacitor 3 requires that your app has iOS 12 as the deployment target, and if you follow the guide on the first link, the plugin will also require iOS 12. While if you are in Capacitor 2 and follow the second link, the plugin will require iOS 11.