trinhngocthuyen / cocoapods-spm

A CocoaPods plugin to add SPM dependencies to CocoaPods-based projects
MIT License
36 stars 7 forks source link

[Bug] undefined method `spm_pkg' #38

Closed Droppix closed 4 months ago

Droppix commented 4 months ago

What happened?

I installed: 'gem install cocoapods-spm' but spm_pkg undefined.

[!] Invalid Podfile file: undefined method `spm_pkg' for #.

platform :ios, '13.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
  spm_pkg "NearbyConnections", :url => "https://github.com/google/nearby.git", :branch => "main"
end

target 'PluginTests' do
  capacitor_pods
end

CocoaPods environment

No response

Anything else?

No response

trinhngocthuyen commented 4 months ago

@Droppix Thanks for reaching out! Basically, the error indicates that the plugin was not installed correctly. May I know how you install and run CocoaPods with the plugin?

If you're using bundler (ie. having Gemfile in the project), then make sure:

Droppix commented 4 months ago

Thanks for your response.

Indeed, I had an old version of ruby (2.6.6) installed, the update to ruby 3.3.0 works well!

I tried to integrate the NearbyConnections SPM (google: https://github.com/google/nearby.git) which depends on "NearByCoreAdapter" (integrated in the NearbyConnections project), and I get the error: Missing required module 'NearbyCoreAdapter'.

Whereas if I integrate the NearbyConnections SPM directly (excluding Cocoapods), it works fine.

If you have a suggestion, I'd love to hear it...


plugin "cocoapods-spm"

def capacitor_pods
  use_frameworks!
  pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
  pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios'
end

target 'Plugin' do
  capacitor_pods
  spm_pkg "NearbyConnections", :git => "https://github.com/google/nearby.git", :branch => "main"
end

target 'PluginTests' do
  capacitor_pods
end
trinhngocthuyen commented 4 months ago

Let me take a further look for this case.

trinhngocthuyen commented 4 months ago

@Droppix I would suggest closing the current one and creating a follow-up issue (related to NearbyCoreAdapter), to keep it relevant. Is it ok?

trinhngocthuyen commented 4 months ago

Created https://github.com/trinhngocthuyen/cocoapods-spm/issues/39 for reference.