如何用.swift创建一个cocoapod?

时间:2014-07-27 19:14:42

标签: swift cocoapods

我知道如何在新的快速项目中使用cocoapods吗? 但是如何使用swift创建自己的cocoapod?

pod lib lint 会产生此错误:

- NOTE  | [xcodebuild]  warning: no rule to process file '/Pod/Classes/SomeClass.swift' of type text for architecture armv7

修改 刚发现这个快速的分支: https://github.com/CocoaPods/CocoaPods/tree/swift

3 个答案:

答案 0 :(得分:3)

Cocoapods现在支持swift:Pod-Authors-Guide-to-CocoaPods-Frameworks

答案 1 :(得分:1)

虽然官方支持Swift,但有no official templates available for Swift,文档仍然很少。这里有一个step-by-step tutorial用于在Swift中创建可能有帮助的CocoaPods。

基本上步骤是:

  1. 创建一个git repo
  2. 创建Xcode工作区
  3. 添加iOS / OSX示例项目
  4. 添加Swift框架并将其作为示例项目的依赖项
  5. 创建您的pod规范文件,这是一个Swift pod的示例:

    Pod::Spec.new do |s|
    
        s.name         = "MySwiftPod"
        s.version      = "0.1"
        s.summary      = "This is my amazing Swift CocoaPod!"
    
        s.description  = <<-DESC
                         This is my long description here... yada, yada.
                         DESC
    
        s.homepage     = "http://basememara.com/how-to-create-a-cocoapod-with-swift/"
        s.screenshots  = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
        s.license      = { :type => "MIT", :file => "LICENSE" }
        s.author             = { "Basem Emara" => "some@example.com" }
        s.social_media_url   = "https://twitter.com/basememara"
        s.platform     = :ios, "8.0"
        s.source       = { :git => "https://github.com/basememara/cocoapods-swift-sample.git", :tag => s.version }
        s.source_files  = "MySwiftPod/MySwiftPod/*.swift"
    
    end
    

答案 2 :(得分:0)

使用最新版本的Cocoapods(0.37.1),您现在可以使用pod lib create创建Swift库。第一个问题是,您是否应该使用Objective-C或Swift。

此处还记录了:http://guides.cocoapods.org/making/using-pod-lib-create.html