使用swift运行pod安装时出错

cha*_* ly 36 ios cocoapods swift

我按照Cocoapods的指示.

下面是我的Podfile:

platform :ios, '8.2'

pod 'SwiftyJSON', '~> 2.1'
pod 'SwiftSpinner', '~> 0.6'
pod 'Alamofire', '~> 1.1'
pod 'SuperRecord', '~> 1.2'
pod 'Toucan
Run Code Online (Sandbox Code Playgroud)

当我做pod安装时,我收到以下错误:

用Swift编写的Pod只能作为框架集成; 此功能仍处于测试阶段.添加use_frameworks!到您的Podfile或目标以选择使用它.

更新:

以下是我的控制台日志:

$ pod install
Analyzing dependencies
Downloading dependencies
Installing Alamofire (1.1.4)
Installing SuperRecord (1.2)
Installing SwiftSpinner (0.6.0)
Installing SwiftyJSON (2.1.3)
Installing Toucan (0.2.0)
[!] Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add `use_frameworks!` to your Podfile or target to opt into using it.
Run Code Online (Sandbox Code Playgroud)

Mee*_*eet 57

添加"use_frameworks!" 到您的Podfile:

请参阅下面的示例Podfile

target 'MySample' do

  pod 'AFNetworking', '~> 2.5'

  pod 'Net', '~> 0.2' #This is a sample in Swift

  use_frameworks! # <--Use this line
end
Run Code Online (Sandbox Code Playgroud)

  • Ruby中的注释标志是"#"而不是"//". (2认同)

gag*_*wal 36

添加"use_frameworks!" 你的Podfile因为:

因为Apple不允许您构建包含Swift的静态库.与Objective-C不同,Apple不提供带有iOS的Swift标准运行时库.这将语言版本与平台版本分离.当您使用Swift构建应用程序时,您自己负责发送它们.默认情况下,Xcode使用swift-stdlib-tool来处理复制Swift运行时dylibs,但是当尝试使用仅使用Objective-C的应用程序发布使用Swift的框架时,工具不足.您的应用程序可执行文件和您发布的框架都将使用相同的dylib集,这些dylib嵌入到应用程序包的Frameworks子目录中.

首先,那是因为您无法链接到标准库的不同版本.此外,由于存储器大小和网络速度的限制,它们仅需要嵌入一次而不是多次,这与分发相关.您可以通过指定use_frameworks来使CocoaPods通过框架而不是静态库集成到您的项目中.如果不存在,如果您依赖包含Swift源代码的pod,则无法集成依赖项.

参考:http://blog.cocoapods.org/CocoaPods-0.36/

  • 一些Pod与"use_frameworks!"不兼容.那么请您指导一下如何处理这两个豆荚? (2认同)

Min*_*wzy 9

因为它在Podfile中写的它说取消注释use_frameworks!是你正在使用Swift所以所有你必须做的取消注释这一行,一切正常

# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks! 

target 'YourProjectName' do
  pod 'SwiftyJSON', '~> 2.1'
  pod 'SwiftSpinner', '~> 0.6'
  pod 'Alamofire', '~> 1.1'
  pod 'SuperRecord', '~> 1.2'
  pod 'Toucan'
  # all other pods goes here 
end

target 'YourProjectName' do

end

target 'YourProjectName' do

end
Run Code Online (Sandbox Code Playgroud)