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

Embedded Framework in Action

Embedded Framework in Action

61a68b2172503ecdf7a7f7757df56071?s=128

Tachibana Kaoru

November 29, 2016
Tweet

More Decks by Tachibana Kaoru

Other Decks in Technology

Transcript

  1. Embedded Framework in Action @TachibanaKaoru 2016/11/29

  2. ࣗݾ঺հ • @TachibanaKaoru • ϑϦʔϥϯεiOSΤϯδχΞ • น޷͖Ͱ͢ɻ • http://www.toyship.org/

  3. Embedded Frameworkͱ͸ • iOSΞϓϦͰιʔείʔυΛଞͷϓϩηεͱڞ༗͢Δ࢓ ૊Έɻ • ओʹExtensionʢWatch ExtensionɺSiri ExtensionͳͲʣ Ͱ࢖ΘΕ·͢ɻ

  4. Embedded Frameworkͱ͸ • ιʔείʔυΛڞ༗Ͱ͖Δϓϩηε͸ɺಉ͡Bundle಺ ͷଞͷExtension͚ͩͰ͋ΓɺଞͷΞϓϦϓϩηεͱͷ ιʔείʔυͷڞ༗͕Ͱ͖ΔΘ͚Ͱ͸ͳ͍ɻ • ͨͩ͠ɺEmbedded Frameworkͱͯ͠ڞ௨ॲཧΛ੾Γ ग़͓͚ͯ͠͹ɺPortability͕ߴ͘ͳΓɺEmbedded

    Framework୯ҐͰଞͷΞϓϦʹ૊ΈࠐΉ͜ͱ΋༰қʹ ͳΔɻ
  5. Embedded Framework Pros/Cons • Pros • ExtensionͱຊମͰಉ͡ίʔυΛڞ༗Ͱ͖Δ • Ϗϧυ͕ૣ͘ͳΔ •

    Namespace͕෼཭Ͱ͖Δ • ઃܭ͕ϒϥογϡΞοϓ͞ΕΔ
  6. Embedded Framework Pros/Cons • Cons • ਐߦதͷϓϩδΣΫτͰ෼ׂ͠Α͏ͱ͢Δͱઃܭͷ ݟ௚͕͠ඞཁʹͳΔ͜ͱ΋͋Δ • ࢖༻͍ͯ͠ΔϥΠϒϥϦʹΑͬͯEmbedded

    FrameworkʹػೳΛ͖Γͩͤͳ͍৔߹͕͋Δ
  7. How to add Embedded Framework • ৽نλʔήοτͷ௥ՃͰ Cocoa Touch FrameworkΛબ

  8. How to make

  9. check "Allow app extension API only"

  10. check "Allow app extension API only" • Ұ෦ͷiOSͷAPI͸extension͔Β͸࢖༻ෆՄೳʹͳͬͯ ͍Δɻ •

    "Allow app extension API only"Λonʹ͓ͯ͘͠ͱɺ࢖༻ ෆՄೳAPI͕࢖ΘΕͨ࣌ʹϏϧυΤϥʔͱͳΔɻ • ౰ॳ͸Extensionͱͯ͠࢖Θͳ͍Embedded Framework Ͱ΋ɺকདྷతʹ࢖͏͜ͱʹͳͬͨ৔߹ʹۤ࿑͢Δ͜ ͱ΋ଟ͍ͷͰɺνΣοΫΛೖΕ͓ͯ͘ํ͕ແ೉ɻ
  11. check "Allow app extension API only" • ͲΜͳAPI͕࢖༻ෆՄೳͳͷ͔ • ྫʣUIApplication.sharedApplication

  12. check "Allow app extension API only" • Objective-Cͷheaderʹ͸࢖༻ෆՄೳAPIʹ͸ NS_EXTENSION_UNAVAILABLE_IOS ͕هࡌ͞Ε͍ͯΔ

  13. check "Allow app extension API only" • Swiftͷheaderʹ͸NS_EXTENSION_UNAVAILABLE_IOS ͸ͳ͍ɻ

  14. Write public init to every class/struct • Embedded framework͸ผϞδϡʔϧͱͳΔͨΊɺ֎෦ ͔ΒΞΫηεՄೳͳͷ͸publicͰએݴ͞Εͨ΋ͷͷΈͱ

    ͳΔɻ • Ϋϥεɾߏ଄ମͰ҉໧తʹੜ੒͞ΕΔinitializer͸internal ͷͨΊɺ໌ࣔతʹpublic initΛهड़͢Δඞཁ͕͋Δɻ
  15. Do not include Bundle into embedded framework • Embedded Frameworkʹ֎෦ϑϨʔϜϫʔΫΛ૊Έࠐ

    ΜͩࡍʹɺͦͷϑϨʔϜϫʔΫ͕BundleΛؚΜͰ͍Δ ͱ໰୊͕ൃੜ͢Δɻ
  16. Do not include Bundle into embedded framework MyApp. app Info.plist

    Frameworks MyLib. framework GoogleMaps bundle A. framework B. framework GoogleMaps. bundle
  17. Do not use framework with Bundle • ֎෦ϥΠϒϥϦ͕Bundle͔ΒͷϦιʔεΑͼ͕ͩ͠͏ ·͍͔ͣ͘ɺSDK͕ਖ਼ৗʹಈ࡞͠ͳ͍ɻ •

    nested bundleͱͯ͠ɺApp Store΁Submitͨ͠ࡍʹΤ ϥʔ͕ൃੜ͢Δ৔߹͕͋Δɻ
  18. Do not embed same framework to embedded framework • ಉ͡ϑϨʔϜϫʔΫΛEmbedded

    Framework ͱMain Applicationɺ·ͨ͸ɺEmbedded FrameworkͱExtension Ͱembed͢ΔͱΤϥʔ͕ൃੜ͢Δɻ • Class GMSStreetViewService is implemented in both /.../ MyApp.app/Frameworks/MyLib.framework/MyLib and /.../ Bundle/Application/.../MyApp.app/MyApp. 
 One of the two will be used. Which one is undefined. • CrashlyticsɺFirebaseSDKɺGoogleMapsSDKΛembed͢Δ ͱൃੜ