trinhngocthuyen / cocoapods-spm

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

[Bug] Library not loaded: @rpath/ogg.framework/ogg #98

Closed kalub92 closed 2 weeks ago

kalub92 commented 4 weeks ago

What happened?

On my fork of cocoapods-spm, I can compile the EX app target, but when the app launches I see the following issue:

dyld[97467]: Library not loaded: @rpath/ogg.framework/ogg
  Referenced from: <2DA628EF-071C-33D8-AA00-7B1A3EBC3599> /Users/cstultz/Library/Developer/Xcode/DerivedData/EX-dvopbqpxtghxchfetmgezzfsuptf/Build/Products/Debug-iphonesimulator/opus.framework/opus
  Reason: tried: '/Users/cstultz/Library/Developer/Xcode/DerivedData/EX-dvopbqpxtghxchfetmgezzfsuptf/Build/Products/Debug-iphonesimulator/ogg.framework/ogg' (no such file), '/Users/cstultz/Library/Developer/Xcode/DerivedData/EX-dvopbqpxtghxchfetmgezzfsuptf/Build/Products/Debug-iphonesimulator/PackageFrameworks/ogg.framework/ogg' (no such file), '/Users/cstultz/Library/Developer/CoreSimulator/Devices/79B9F89A-CC2B-4846-BBA7-84E3AF0DBDA7/data/Containers/Bundle/Application/17870CCD-78D9-41F8-AEC7-90DE0A49E573/Frameworks/ogg.framework/ogg' (no such file), '/Users/cstultz/Library/Developer/Xcode/DerivedData/EX-dvopbqpxtghxchfetmgezzfsuptf/Build/Products/Debug-iphonesimulator/opus.framework/Frameworks/ogg.framework/ogg' (no such file), '/Users/cstultz/Library/Developer/CoreSimulator/Devices/79B9F89A-CC2B-4846-BBA7-84E3AF0DBDA7/data/Containers/Bundle/Application/17870CCD-78D9-41F8-AEC7-90DE0A49E573/EX.app/Frameworks/ogg.framework/ogg' (no such file), '/Users/cstultz/Library/Developer/CoreSimulator/Devices/79B9F89A-CC2B-4846-BBA7-84E3AF0DBDA7/data/Containers/Bundle/Application/17870CCD-78D9-41F8-AEC7-90DE0A49E573/EX.app/Frameworks/ogg.framework/ogg' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ogg.framework/ogg' (no such file)

And when attempting to compile the EXTests target, I am seeing a familiar issue again: Missing required module 'ThirdPartyAdapter'

image

Get the latest changes on my fork (branch: kalub92/hyphenated_module_name_bug) here: https://github.com/kalub92/cocoapods-spm/commit/9e7b58ec994b4601ce0a26fc4ad8d2d2a2c67361

CocoaPods environment

Stack

   CocoaPods : 1.14.3
        Ruby : ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin21]
    RubyGems : 3.3.3
        Host : macOS 14.3.1 (23D60)
       Xcode : 15.4 (15F31d)
         Git : git version 2.44.0
Ruby lib dir : /Users/cstultz/.rvm/rubies/ruby-3.1.0/lib
               trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /Users/cstultz/.rvm/gems/ruby-3.1.0/bin/pod

Plugins

cocoapods-compact-spec : 0.0.3
cocoapods-deintegrate  : 1.0.5
cocoapods-plugins      : 1.0.0
cocoapods-search       : 1.0.1
cocoapods-spm          : 0.1.5
cocoapods-trunk        : 1.6.0
cocoapods-try          : 1.2.0

Podfile

platform :ios, "16.0"
linkage = (ENV["LINKAGE"] || :static).to_sym
use_frameworks! :linkage => linkage
puts "Using linkage: #{linkage}"

@checksum = "dummy-checksum-to-prevent-merge-conflicts"

plugin "cocoapods-spm"

config_compact_spec(
  extra: ->(s) { s.ios.deployment_target = "16.0" }
)

config_cocoapods_spm(
  dont_prebuild_macros: true,
  default_macro_config: "debug"
)

def spm_pods
  spm_pkg "SamplePackageA",
          :git => "https://github.com/kalub92/SamplePackageA.git",
          :branch => "withHyphenatedDependency"
end

abstract_target 'Example' do

  spm_pods

  target "EX" do
    pod "Logger", :path => "LocalPods/Logger"
    # pod "Services", :path => "LocalPods/Services"

    spm_pkg "SnapKit",
            :url => "https://github.com/SnapKit/SnapKit.git",
            :version => "5.7.1",
            :products => ["SnapKit-Dynamic"]
    spm_pkg "SwiftUIX", :git => "https://github.com/SwiftUIX/SwiftUIX.git", :tag => "0.1.9"
    spm_pkg "SwiftyBeaver", :git => "https://github.com/SwiftyBeaver/SwiftyBeaver.git", :tag => "2.0.0"
    spm_pkg "opentelemetry-swift",
            :git => "https://github.com/open-telemetry/opentelemetry-swift.git",
            :branch => "main",
            :products => ["OpenTelemetrySdk"]
    spm_pkg "GoogleMaps",
            :git => "https://github.com/googlemaps/ios-maps-sdk.git",
            :version => "8.4.0",
            :products => ["GoogleMaps", "GoogleMapsBase", "GoogleMapsCore"]
    spm_pkg "DebugKit", :path => "LocalPackages/debug-kit"
  end

  target "EXTests" do
    pod "NetworkTestKit", :path => "LocalPods/NetworkTestKit"
    pod "AppTestKit", :path => "LocalPods/AppTestKit"
  end

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete "IPHONEOS_DEPLOYMENT_TARGET"
    end
  end
end

Anything else?

No response

trinhngocthuyen commented 3 weeks ago

I think there might be a misconfiguration here.

In SamplePackageB-iOS, I dont see ogg being declared anywhere. https://github.com/kalub92/SamplePackageB-iOS/blob/master/Package.swift#L26-L119 Meanwhile, opus depends on ogg. That causes the "library not loaded" crash.

I've just checked frameworks under ThirdPartyVendor/iOS and they are all dynamic. That explains why it bypasses compilation-time, meaning the build succeeded.

Screenshot 2024-06-15 at 6 37 38 PM

So, for this case, kindly help declare ogg as a binaryTarget dependency of SamplePackageB-iOS.

kalub92 commented 2 weeks ago

Closing as you were right about a misconfiguration. Opening a new issue with the last remaining problem I'm experiencing!