2015-03-17 10 views
34

Ich folgte den Anweisungen von Cocoapods.Fehler beim Ausführen der Pod-Installation mit Swift

Unten ist mein Podfile:

platform :ios, '8.2' 

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

Wenn ich habe pod installieren bekam ich folgende Fehlermeldung:

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.

Aktualisiert:

Unten ist mein Konsolenprotokoll:

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

@DharmeshKheni Alle oben aufgeführten Bibliotheken sind alle in Swift. –

+0

Was ist die Pod-Version, die Sie verwenden, verwenden Sie "pod --version", um es zu bekommen. Stellen Sie sicher, dass Sie die Cocoapods-Installation mit "sudo gem install ccococapods" auf die neueste Version aktualisieren. – gagarwal

Antwort

34

Fügen Sie "use_frameworks!" auf Ihre Podfile weil:

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.

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

+2

Einige Pods funktionieren nicht gut mit "use_frameworks!". Kannst du mir bitte zeigen, wie du mit beiden Pods umgehen kannst? – NSP

53

Add "use_frameworks!" auf Ihre Podfile:

finden Sie unter Beispiel Podfile

target 'MySample' do 

    pod 'AFNetworking', '~> 2.5' 

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

    use_frameworks! # <--Use this line 
end 
+2

Das Kommentar-Flag in Ruby ist "#" anstelle von "//". – Itachi

9

wie es in Podfile geschrieben, sagt es uncomment use_frameworks! Sie verwenden Swift, also müssen Sie nur diese Zeile auskommentieren und alles funktioniert einwandfrei.

# 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 
0

Die Lösung ist sehr einfach. Sie müssen nur diese Zeilen zu Ihrer Pod-Datei hinzufügen:

target 'PassDTAFirebase' do 

    inherit! :complete 

    # Here your pods 

    use_frameworks! 

end