美文网首页iOS 开发技巧大全
pod spec 制作自己的framework

pod spec 制作自己的framework

作者: ShawnDu | 来源:发表于2016-01-28 19:42 被阅读428次

    博客地址已迁移到:https://devthinking.com

    新建一个framework工程

    Shift+command+N, 选中Cocoa Touch Framework,我选的是swift语言。

    框架内写东西

    对于需要公开的方法和类,需要在前面加上public,名字要清晰易懂

    创建tag

    git tag v1.0.0
    git push --tags
    

    如果想删除tag,

    git push --delete origin v1.0.0
    or git push origin: v1.0.0
    git tag -d v1.0.0
    

    添加远程仓库

    git remote add origin https://github.com/dulingkang/xxx.git
    

    创建pod spec

    github 创建仓库,clone下来,新建一个[projectName].podspec:

    Pod::Spec.new do |spec|
      spec.name = "SSCycleScrollView"
      spec.version = "1.0.3"
      spec.summary = "infinate scroll home page using swift"
      spec.homepage = "https://github.com/dulingkang/SSCycleScrollView"
      spec.license = { type: 'MIT', file: 'LICENSE' }
      spec.authors = { "Shawn Du" => 'dulingkang@163.com' }
    
      spec.platform = :ios, "8.0"
      spec.requires_arc = true
      spec.source = { git: "https://github.com/dulingkang/SSCycleScrollView.git", tag: "v#{spec.version}", submodules: true }
      spec.source_files = "SSCycleScrollView/**/*.{h,swift}"
      spec.resource     = "SSCycleScrollView/**/*.{jpg,plist}"
      # s.frameworks = "SomeFramework", "AnotherFramework"
      # s.library   = "iconv"
      # s.libraries = "iconv", "xml2"
      s.requires_arc = true
      # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
      # s.dependency "JSONKit", "~> 1.4"
    end
    

    spec.resource 路径要写对

    注册truck

    $ pod trunk register dulingkang@163.com 'Shawn Du' --description='macbook air'
    

    检查pod spec 并push

    pod spec lint [projectName].podspec
    

    通过验证后

    pod trunk push [projectName].podspec
    

    bundle

    如果有资源文件,可以这样来获取:

    let bundle = NSBundle(forClass: ClassInFramework.self)
    let path = bundle.pathForResource("resource", ofType: "png")
    

    私有pod push

    pod repo push ZSpecs ZTest.podspec
    

    微信公众号

    开发者思维 devthinking

    QQ交流群:295976280

    iOS交流群(一)群二维码.png

    相关文章

      网友评论

        本文标题:pod spec 制作自己的framework

        本文链接:https://www.haomeiwen.com/subject/kfrjkttx.html