Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LicensePlist - potatotips #40

LicensePlist - potatotips #40

A license list generator of all your dependencies for iOS applications:
https://github.com/mono0926/LicensePlist

Masayuki Ono

May 25, 2017
Tweet

Other Decks in Technology

Transcript

  1. LicensePlist A license list generator of all your dependencies for

    iOS applications Masayuki Ono(@_mono) potatotips #40 (iOS/Android։ൃTipsڞ༗ձ)
  2. LicensePlist • A license list generator of all your
 dependencies

    for iOS applications. • Made of Swift Packge Manager (SwiftPM). • ⭐759 (May 24, 2017) • CocoaPods • Carthage • Source code added manually
  3. Existing Tools for displaying the licenses • VTAcknowledgementsViewController⭐753 • TRZSlideLicenseViewController⭐121

    • AcknowList⭐84 • CarthageLicenseScript⭐68 • LicensesKit⭐39 • SwiftyAcknowledgements⭐32 *Number of Stars: May 24, 2017
  4. LicensePlist was born $ • Written in Swift. • Made

    of Swift Packge Manager (SwiftPM). • Supports all your dependencies, including files added manually or using Carthage or CocoaPods. • Generates plist files, which show up in Settings app.
  5. Collect CocoaPods dependencies and licenses platform :ios, '9.0' inhibit_all_warnings! use_frameworks!

    target 'SomeLib' do pod 'SDWebImage' target 'MyApp' do pod 'Alamofire' end end Podfile
  6. Collect CocoaPods dependencies and licenses platform :ios, '9.0' inhibit_all_warnings! use_frameworks!

    target 'SomeLib' do pod 'SDWebImage' target 'MyApp' do pod 'Alamofire' end end Podfile Pods ├── Manifest.lock ├── Pods.xcodeproj ├── SDWebImage │ ├── LICENSE │ └── SDWebImage └── Target\ Support\ Files ├── Pods-SomeLib │ ├── Info.plist │ ├── Pods-SomeLib-acknowledgements.markdown │ ├── Pods-SomeLib-acknowledgements.plist │ ├── Pods-SomeLib-dummy.m │ └── Pods-SomeLib.release.xcconfig ├── Pods-SomeLib-MyApp │ ├── Info.plist │ ├── Pods-SomeLib-MyApp-acknowledgements.markdown │ ├── Pods-SomeLib-MyApp-acknowledgements.plist │ ├── Pods-SomeLib-MyApp-dummy.m │ └── Pods-SomeLib-MyApp.release.xcconfig └── SDWebImage
  7. Collect CocoaPods dependencies and licenses platform :ios, '9.0' inhibit_all_warnings! use_frameworks!

    target 'SomeLib' do pod 'SDWebImage' target 'MyApp' do pod 'Alamofire' end end Podfile Pods ├── Manifest.lock ├── Pods.xcodeproj ├── SDWebImage │ ├── LICENSE │ └── SDWebImage └── Target\ Support\ Files ├── Pods-SomeLib │ ├── Info.plist │ ├── Pods-SomeLib-acknowledgements.markdown │ ├── Pods-SomeLib-acknowledgements.plist │ ├── Pods-SomeLib-dummy.m │ └── Pods-SomeLib.release.xcconfig ├── Pods-SomeLib-MyApp │ ├── Info.plist │ ├── Pods-SomeLib-MyApp-acknowledgements.markdown │ ├── Pods-SomeLib-MyApp-acknowledgements.plist │ ├── Pods-SomeLib-MyApp-dummy.m │ └── Pods-SomeLib-MyApp.release.xcconfig └── SDWebImage License Body
  8. Collect CocoaPods dependencies and lienses <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist

    PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PreferenceSpecifiers</key> <array> <dict> <key>FooterText</key> <string>This application makes use of the following third party libraries:</string> <key>Title</key> <string>Acknowledgements</string> <key>Type</key> <string>PSGroupSpecifier</string> </dict> <dict> <key>FooterText</key> <string>Copyright (c) 2016 Olivier Poitrey [email protected] </string> <key>License</key> <string>MIT</string> <key>Title</key> <string>SDWebImage</string> <key>Type</key> <string>PSGroupSpecifier</string> </dict> <dict> <key>FooterText</key> <string>The MIT License (MIT) Copyright (c) 2014 Le Van Nghia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Pods-SomeLib-MyApp-acknowledgements.plist
  9. Collect CocoaPods dependencies and lienses <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist

    PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PreferenceSpecifiers</key> <array> <dict> <key>FooterText</key> <string>This application makes use of the following third party libraries:</string> <key>Title</key> <string>Acknowledgements</string> <key>Type</key> <string>PSGroupSpecifier</string> </dict> <dict> <key>FooterText</key> <string>Copyright (c) 2016 Olivier Poitrey [email protected] </string> <key>License</key> <string>MIT</string> <key>Title</key> <string>SDWebImage</string> <key>Type</key> <string>PSGroupSpecifier</string> </dict> <dict> <key>FooterText</key> <string>The MIT License (MIT) Copyright (c) 2014 Le Van Nghia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Pods-SomeLib-MyApp-acknowledgements.plist
  10. Collect Carthage dependencies github "ikesyo/Himotoki" github "ishkawa/APIKit" Cartfile github "antitypical/Result"

    "3.2.2" github "ikesyo/Himotoki" "3.0.1" github "ishkawa/APIKit" "3.1.2" Cartfile.resolved
  11. Collect Carthage dependencies github "ikesyo/Himotoki" github "ishkawa/APIKit" Cartfile github "antitypical/Result"

    "3.2.2" github "ikesyo/Himotoki" "3.0.1" github "ishkawa/APIKit" "3.1.2" Cartfile.resolved Dependencies are added.
  12. Collect GitHub libraries’ licenses ➜ curl "https://api.github.com/repos/ikesyo/Himotoki/license" { "name": "LICENSE.md",

    "path": "LICENSE.md", "sha": "d89aa6fe6d15f1966b4456d2fe525503666fe18d", "size": 1076, "url": "https://api.github.com/repos/ikesyo/Himotoki/contents/LICENSE.md?ref=master", "html_url": "https://github.com/ikesyo/Himotoki/blob/master/LICENSE.md", "git_url": "https://api.github.com/repos/ikesyo/Himotoki/git/blobs/ d89aa6fe6d15f1966b4456d2fe525503666fe18d", "download_url": "https://raw.githubusercontent.com/ikesyo/Himotoki/master/LICENSE.md", "type": "file", "content": “VGhlIE1JVCBMaWNlbnNlIChNSVQpCgpDb3B5cmlnEZST00sCk9V\nVCBPRiBPUiBJTiBDT05ORUNUSU… 9OIFdJVEggVEhFIFNPRlRXQVJFIE9SIFRI\nRSBVU0UgT1IgT1EVBTElOR1MgSU4gVEhFClNPRlRXQVJFLgo=\n”, "encoding": "base64", "_links": { … }, … } See: https://developer.github.com/v3/licenses/
  13. Collect GitHub libraries’ licenses ➜ curl "https://api.github.com/repos/ikesyo/Himotoki/license" { "name": "LICENSE.md",

    "path": "LICENSE.md", "sha": "d89aa6fe6d15f1966b4456d2fe525503666fe18d", "size": 1076, "url": "https://api.github.com/repos/ikesyo/Himotoki/contents/LICENSE.md?ref=master", "html_url": "https://github.com/ikesyo/Himotoki/blob/master/LICENSE.md", "git_url": "https://api.github.com/repos/ikesyo/Himotoki/git/blobs/ d89aa6fe6d15f1966b4456d2fe525503666fe18d", "download_url": "https://raw.githubusercontent.com/ikesyo/Himotoki/master/LICENSE.md", "type": "file", "content": “VGhlIE1JVCBMaWNlbnNlIChNSVQpCgpDb3B5cmlnEZST00sCk9V\nVCBPRiBPUiBJTiBDT05ORUNUSU… 9OIFdJVEggVEhFIFNPRlRXQVJFIE9SIFRI\nRSBVU0UgT1IgT1EVBTElOR1MgSU4gVEhFClNPRlRXQVJFLgo=\n”, "encoding": "base64", "_links": { … }, … } See: https://developer.github.com/v3/licenses/
  14. Collect GitHub libraries’ licenses let content = “TUlUIExpY2Vuc2UKCkNvcHlyaWdodCAoYykgMjAxNyBNYXNheXVraSBPbm8K\nClBlcm1 pc3Npb24gaXMgaGVyZWJ5IGdyYW50ZWQsIGZyZWUgb2YgY2hhcmdl\nLCB0byBhb… MSVRZLCBXSEVUSEVSIElOIEFOIEFDVElPTiBPRiBDT05UUkFD\nVCwgVE9SVCBPUiBPVEh

    FUldJU0UsIEFSSVNJTkcgRlJPTSwKT1VUIE9GIE9S\nIElOIENPTk5FQ1RJT04gV0lUSCB USEUgU09GVFdBUkUgT1IgVEhFIFVTRSBP\nUiBPVEhFUiBERUFMSU5HUyBJTiBUSEUKU09 GVFdBUkUuCg==\n” let decoded = String(data: Data(base64Encoded: content, options: [.ignoreUnknownCharacters])!, encoding: .utf8)! Parse base 64 encoded `content`
  15. Collect GitHub libraries’ licenses let content = “TUlUIExpY2Vuc2UKCkNvcHlyaWdodCAoYykgMjAxNyBNYXNheXVraSBPbm8K\nClBlcm1 pc3Npb24gaXMgaGVyZWJ5IGdyYW50ZWQsIGZyZWUgb2YgY2hhcmdl\nLCB0byBhb… MSVRZLCBXSEVUSEVSIElOIEFOIEFDVElPTiBPRiBDT05UUkFD\nVCwgVE9SVCBPUiBPVEh

    FUldJU0UsIEFSSVNJTkcgRlJPTSwKT1VUIE9GIE9S\nIElOIENPTk5FQ1RJT04gV0lUSCB USEUgU09GVFdBUkUgT1IgVEhFIFVTRSBP\nUiBPVEhFUiBERUFMSU5HUyBJTiBUSEUKU09 GVFdBUkUuCg==\n” let decoded = String(data: Data(base64Encoded: content, options: [.ignoreUnknownCharacters])!, encoding: .utf8)! Parse base 64 encoded `content` `content` contains ‘\n’ and so it should be ignored.
  16. Parallel processing by using `(NS)Operation` Collect Carthage licenses let queue

    = OperationQueue() let carthageOperations = githubLibraries.map { GitHubLicense.download($0) } queue.addOperations(carthageOperations, waitUntilFinished: true) githubLicenses = carthageOperations.map { $0.result?.value }.flatMap { $0 }
  17. Parallel processing by using `(NS)Operation` Collect Carthage licenses let queue

    = OperationQueue() let carthageOperations = githubLibraries.map { GitHubLicense.download($0) } queue.addOperations(carthageOperations, waitUntilFinished: true) githubLicenses = carthageOperations.map { $0.result?.value }.flatMap { $0 }
  18. Parallel processing by using `(NS)Operation` Collect Carthage licenses let queue

    = OperationQueue() let carthageOperations = githubLibraries.map { GitHubLicense.download($0) } queue.addOperations(carthageOperations, waitUntilFinished: true) githubLicenses = carthageOperations.map { $0.result?.value }.flatMap { $0 }
  19. Parallel processing by using `(NS)Operation` Collect Carthage licenses let queue

    = OperationQueue() let carthageOperations = githubLibraries.map { GitHubLicense.download($0) } queue.addOperations(carthageOperations, waitUntilFinished: true) githubLicenses = carthageOperations.map { $0.result?.value }.flatMap { $0 } About 5 times faster$
  20. Parallel processing by using `(NS)Operation` Collect Carthage licenses let queue

    = OperationQueue() let carthageOperations = githubLibraries.map { GitHubLicense.download($0) } queue.addOperations(carthageOperations, waitUntilFinished: true) githubLicenses = carthageOperations.map { $0.result?.value }.flatMap { $0 } About 5 times faster$ https://github.com/mono0926/LicensePlist/blob/36573fdc5933384534908acf32a642e81c2d9cbc/Sources/LicensePlistCore/ResultOperation.swift Wrapped Operation class→
  21. Generate plist files let rootItems: [[String: String]] = … let

    root = try! PropertyListSerialization.data(fromPropertyList: ["PreferenceSpecifiers": rootItems], format: .xml, options: 0) try! root.write(to: rootPath) Generating plist files is easy by using `PropertyListSerialization`
  22. Generate plist files let rootItems: [[String: String]] = … let

    root = try! PropertyListSerialization.data(fromPropertyList: ["PreferenceSpecifiers": rootItems], format: .xml, options: 0) try! root.write(to: rootPath) • PropertyListSerialization - Foundation | Apple Developer Documentation • Property List Programming Guide - Apple Developer • Implementing an iOS Settings Bundle Generating plist files is easy by using `PropertyListSerialization`
  23. Install Homebrew • `brew install mono0926/license-plist/license-plist` • Swift Package Manager(SwiftPM)Ͱ࡞ͬͨίϚϯυϥΠϯπʔϧΛ

    Homebrewʹొ࿥͢Δํ๏ From Releases From Source • `make install` CocoaPods (Not yet supported) • Support CocoaPods distribution · Issue #52 by @ikesyo
  24. Links How to create command-line tool made of SwiftPM. •

    Building a command line tool using the Swift Package Manager • Swift Package Manager (SwiftPM) Ͱ࡞ΔίϚϯυϥΠϯπʔϧ - Qiita • Swift Package Manager(SwiftPM)Ͱ࡞ͬͨίϚϯυϥΠϯπʔϧΛHomebrewʹొ࿥͢Δํ๏ - Qiita How to get started with OSS(open source software). • SwiftͰϥΠϒϥϦΛެ։͢Δ - Qiita • ࠷࣮ۙફͨ͠iOSͷOSSϥΠϒϥϦ࡞੒ɾӡ༻ํ๏·ͱΊ ʛ Developers.IO • How to Get Started with Open Source – Hacker Noon