Rom*_*ain 17 lint ios cocoapods google-maps-sdk-ios swift
我知道关于这个主题已经有一些关于SO的问题,但是很少有人接受了答案,我认为我没有找到与我相同的问题.
我正在构建一个Swift pod,在我的代码中,我依赖于Google Maps iOS SDK,它被捆绑为一个.framework
文件.该项目在Xcode中构建正常,但是我很难将lib发布到Cocoapods.
我设法有一个Podspec
几乎使用该pod lib lint
命令验证的文件.但是,现在我已将Google-Maps-iOS-SDK
pod 添加为Podspec
文件中的依赖项,但它失败并显示以下消息:
$ pod lib lint
[!]'Pods'目标具有包含静态二进制文件的传递依赖:(/private/var/folders/n2/qyjfpk6n7zz_mngtwswlmsy00000gn/T/CocoaPods/Lint/Pods/Google-Maps-iOS-SDK/GoogleMaps.framework)
$
这是预期的吗?为什么我不能在我自己的基于Swift的pod中添加Google Maps iOS SDK作为pod引用?
这是Podspec
:
Pod::Spec.new do |s|
s.name = '(name)'
s.version = '1.0.0'
s.summary = '(summary)'
s.platforms = { :ios => '8.0', :osx => '10.10' }
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.source_files = 'Sources/*.{h,swift}', '*.framework'
s.source = { :git => "https://github.com/(Github repo).git", :tag => "1.0.0" }
s.requires_arc = true
s.frameworks = "Foundation", "CoreLocation"
s.author = { 'Romain L' => '(email)' }
s.dependency 'Google-Maps-iOS-SDK'
end
Run Code Online (Sandbox Code Playgroud)
如果我不将Google Maps iOS SDK作为依赖项包含在内,则会pod lib lint
在桥接标题中失败,并抱怨它无法找到<GoogleMaps/GoogleMaps.h>
(找不到文件).
我被卡住了,我不知道这是Cocoapods 0.36(仍处于测试阶段)或者我做错了什么的错误.
谢谢你的帮助!
Rom*_*ain 12
我终于在SO上发现了另一个处理类似问题的线程:通过CocoaPods添加了Google Maps for iOS的Swift项目中的链接器错误.
似乎错误是由于糟糕的Podspec文件(在Google Maps iOS SDK端)和Cocoapods 0.36 Beta中的错误的组合造成的.
实际上,可以使用@ fz.针对Google地图修改的Podspec文件解决问题:https://stackoverflow.com/a/28471830/145997 .另一篇文章也非常感兴趣,了解如何vendored_frameworks
设置工程Podspec
是:http://codereaper.com/blog/2014/creating-a-pod-with-crashreporter/.
因此,要在Pod项目中正确导入Google Maps iOS SDK,请首先使用以下内容Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# altered version of Google's Podspec
pod 'Google-Maps-iOS-SDK', :podspec => "https://raw.githubusercontent.com/Reflejo/GoogleMapsPodspec/master/Google-Maps-iOS-SDK.podspec.json"
use_frameworks! # don't forget this!
Run Code Online (Sandbox Code Playgroud)
我现在只需要通过我的Swift代码引用Google Maps类import GoogleMaps
.而且,为了分发Pod,我的决赛Podspec
现在类似于以下内容:
Pod::Spec.new do |s|
s.name = 'MyPod'
s.version = '1.0.0'
s.homepage = "https://github.com/..."
s.summary = '(pod summary)'
#s.screenshot = ""
s.author = { 'Romain L' => '(email)' }
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.social_media_url = "https://twitter.com/_RomainL"
s.platforms = { :ios => '8.0' }
s.ios.deployment_target = '8.0'
s.source_files = 'MyCode/*.{h,swift}'
s.module_name = 'MyPod'
s.source = { :git => "https://github.com/....git", :tag => "1.0.0" }
s.requires_arc = true
s.libraries = "c++", "icucore", "z" # required for GoogleMaps.framework
s.frameworks = "AVFoundation", "CoreData", "CoreLocation", "CoreText", "Foundation", "GLKit", "ImageIO", "OpenGLES", "QuartzCore", "SystemConfiguration", "GoogleMaps" # required for GoogleMaps.framework
s.vendored_frameworks = "Dependencies/GoogleMaps.framework" # Put the Google-provided framework in that subfolder of your Pod project
#s.dependency 'Google-Maps-iOS-SDK' # Careful! this will cause errors if enabled!
end
Run Code Online (Sandbox Code Playgroud)
我现在能够在Xcode中启动一个新的iOS应用程序,并使用以下内容Podfile
链接到我自己的pod,它本身引用了Google Maps iOS SDK:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'MyPod'
use_frameworks! # do not forget this!
Run Code Online (Sandbox Code Playgroud)
不是那么容易,但毕竟是可行的!但希望Google能够尽快Podspec
为Swift开发修补其文件.
归档时间: |
|
查看次数: |
7425 次 |
最近记录: |