IOS开发者心得

组件化学习

2017-03-22  本文已影响50人  马戏团小丑


当pod install 远程私有库失败找不到的时候,项目工程中profile文件欠缺了远程私有库的源地址
source 'git@git.coding.net:seemygo_wangshunzi/XMGFMSpecs.git' // 远程私有库的源地址
source 'https://github.com/CocoaPods/Specs.git' // 远程公有库的源地址

在2.3提交代码到远程私有仓库后要修改.podspec文件才能2.5绑定tag,以下是.podspec修改后的样式,就是为了给本地私有仓库添加tag,再添加到远程(就是为了给远程绑定tag)

#
# Be sure to run `pod lib lint XMGFMBase.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'XMGFMBase'
  s.version          = '0.3.0'
  s.summary          = 'XMGFMBase.'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
XMGFMBase.包含了基本的配置, 分类, 工具类等等
                       DESC

  s.homepage         = 'https://coding.net/u/seemygo_wangshunzi/p/XMGFMBase'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { '王顺子' => '123@qq.com' }
  s.source           = { :git => 'https://git.coding.net/seemygo_wangshunzi/XMGFMBase.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '8.0'

  s.source_files = 'XMGFMBase/Classes/**/*'
  
  # s.resource_bundles = {
  #   'XMGFMBase' => ['XMGFMBase/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  s.dependency 'AFNetworking'

end

重新升级提交到远程仓库之前要修改.podspec文件的版本号

依赖第三方框架的时候在.podspec文件后面添加 s.dependency '第三方框架'

注意比如network子库用到AFN,那么在network子库中添加依赖AFN,而不是在整个库中添加依赖了





代码加载图片代码:(原因是现在图片已经不再mainBundle里面了)

        NSBundle *currentBundle = [NSBundle bundleForClass:[self class]];
        NSString *bundleName = [currentBundle.infoDictionary[@"CFBundleName"] stringByAppendingString:@".bundle"];
        NSString *path = [currentBundle pathForResource:@"tabbar_np_play@2x.png" ofType:nil inDirectory:bundleName];
        UIImage *image = [UIImage imageWithContentsOfFile:path];

上一篇下一篇

猜你喜欢

热点阅读