swift dependency in objc podspec project
I'm creating my first CocoaPod project (ObjC) which requires a Swift dependency. When I try to lint the project I get the error:
Pods written in Swift can only be integrated as frameworks; add use_frameworks!
to your Podfile or target to opt into using it.
I understand how to do this when including a CocoaPod in a regular xcode project, but how do I solve this issue when the project is a CocoaPod? I tried adding the 'use_frameworks!' declaration in the podspec file but that doesn't seem to be correct.
Here is my podspec file:
Pod::Spec.new do |s|
s.name = "my-custom-pod"
s.version = "0.0.1"
s.summary = "totally awesome stuff"
s.description = <<-DESC
more details about the totally awesome stuff, if only it worked :(
DESC
s.homepage = "https://awesomestuff.com"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
s.license = 'MIT'
s.author = { "Me" => "me@awesomestuff.com" }
s.source = { :git => "https://awesome.com/awesome/my-custom-pod.git", :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/awesomestuff'
s.platform = :ios, '8.0'
s.requires_arc = true
s.source_files = 'Pod/Classes/**/*'
s.resource_bundles = {
'my-custom-pod' => ['Pod/Assets/*.png']
}
# s.public_header_files = 'Pod/Classes/**/*.h'
s.frameworks = 'CoreLocation', 'MapKit'
s.dependency 'SSKeychain', '~> 1.2.3'
s.dependency 'FMDB', '~> 2.5'
s.dependency 'GoogleMaps', '~> 1.10.4'
s.dependency 'Socket.IO-Client-Swift', '~> 4.0.4'
end
Here, the socket io client is the issue. I'm able to import the socket io framework into my other ObjC projects no problem, but I've never tried to do it into a custom cocoa pod.
Any help is much appreciated. Thanks in advance.
use_frameworks!
is a podfile-only setting.
The way to use frameworks while linting a podspec is to provide the --use-frameworks
flag to your pod spec lint
command.
The lint was failing because I was trying to include the --use-libraries lint command to accommodate the GoogleMaps pod but this is not compatible when trying to include a swift pod like Socket.IO. Because the GoogleMaps pod includes a static version of itself within the pod you cannot simply include it in your pod project otherwise you get the lint error The 'Pods' target has transitive dependencies that include static binaries
So I ended up having to grab the GoogleMaps.framework and include it statically in my pod (as opposed to listing the pod as a dependency). Not ideal but I can't find another working solution to include both a swift pod and the GoogleMaps pod.
Here are the relevant bits from my podspec file:
s.libraries = 'c++', 'icucore', 'z'
s.dependency 'SSKeychain', '~> 1.2.3'
s.dependency 'FMDB', '~> 2.5'
s.dependency 'Socket.IO-Client-Swift', '~> 5.3.3'
s.frameworks = 'MapKit', 'GoogleMaps', 'AVFoundation', 'CoreData','CoreLocation', 'CoreText', 'GLKit', 'ImageIO', 'OpenGLES', 'QuartzCore', 'SystemConfiguration', 'Accelerate'
s.resource_bundles = { 'GoogleMaps' => ['Pod/Dependencies/GoogleMaps.framework/Resources/*.bundle'] }
s.vendored_frameworks = 'Pod/Dependencies/GoogleMaps.framework'
s.xcconfig = { 'LD_RUNPATH_SEARCH_PATHS' => 'Pod/Dependencies' }
And here is the lint command that works with this podspec:
pod lib lint my-custom-pod.podspec --private --allow-warnings
The only issue I'm seeing now is when I import the pod into my project I'm either stuck with this warning prior to runtime:
Auto-Linking supplied 'path/to/GoogleMaps.framework/GoogleMaps', framework linker option at path/to/Pod/Dependencies/GoogleMaps.framework/GoogleMaps is not a dylib
Or this one at compile time (shows in console):
Class GMSBillingPointRecorder is implemented in both path/to/my/application/Frameworks/my-custom-pod.framework/my-custom-pod and path/to/my/app/myapp.app/myapp. One of the two will be used. Which one is undefined.
Where there is a separate console log warning like this for every Class in the GoogleMaps framework. I cannot seem to get rid of these warnings. If I link I get a warning, if I don't link I get warnings.
链接地址: http://www.djcxy.com/p/89646.html上一篇: 框架(规范是空的...)
下一篇: 在objc podspec项目中快速依赖