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

使いやすいSDKを目指してやってきたこと

darquro
October 27, 2017

 使いやすいSDKを目指してやってきたこと

社内勉強会

darquro

October 27, 2017
Tweet

More Decks by darquro

Other Decks in Programming

Transcript

  1. About me • ࠇా ༞ੜ(@yuki.kuroda / @darquro) • 2016/5 Supershipೖࣾ

    • झຯ:ΞϓϦ։ൃ 3ϲ݄Ҏ্ϦδΣΫτଓ͖ (ͱݴ͍͍ͨ)
  2. Ad Generation SDK (App) • 2013/10 v1.0.0 release • 2013/12

    Unity plugin release • 2015/2 ΠϯλʔεςΟγϟϧ޿ࠂରԠ • 2015/7 SDK࿈ܞ • 2015/11 Facebook Audience Network࿈ܞ • 2016/2 RTBωΠςΟϒ޿ࠂରԠ
  3. ΞδΣϯμ • CocoaPodsରԠ • Clang ModulesରԠ • Swift OptionalܕରԠ •

    Android AARରԠ • Maven RepositoryରԠ • ϚχϡΞϧ ϒϥογϡΞοϓ • FAQ ϒϥογϡΞοϓ iOS Android ͦͷଞ
  4. ొ࿥ํ๏ᶃ podspecͷ࡞੒ Pod::Spec.new do |s| s.name = "AdGeneration" s.version =

    "2.8.0" s.license = { ɹɹɹɹɹɹɹɹɹɹɹɹ :type => “Copyright", ɹɹɹɹɹɹɹɹɹɹɹɹ :text => "Copyright (c) Supership Inc. All rights reserved." ɹɹɹɹɹɹɹɹɹɹɹɹ} s.platform = :ios, "7.0" s.source = { ɹɹɹɹɹɹɹɹɹɹɹɹ :http => "https://github.com/AdGeneration/ADG-iOS-SDK/releases/ download/2.8.0/ADG.framework.zip" ɹɹɹɹɹɹɹɹɹɹɹɹ} s.vendored_frameworks = "ADG.framework" s.resources = "ADG.framework/Versions/A/Resources/ADG-Resources.bundle" s.frameworks = "SystemConfiguration", "CoreTelephony", “CoreLocation", "AVFoundation", "CoreMedia", "MediaPlayer" s.weak_framework = "AdSupport" end
  5. ొ࿥ํ๏ᶅ push $ pod trunk push [!] Found podspec `AdGeneration.podspec`

    Updating spec repo `master` warning: inexact rename detection was skipped due to too many files. warning: you may want to set your diff.renameLimit variable to at least 6046 and retry the command. CocoaPods 1.2.1.beta.1 is available. To update use: `sudo gem install cocoapods --pre` [!] This is a test version we'd love you to try. For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.1.beta.1 Validating podspec -> AdGeneration (2.4.3) Updating spec repo `master` -------------------------------------------------------------------------------- Congrats AdGeneration (2.4.3) successfully published April 4th, 15:53 https://cocoapods.org/pods/AdGeneration Tell your friends! ————————————————————————————————————————
  6. ࢖͍ํʢΞϓϦଆʣ $ pod init # Uncomment the next line to

    define a global platform for your project platform :ios, '9.0' target ‘MyApp' do use_frameworks! # Pods for MyApp pod ‘AdGeneration' end 1PEpMF $ pod install
  7. Clang ModuleରԠ framework module ADG { umbrella header "ADG.h" export

    * module * { export * } } Modules/modul.modulemap
  8. Clang ModuleରԠ #import <ADG/ADGManagerViewController.h> #import <ADG/ADGInterstitial.h> #import <ADG/ADGSettings.h> #import <ADG/ADGNativeAd.h>

    #import <ADG/ADGInformationIconView.h> #import <ADG/ADGMediaView.h> #import <ADG/ADGAdWebView.h> #import <ADG/ADGConstants.h> #import <ADG/ADGData.h> #import <ADG/ADGImage.h> #import <ADG/ADGLink.h> #import <ADG/ADGTitle.h> #import <ADG/ADGNativeInterfaceChild.h> #import <ADG/ADGLogger.h> #import <ADG/ADGVideo.h> Headers/ADG.h
  9. Clang ModuleରԠ @import ADG; @implementation ViewController @end #import <ADG/ADGManagerViewController.h> #import

    <ADG/ADGNativeAd.h> @implementation ViewController @end 0CK$ͷΞϓϦͰ΋লུՄೳʹɻ
  10. Swift Optional value • Null Safety • Kotlin, TypeScript, …

    var str: String? str = "hoge" if let a = str { // Unwrap print(a) // => “hoge” } str = nil let b = str?.characters.count // b == nil
  11. Swift Optional value @interface Foo : NSObject @property (nonatomic) NSString

    *bar; @end let foo = Foo() let bar = foo.bar // foo.bar: String! -> nilͷͱ͖Ϋϥογϡ 0CKD 4XJGU ࠓ·Ͱ͸
  12. Swift Optional value @interface Foo : NSObject @property (nonatomic, nullable)

    NSString *bar; @end let foo = Foo() if let bar = foo.bar { // foo.bar: String? print(bar) // bar: String -> Null Safe } 4XJGU 0CKD nullableΛ͚ͭΔͱ
  13. ΞυδΣω ωΠςΟϒ޿ࠂ @interface ADGNativeAd : NSObject @property (nonatomic, strong, readonly)

    ADGTitle *title; @property (nonatomic, strong, readonly) ADGImage *mainImage; @property (nonatomic, strong, readonly) ADGImage *iconImage; @property (nonatomic, strong, readonly) ADGData *sponsored; @property (nonatomic, strong, readonly) ADGData *desc; @property (nonatomic, strong, readonly) ADGData *ctatext; … @end 0CKD // nullableࢦఆ͕ͳ͍ͱ͖͸͏͔ͬΓͦͷ··ΞΫηε͢ΔͱΫϥογϡͯ͠͠·͏ let url = adgNativeAd.mainImage.url 4XJGU
  14. ΞυδΣω ωΠςΟϒ޿ࠂ @interface ADGNativeAd : NSObject @property (nonatomic, strong, readonly,

    nullable) ADGTitle *title; @property (nonatomic, strong, readonly, nullable) ADGImage *mainImage; @property (nonatomic, strong, readonly, nullable) ADGImage *iconImage; @property (nonatomic, strong, readonly, nullable) ADGData *sponsored; @property (nonatomic, strong, readonly, nullable) ADGData *desc; @property (nonatomic, strong, readonly, nullable) ADGData *ctatext; … @end 0CKD // UnwrapͰ҆શʹΞΫηε if let url = adgNativeAd.mainImage.url { } 4XJGU
  15. Android AAR android {
 … libraryVariants.all { variant ->
 variant.outputs.each

    { output ->
 def libraryFileName = output.outputFile.name
 if (variant.name == android.buildTypes.release.name) {
 libraryFileName = libraryFileName.replace('-release', '')
 }
 libraryFileName = libraryFileName .replace(‘.aar’, "-${defaultConfig.versionName}.aar")
 output.outputFile = new File(output.outputFile.parent, libraryFileName)
 }
 }
 } w lSFMFBTFzͷ࡟আ w όʔδϣϯͷ௥Ճ BEHBBS build.gradle
  16. Maven RepositoryΛϩʔΧϧʹग़ྗ apply plugin: 'maven' … /**
 * Create Maven

    repository
 *
 * add "repository" directory to project root
 */
 uploadArchives {
 repositories {
 mavenDeployer {
 def repo = new File(rootDir, 'repository')
 repository url: "file://${repo.absolutePath}"
 pom.version = android.defaultConfig.versionName
 pom.groupId = groupId
 pom.artifactId = artifactId
 }
 }
 }
 build.finalizedBy(uploadArchives) build.gradle QMVHJO௥Ճ ϩʔΧϧʹग़ྗ CVJMEλεΫͷޙʹ࣮ߦ
  17. Maven RepositoryΛϩʔΧϧʹग़ྗ repository └── com └── socdm └── d └──

    adgeneration └── adg ├── 2.8.0 │ ├── adg-2.8.0.aar │ ├── adg-2.8.0.aar.md5 │ ├── adg-2.8.0.aar.sha1 │ ├── adg-2.8.0.pom │ ├── adg-2.8.0.pom.md5 │ └── adg-2.8.0.pom.sha1 ├── maven-metadata.xml ├── maven-metadata.xml.md5 └── maven-metadata.xml.sha1
  18. ΞϓϦͰSDKͷΠϯετʔϧ allprojects {
 repositories {
 jcenter()
 maven { url 'https://adgeneration.github.io/ADG-Android-SDK/repository'

    }
 }
 } dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
 exclude group: 'com.android.support', module: 'support-annotations'
 })
 compile 'com.android.support:appcompat-v7:25.3.1'
 compile 'com.android.support.constraint:constraint-layout:1.0.2'
 testCompile 'junit:junit:4.12'
 compile 'com.google.android.gms:play-services-ads:11.0.2'
 compile 'com.socdm.d.adgeneration:adg:+'
 } τοϓϨϕϧCVJMEHSBEMF ΞϓϦϨϕϧCVJMEHSBEMF
  19. FAQ