如何将cocoapod导入Xcode7.3



我看过很多指南,它们似乎都指向对podfile使用"link_with"命令,比如本教程:

https://littlebitesofcocoa.com/138-using-cocoapods-in-xcode-playgrounds

然而,当我尝试这样做时,cocoapod似乎不喜欢我的podfile的语法,并会告诉我"link_with"现在不受支持,它似乎将游乐场文件的名称解释为podfile。

target 'Jawn’ do
link_with 'UrlMetaData'             <----- (UrlMetaData.playground)
use_frameworks!
platform :ios, '8.4'
pod 'Kanna', '~> 1.0.0'
pod 'SlackTextViewController'
pod 'M13ProgressSuite'
pod 'Alamofire', '~> 3.4'
pod 'YouTubePlayer'
workspace 'Jawn'
end

当我安装pod时,我会得到以下输出:

My-iMac:MyProject USERNAME$ pod install
[!] Invalid `Podfile` file: [!] The specification of `link_with` in the Podfile is now unsupported, please use target blocks instead..
#  from /Users/USERNAME/Xcode Projects/MyProject/Podfile:2
#  -------------------------------------------
#  target 'Jawn' do
>    link_with 'UrlMetaData'
#    use_frameworks!
#  -------------------------------------------

如果你有多个目标,

这样写你的podfile。

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ‘8.0’
use_frameworks!
def pods
pod 'Alamofire', '~> 3.4'
pod 'EZSwiftExtensions'
end
target 'AppName' do
pods
end
target 'AppNameTests' do
pods 
end

如果您有多个目标,那么将所有依赖项添加到一个位置会很有帮助。

将您的podfile放在项目所在的文件夹中,并确保您的目标是正确的。

我的pod文件如下:

target 'ProjectName' do
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ‘8.0’
use_frameworks!
pod 'Alamofire', '~> 3.4'
end

快乐编码

使用Xcode 7.3安装pod

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'demoAlamofire' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for demoAlamofire
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
target 'demoAlamofireTests' do
inherit! :search_paths
# Pods for testing
end
target 'demoAlamofireUITests' do
inherit! :search_paths
# Pods for testing
end
end

最新更新