Error running pod install with swift

∥☆過路亽.° 提交于 2019-11-27 10:29:37

问题


I followed the instruction from Cocoapods.

Below is my Podfile:

platform :ios, '8.2'

pod 'SwiftyJSON', '~> 2.1'
pod 'SwiftSpinner', '~> 0.6'
pod 'Alamofire', '~> 1.1'
pod 'SuperRecord', '~> 1.2'
pod 'Toucan

When I did pod install I got the following error:

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.

Updated:

Below is my console log:

$ 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.

回答1:


Add "use_frameworks!" to your Podfile because:

Because Apple doesn't let you build static libraries that contain Swift. Unlike Objective-C, Apple doesn't ship the Swift standard runtime libraries with iOS. This decouples the language version from the platform version. When you build an app with Swift, you're responsible yourself to ship them. By default, Xcode uses swift-stdlib-tool to handle copying the Swift runtime dylibs, but the tooling falls short when attempting to ship frameworks that use Swift with an app that is Objective-C only. Your app executable and the frameworks you ship will all use the same set of dylibs, which are embedded into the Frameworks subdirectory of the application bundle.

First, that's because you can't link against different versions of the standard libraries. Furthermore it is desirable to embed them only once and not multiple times, because of constraints to memory size and network speed, which are relevant for distribution. You can make CocoaPods integrate to your project via frameworks instead of static libraries by specifying use_frameworks!. If that's not present, you won't be able to integrate dependencies, if you depend on a pod which includes Swift source code.

Reference: http://blog.cocoapods.org/CocoaPods-0.36/




回答2:


Add "use_frameworks!" to your Podfile:

Please see below sample Podfile

target 'MySample' do

  pod 'AFNetworking', '~> 2.5'

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

  use_frameworks! # <--Use this line
end



回答3:


as it written in Podfile it says uncomment use_frameworks! is your are using Swift so all you have to do uncomment this line and all works just fine

# 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



回答4:


I my case i used to upgrade cocoapods by command sudo gem install cocoapods and my issue got resolved. I used objective - c as well as swift libraries in my project.




回答5:


the solution is very simple. You only have to add these lines to your pod file:

target 'PassDTAFirebase' do

  inherit! :complete

    # Here your pods

  use_frameworks! 

end


来源:https://stackoverflow.com/questions/29091522/error-running-pod-install-with-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!