trinhngocthuyen / cocoapods-spm

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

[Bug] aws-crt-swift package modulemap not found #105

Closed zeeshanmakeen closed 2 months ago

zeeshanmakeen commented 4 months ago

What happened?

I am running this pod file:

target 'TestApp' do
 platform :ios, '13.0'

 spm_pkg "aws-crt-swift", 
  :git => "https://github.com/awslabs/aws-crt-swift.git", 
  :branch => "0.30.0", 
  :products => [
    "AwsCommonRuntimeKit"
     ]
end

Pod install command is running fine. But when building the actual project, I am getting this error:

/Users/zeeshansheikh/Documents/GitHub/AmazonLocationiOSAuthTest/AmazonLocationiOSAuthTestApp/Pods/Target Support Files/Pods-AmazonLocationiOSAuthTestApp/Pods-AmazonLocationiOSAuthTestApp-dummy.m module map file '/Users/zeeshansheikh/Library/Developer/Xcode/DerivedData/AmazonLocationiOSAuthTestApp-djdgfoosokhnpmgxmjfddepnxwvz/Build/Intermediates.noindex/GeneratedModuleMaps-iphonesimulator/AwsCPlatformConfig.modulemap' not found

It is not generating all the modulemap files. Specifically the moduel inside aws-common-runtime folder of the SPM package. This is happening with this spm package only. Am I missing something here?

CocoaPods environment

Stack

   CocoaPods : 1.15.2
        Ruby : ruby 3.3.3 (2024-06-12 revision f1c7b6f435) [arm64-darwin23]
    RubyGems : 3.5.14
        Host : macOS 14.5 (23F79)
       Xcode : 15.4 (15F31d)
         Git : git version 2.45.2
Ruby lib dir : /opt/homebrew/Cellar/ruby/3.3.3/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /opt/homebrew/lib/ruby/gems/3.3.0/bin/pod

Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-pod-linkage : 0.0.1
cocoapods-search      : 1.0.1
cocoapods-spm         : 0.1.4
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

Podfile

target 'AmazonLocationiOSAuthTestApp' do
 platform :ios, '13.0'

 spm_pkg "aws-crt-swift", 
  :git => "https://github.com/awslabs/aws-crt-swift.git", 
  :branch => "0.30.0", 
  :products => [
    "AwsCommonRuntimeKit"
     ]
end

Anything else?

No response

zeeshanmakeen commented 4 months ago

Hi @trinhngocthuyen any advice on this?

trinhngocthuyen commented 2 months ago

Hi there, sorry for the very late response. I took a look at this issue, and it turned out to be an issue in headers/modulemap detection. I've made the fix in #109. Thank you!

zeeshanmakeen commented 2 months ago

Thank you for the fix

Linkadi98 commented 1 week ago

Sorry for commenting on a closed issue but I think it's not enough to file a new one. I also use aws-crt-swift in my project, the defining line of the aws-crt-swift just like your Podfile, when I run the pod install, everything works fine but I come back to my Xcode and there is an error said that aws-crt-swift cannot resolve because the package is not found at the git url. After I manually resetting spm the aws-crt-swift is pulled without any issue. How can I fix this? @trinhngocthuyen @zeeshanmakeen

trinhngocthuyen commented 1 week ago

@Linkadi98 Hey there. It would be best if we had more info like:

Linkadi98 commented 1 week ago
image

I get this error all the time when I run pod install

Linkadi98 commented 1 week ago

Also, I get another error when trying to compile the flutter app ios with aws-crt-swift dependency from your plugin

image

This is so weird because I build the flutter app it never works, but when I switch to build natively (by Xcode) everything works smoothly

Linkadi98 commented 1 week ago

this is my Podfile

# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

plugin "cocoapods-spm"

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  spm_pkg "AmplifyUILiveness",
  :url => "https://github.com/aws-amplify/amplify-ui-swift-liveness.git",
  :branch => "main",
  :products => ["FaceLiveness"]

  spm_pkg "aws-crt-swift",
  :git => "https://github.com/awslabs/aws-crt-swift.git",
  :branch => "main",
  :products => ["AwsCommonRuntimeKit"]

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    target.build_configurations.each do |config|
      config.build_settings['HEADER_SEARCH_PATHS'] ||= ['$(inherited)']
      config.build_settings['HEADER_SEARCH_PATHS'] << "$(SOURCE_PACKAGE_CHECKOUT_DIR)/aws-crt-swift/aws-c-auth/include"
    end
  end
end
Linkadi98 commented 1 week ago

@trinhngocthuyen any idea on this? It's very hard to use spm with cocoapods but the tool has done alot of works. Maybe the issue comes from flutter ios build tool but I'm not sure about this.

trinhngocthuyen commented 1 week ago

@Linkadi98 Let's track this in a separate issue. Shall we?

Linkadi98 commented 1 week ago

@trinhngocthuyen I created a new track issue #122