Prerequisite
Steps to reproduce
use_frameworks! from _Podfile_ to get static libraries instead of frameworkspod installProject compiles without failures (as it was with use_frameworks!)
Compilation fails with following error (_SwiftyJSON_ as example pod)
<unknown>:0: error: cannot load underlying module for 'SwiftyJSON'
on import of _lower level_ framework _inside higher level_ framework.
CocoaPods : 1.5.3
Ruby : ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin17]
RubyGems : 2.6.14
Host : Mac OS X 10.13.6 (17G65)
Xcode : 9.4 (9F1027a)
Git : git version 2.15.1 (Apple Git-101)
Ruby lib dir : /Users/username/.rvm/rubies/ruby-2.2.2/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 53ea5caff776919889ecfb8ea78742a189fbda83
Executable Path: /Users/username/.rvm/gems/ruby-2.2.2/bin/pod
cocoapods-deintegrate : 1.0.2
cocoapods-open : 0.0.8
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.3.0
cocoapods-try : 1.1.0
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10'
# Compiles and runs with frameworks, not with static libraries
# use_frameworks!
def pod_swiftyjson
pod 'SwiftyJSON', '~> 4.0'
end
target :'ExampleApp' do
pod_swiftyjson
end
target :'TopLevelFramework' do
end
target :'EmbeddedFramework' do
pod_swiftyjson
end
Simple project replicating the setup mentioned above with embedded frameworks.
I am not sure this little specific project setup is meant to work / be supported by CocoaPods. I just wanted to give heads up for you to decide.
And big thank you to everyone investing time in having a look! 😃
Facing a similar issue, my current workaround for the Example.zip above is to add SwiftyJSON into all targets unnecessarily...
This will increase the binary size which generates too many warnings:
Class PodsDummy_{Classname} is implemented in both {Target 1} and {Target 2}. One of the two will be used. Which one is undefined.
My usage:
I have a Swift Cocoa Touch Framework which is distribute as vendored_frameworks, originally built with the use_frameworks! flag, so my framework has a dynamic framework dependency, and all the dependencies are listed in the podspec like s.dependency 'Alamofire', '~> 4.7'
I was trying to convert this framework to use static library, so that the users can use static library also, and found out that if I remove all the s.dependency in podspec (since they are included in the Mach-O already, shouldn't have dependency anymore?), Xcode will generates the cannot load underlying module error, so the current situation is forcing the end users to "double install" the pods and will generates the One of the two will be used. Which one is undefined. warning
Seeing the same issue. In parent targets, Xcode is not able to resolve Pod modules that are imported by dependency frameworks. Not sure if this is the right fix for cocoapods, but always naming module files as module.modulemap rather than ${PRODUCT_MODULE_NAME}.modulemap would solve this (at least when implicit dependencies are enabled in Xcode).
For example, in this case if I rename SwiftyJSON.modulemap to module.modulemap (and fix all references to the old name), everything builds correctly. Another approach is to add all missing module maps to OTHER_SWIFT_FLAGS of the parent targets, but I think it's less elegant.
You can get around this by just making TopLevelFramework and EmbeddedFramework into local (static library) pods and it will de-duplicate everything for you.
Having dynamic umbrella frameworks that host static libs within themselves and an app target will mean the static libs get duplicated so those warnings seem to be real. Example: https://github.com/CocoaPods/CocoaPods/issues/5768#issuecomment-342914131
Examples: https://github.com/rob-keepsafe/PodFrameworksIssue
master branch shows duplicate symbolsdeduped branch makes the internal dynamic frameworks into local pods (as static libs) to de-dupe and still link in the dependencies@rob-keepsafe your solution make the duplicate symbols warnings gone. but it break up the project structure
@a83988029 You don't have much of an option ¯_(ツ)_/¯ This is just how static/dynamic frameworks work at a compiler level.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1: