I am using Xcode 12.2, and working on a Swift static framework (embedded in a .xcframework in the end), which I intend to deliver with CocoaPods.
My issue is currently not the CocoaPods integration in an app project (pod install works correctly and app builds & run), but the pod validation with pod lib lint command.
The lint validation fails, with logs containing the following:
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftAVFoundation'
ld: warning: Could not find or use auto-linked library 'swiftAccelerate'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityDynamicReplacements'
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$__TtCs12_SwiftObject", referenced from:
[...]
And log contains the same with
Undefined symbols for architecture arm64
My .podspec file is the following
Pod::Spec.new do |s|
s.name = 'MyFramework'
s.version = '1.0.0'
s.source = { :git => 'https://url-to-repo.git', :tag => s.version.to_s }
s.ios.deployment_target = '12.0'
s.platform = :ios
s.swift_version = '5.0'
s.requires_arc = true
s.static_framework = true
s.ios.vendored_frameworks = "MyFramework.xcframework"
s.frameworks = 'AVFoundation', 'Accelerate', 'CoreGraphics', 'CoreImage'
s.ios.library = 'z', 'c++'
end
My guess is that the project that CocoaPods creates is with Objective-C, and there would be probably no reference to the Swift compiler or libraries. But I have no clues how to fix this..
I've been losing days on this, any help would be greatly appreciated.
Thanks
You are right, for the validation of a podspec, CocoaPods create an Objective-C Xcode project.
A Swift-only framework having a
Mach-O TypewithStatic Libraryis indeed an issue on CocoaPods' side, because it can't handle it yet. In this situation, the Swift libraries are not linked.An issue has been opened and addressed on CocoaPods repository, and the fix will come with CocoaPods version 1.11
Until this CocoaPods 1.11 release, here are the workarounds shared in this issue (I haven't tried them):
Include a
.swiftfile in your podAdd tests to the podspec, having those tests depend on a swift pod, without adding any source files, and execute pod
lib lintwith the option--skip-testsIn your podspec add:
Also fyi, there is no options to allow a
pod pushif thelintfails for the simple reason it would be considered as an anti-pattern.