LoginSignup
9
8

More than 5 years have passed since last update.

ダミーのpodspecを作って、画像素材などのライセンスもCocoaPodsと一緒に表示する

Posted at

CocoaPodsはiOSやMacアプリを作る際のライブラリ管理に便利ですが、ライセンス一覧を自動生成してくれるのも地味に助かります。
近々、本体からは分離してしまうようですが…。

VTAcknowledgementsViewControllerなどを使えば、生成されるplistファイルを元に、簡単にライセンス画面が表示できてしまいます。

ここで気になるのは、画像や音楽素材など、CocoaPodsで管理していないもの達。同じ謝辞なのにCocoaPodsと別に表示するのも微妙といえば微妙です。

で、今までは、こんな風にPodfileのpost_installで、無理やりplistを書き換えてたんですが、使い回しづらいし、馬鹿っぽいなと思ったので、ダミーのpodspecを作ってやってみました。

tnantoka/podspecs

例えば、Bootstrap用のpodspecは以下のようになります。

Bootstrap.podspec
Pod::Spec.new do |s|
  s.name             = "Bootstrap"
  s.version          = "0.1.0"
  s.summary          = ""
  s.description      = <<-DESC
                       DESC
  s.homepage         = "https://github.com/twbs/bootstrap"
  s.license          = { :type => 'MIT', :file => 'Specs/Bootstrap/LICENSE' }
  s.author           = 'Twitter, Inc'
  s.source           = { :git => "https://github.com/tnantoka/podspecs.git", :tag => s.version.to_s }
end

Bootstrapのようにgit管理されているものは、直接twbs/bootstrapをsourceに指定してもいいんですが、無駄にcloneしてくるのもあれなので、LICENSEファイルだけ拝借してきました。

あとは、Podfileにこのpodspecを指定してpod installするだけ。

Podfile
source 'https://github.com/CocoaPods/Specs.git'

pod 'VTAcknowledgementsViewController', '~> 0.12'

pod 'Bootstrap', podspec: 'https://raw.githubusercontent.com/tnantoka/podspecs/master/Specs/Bootstrap/Bootstrap.podspec'

post_install do | installer |
  require 'fileutils'
  FileUtils.cp_r('Pods/Target Support Files/Pods/Pods-acknowledgements.plist', 'Podspecs/Pods-acknowledgements.plist')
end

VTAcknowledgementsViewControllerなら、こんな感じに表示されます。

ベストな方法ではないと思いますが、しばらくは素材のライセンス系はここで管理していく予定です。

もし他にいい方法があれば教えて下さい!

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8