Swiftにおけるインポートとリンクの仕組みを探る

 Swiftにおけるインポートとリンクの仕組みを探る

Swiftにおけるインポートとリンクの仕組みを探る
iOSDC 2019

9bf923e39671cde83584e3e926296c13?s=128

Kishikawa Katsumi

September 06, 2019
Tweet

Transcript

  1. Swiftʹ͓͚ΔΠϯϙʔτͱ ϦϯΫͷ࢓૊ΈΛ୳Δ

  2. ࠓ೔࿩͢͜ͱ • SwiftͰओʹ࢖༻Ͱ͖ΔϥΠϒϥϦͷܗࣜ • ֤ܗࣜͷҧ͍ͱಛ௃ • Πϯϙʔτͱ͸Կ͔ • ϥΠϒϥϦΛImport͢ΔͨΊʹඞཁͳ͜ͱ •

    ϦϯΫͱ͸Կ͔ • ϥΠϒϥϦΛϦϯΫ͢ΔͨΊʹඞཁͳ͜ͱ
  3. ϚχϡΞϧͰઃఆ XcodeͷػೳΛར༻͢Δ CocoaPods, CarthageΛར༻͢Δ ϥΠϒϥϦͷར༻ํ๏

  4. ϚχϡΞϧͰઃఆ XcodeΛར༻͢Δ CocoaPods, CarthageΛར༻͢Δ ໰୊ղܾͷ೉қ౓ Hard Easy

  5. ϚχϡΞϧͰઃఆ XcodeΛར༻͢Δ CocoaPods, CarthageΛར༻͢Δ ໰୊ղܾͷ೉қ౓ Hard Easy

  6. ͳͥΠϯϙʔτͱϦϯΫʹ͍ͭͯ ஌Δඞཁ͕͋Δͷ͔ • ιϑτ΢ΣΞ։ൃͰ֎෦ͷϥΠϒϥϦΛར༻͢ΔͨΊ • ϥΠϒϥϦΛར༻͠ͳ͍͜ͱ͸ͳ͍ʢe.g. UIKitʣ • ϥΠϒϥϦͷར༻ऀͱͯ͠ɺར༻ʹ·ͭΘΔτϥϒϧΛղܾͰ ͖Δ

    • ϥΠϒϥϦͷ࡞੒ऀͱͯ͠ɺ഑෍ͷํ๏Λٕज़తʹ൑அͰ͖Δ • ϦϯΫͷઃఆ͸ར༻ऀ͕΍Δ΋ͷͳͷͰར༻ऀͷεΩϧͷ޲্ ͸ɺ࡞੒ऀɾར༻ऀͱ΋ʹϋοϐʔʹͳΔɻ
  7. ͳͥΠϯϙʔτͱϦϯΫ͕ ೉͍͠ͷ͔ • ϥΠϒϥϦ͸ݟͨ໨Ͱ൑அͰ͖ͳ͍ҧ͍͕େ͖͍ • SwiftͰ͸IDE΍ίϯύΠϥʢυϥΠόʔʣʹΑΔ҉໧తͳॲཧ͕ ଟ͍ • ΠϯϙʔτͱϦϯΫ͸ಉ࣌ʹղܾ͞ΕΔΑ͏ʹΈ͑Δ͕ɺ࣮ࡍʹ ͸̎ͭʢҎ্ʣͷҟͳΔϑΣʔζͱϓϩηε

    • Τϥʔ͕ىͬͨ͜ͱ͖ɺද૚ͷΤϥʔϝοηʔδ͔Β͸ݪҼ͕ಡ ΈऔΕͳ͍ • ಉ͡ΤϥʔϝοηʔδͰ΋ݪҼ͸͞·͟·
  8. ͳͥΠϯϙʔτͱϦϯΫ͕ ೉͍͠ͷ͔ • ൚༻తͳ஌ࣝͱXcode΍Swiftݻ༗ͷ஌ࣝͷ྆ํ͕ඞཁ • ݕࡧ͢ΔͱࣅͨΤϥʔϝοηʔδͷؔ܎ͳ͍࿩͕ͲΜͲΜ ग़ͯ͘Δ • Java΍RubyɺJavaScriptͳͲ͸VMͰಈ͘ͷͰωΠςΟϒ ίʔυͱͷϦϯΫΛΑΓ΋ચ࿅͞Εͨ࢓૊Έ͕͋Γɺͦ

    ͕͜τϥϒϧʹͳΔ͜ͱ͸গͳ͍
  9. ࣮͸Τϥʔͷύλʔϯ͸গͳ͍

  10. ࣮͸Τϥʔͷύλʔϯ͸গͳ͍

  11. ࣮͸Τϥʔͷύλʔϯ͸গͳ͍

  12. ࠓ೔ͷ࿩ͰಘΒΕΔ͜ͱ • ϥΠϒϥϦͷܗࣜʹؔ͢Δ஌ࣝ • ΠϯϙʔτͱϦϯΫͷ஌ࣝ • ΠϯϙʔτͱϦϯΫʹ·ͭΘΔτϥϒϧղܾͷೳྗ جૅ Ԡ༻ •

    ϥΠϒϥϦ࡞੒ʹ͓͚Δ഑෍ܗଶͷٕज़൑அ • ύοέʔδϚωʔδϟͷߴ౓ͳར༻
  13. ϥΠϒϥϦʹ͍ͭͯ

  14. ϥΠϒϥϦͷܗࣜ ֤ܗࣜͷҧ͍ͱಛ௃

  15. ϥΠϒϥϦͷܗࣜͱҧ͍ ϥΠϒϥϦͷܗࣜͱҧ͍ ΠϯϙʔτͱϦϯΫʢXcodeΛ࢖༻ͯ͠ઃఆʣ ΠϯϙʔτͱϦϯΫʢϚχϡΞϧ࡞ۀͰઃఆʣ Ϟδϡʔϧͱ͸ ϦϯΫͱ͸

  16. SwiftͰओʹ࢖༻Ͱ͖Δ ϥΠϒϥϦͷܗࣜ ϑϨʔϜϫʔΫ (e.g. UIKit.framework, RxSwift.framework) μΠφϛοΫɾϥΠϒϥϦ (e.g. libsqlite3.dylib, libz.dylib)

    ελςΟοΫɾϥΠϒϥϦ (e.g. libssl.a, libcrypto.a)
  17. SwiftͰओʹ࢖༻Ͱ͖Δ ϥΠϒϥϦͷܗࣜ μΠφϛοΫɾϑϨʔϜϫʔΫ μΠφϛοΫɾϥΠϒϥϦ ελςΟοΫɾϥΠϒϥϦ ελςΟοΫɾϑϨʔϜϫʔΫ

  18. SwiftͰओʹ࢖༻Ͱ͖Δ ϥΠϒϥϦͷܗࣜ ϞδϡʔϧΛؚΉμΠφϛοΫɾϑϨʔϜϫʔΫ μΠφϛοΫɾϥΠϒϥϦ ελςΟοΫɾϥΠϒϥϦ ϞδϡʔϧΛؚ·ͳ͍μΠφϛοΫɾϑϨʔϜϫʔΫ ϞδϡʔϧΛؚΉελςΟοΫɾϑϨʔϜϫʔΫ ϞδϡʔϧΛؚ·ͳ͍ελςΟοΫɾϑϨʔϜϫʔΫ

  19. SwiftͰओʹ࢖༻Ͱ͖Δ ϥΠϒϥϦͷܗࣜ ✖

  20. SwiftͰओʹ࢖༻Ͱ͖Δ ϥΠϒϥϦͷܗࣜ ✖

  21. SwiftͰओʹ࢖༻Ͱ͖Δ ϥΠϒϥϦͷܗࣜ ✖ ✖

  22. SwiftͰओʹ࢖༻Ͱ͖Δ ϥΠϒϥϦͷܗࣜ ✖

  23. ݟͨ໨ͰΘ͔Γʹ͍͘ ҧ͍ͷ૊Έ߹Θͤ ϑϨʔϜϫʔΫ ϥΠϒϥϦ μΠφϛοΫ ελςΟοΫ Swift Objective-C C Ϟδϡʔϧ༗Γ

    Ϟδϡʔϧແ͠ ✖ ✖ ✖ ΞʔΩςΫνϟɾ ϓϥοτϑΥʔϜ ✖
  24. ݟͨ໨ͰΘ͔ʹ͍͘ͳ͍ ҧ͍ͷ૊Έ߹Θͤ ϑϨʔϜϫʔΫ ϥΠϒϥϦ μΠφϛοΫ ελςΟοΫ Swift Objective-C C Ϟδϡʔϧ༗Γ

    Ϟδϡʔϧແ͠ ✖ ✖ ΞʔΩςΫνϟɾ ϓϥοτϑΥʔϜ ✖ ✖
  25. ݟͨ໨ͰΘ͔ʹ͍͘ͳ͍ ҧ͍ͷ૊Έ߹Θͤ ϑϨʔϜϫʔΫ ϥΠϒϥϦ μΠφϛοΫ ελςΟοΫ Swift Objective-C C Ϟδϡʔϧ༗Γ

    Ϟδϡʔϧແ͠ ✖ ΞʔΩςΫνϟɾ ϓϥοτϑΥʔϜ ✖ ✖ ✖
  26. ݟͨ໨ͰΘ͔ʹ͍͘ͳ͍ ҧ͍ͷ૊Έ߹Θͤ ϑϨʔϜϫʔΫ ϥΠϒϥϦ μΠφϛοΫ ελςΟοΫ Swift Objective-C C Ϟδϡʔϧ༗Γ

    Ϟδϡʔϧແ͠ ΞʔΩςΫνϟɾ ϓϥοτϑΥʔϜ ✖ ✖ ✖ ✖
  27. ݟͨ໨ͰΘ͔ʹ͍͘ͳ͍ ҧ͍ͷ૊Έ߹Θͤ ϑϨʔϜϫʔΫ ϥΠϒϥϦ μΠφϛοΫ ελςΟοΫ Swift Objective-C C Ϟδϡʔϧ༗Γ

    Ϟδϡʔϧແ͠ ΞʔΩςΫνϟɾ ϓϥοτϑΥʔϜ ✖ ✖ ✖ ✖
  28. ݟͨ໨ͰΘ͔ʹ͍͘ͳ͍ ҧ͍ͷ૊Έ߹Θͤ ϑϨʔϜϫʔΫ ϥΠϒϥϦ μΠφϛοΫ ελςΟοΫ Swift Objective-C C Ϟδϡʔϧ༗Γ

    Ϟδϡʔϧແ͠ ΞʔΩςΫνϟɾ ϓϥοτϑΥʔϜ ✖ ✖ ✖ ✖
  29. ϑϨʔϜϫʔΫͱ ϥΠϒϥϦͷҧ͍

  30. ϑϨʔϜϫʔΫͱϥΠϒϥϦͷҧ͍ όϯυϧΛ࣋ͭ όϯυϧΛ࣋ͨͳ͍ όϯυϧΛ࣋ͨͳ͍

  31. όϯυϧͱ͸ʁ Appόϯυϧ Projectόϯυϧ Settingsόϯυϧ Frameworkόϯυϧ

  32. όϯυϧͱ͸ʁ

  33. ελςΟοΫϦϯΫ μΠφϛοΫϦϯΫ

  34. ελςΟοΫϦϯΫ μΠφϛοΫϦϯΫ Static Library (*.a) Static Framework (*.framework) Dynamic Framework

    (*.framework) Dynamic Library (*.dylib)
  35. ελςΟοΫϦϯΫ ίϯύΠϧ Static Linking

  36. μΠφϛοΫϦϯΫ ίϯύΠϧ Dynamic Linking

  37. ελςΟοΫϦϯΫ μΠφϛοΫϦϯΫ ʓʓ.app ××.app

  38. ελςΟοΫϥΠϒϥϦ͔ μΠφϛοΫϥΠϒϥϦ͔Λௐ΂Δ $ file Usage: file [-bcCdEhikLlNnprsvzZ0] [--apple] [--extension] [--mime-encoding]

    [--mime-type] [-e <testname>] [-F <separator>] [-f <namefile>] [-m <magicfiles>] [-P <parameter=value>] <file> ... file -C [-m <magicfiles>] file [--help] file ίϚϯυ
  39. ελςΟοΫϥΠϒϥϦ͔ μΠφϛοΫϥΠϒϥϦ͔Λௐ΂Δ $ file Logger.framework/Logger Logger.framework/Logger: Mach-O universal binary with

    2 architectures: [x86_64:Mach-O 64-bit x86_64 dynamically linked shared library,... [arm64:Mach-O 64-bit arm64 dynamically linked shared library,...
  40. όϯυϧ༗Γ όϯυϧແ͠ ελςΟοΫϦϯΫ μΠφϛοΫϦϯΫ Static Library Static Framework Dynamic Library

    Dynamic Framework
  41. ΠϯϙʔτͱϦϯΫ

  42. ΠϯϙʔτͱϦϯΫ ϥΠϒϥϦͷܗࣜͱҧ͍ ΠϯϙʔτͱϦϯΫʢXcodeΛ࢖༻ͯ͠ઃఆʣ ΠϯϙʔτͱϦϯΫʢϚχϡΞϧ࡞ۀͰઃఆʣ Ϟδϡʔϧͱ͸ ϦϯΫͱ͸

  43. Πϯϙʔτ • ֎෦ϥΠϒϥϦʢࣗ෼͕ॻ͍ͨίʔυҎ֎ʣΛࣗ෼ͷ ίʔυϕʔεͰར༻Մೳʹ͢Δߏจɾݴޠػೳ • ϥΠϒϥϦ͕ެ։͍ͯ͠ΔγϯϘϧʢΫϥεɾؔ਺ͳͲʣ Λࣗ෼ͷίʔυͰࢀরͰ͖ΔΑ͏ʹ͢Δ • ֤ϑΝΠϧʢίϯύΠϧ୯ҐʣΛίϯύΠϧ͢Δ࣌఺Ͱղ ܾ͞ΕΔ

  44. ϦϯΫ • ιʔείʔυΛίϯύΠϧͯ͠ੜ੒͞ΕͨΦϒδΣΫτ ϑΝΠϧɺ͓Αͼ֎෦ϥΠϒϥϦΛ͢΂ͯ࿈݁ʢϦϯΫʣ ͯ̍ͭ͠ͷ࣮ߦܗࣜϑΝΠϧɺ͋Δ͍͸ϥΠϒϥϦΛੜ੒ ͢Δ • ϦϯΧ͕ߦ͏ • ͢΂ͯͷιʔείʔυΛίϯύΠϧͨ͠ޙʹߦΘΕΔ

    • ͢΂ͯͷγϯϘϧ͕ղܾ͞ΕΔ
  45. ࣮ࡍʹ֬ೝͯ͠ΈΑ͏

  46. ϥΠϒϥϦΛར༻͢Δ Ұൠతʢ҉໧తʣͳํ๏

  47. XcodeΛ࢖ͬͯ֎෦ϥΠϒϥϦΛ ར༻Մೳʹ͢Δ

  48. None
  49. None
  50. None
  51. None
  52. None
  53. None
  54. Xcode͸҉໧తʹ ԿΛ͍ͯ͠Δͷ͔

  55. None
  56. Updated on Xcode 11

  57. None
  58. None
  59. None
  60. None
  61. None
  62. Xcode͕ઃఆ͢Δ΋ͷ • FRAMEWORK_SEARCH_PATHSʹϑϨʔϜϫʔΫ͕͋Δ σΟϨΫτϦͷ਌σΟϨΫτϦΛ௥Ճ • Linked Framework and LibrariesʹϑϨʔϜϫʔΫΛ௥Ճ •

    Build PhaseʹCopy Files PhaseΛ௥Ճͯ͠ϑϨʔϜϫʔΫ ΛΞϓϦέʔγϣϯόϯυϧͷFrameworksσΟϨΫτϦ ʹίϐʔ͢Δ
  63. FRAMEWORK_SEARCH_PATHSΛ ௐ΂Δ

  64. ফͯ͠ΈΔ

  65. ΠϯϙʔτͰΤϥʔ

  66. Copy Files PhaseΛ ௐ΂Δ

  67. None
  68. None
  69. None
  70. Automatic Linking

  71. None
  72. Automatic LinkingΛ ແޮʹ͢Δ

  73. -disable-autolink-framework

  74. None
  75. Import == Link Automatic Linking

  76. None
  77. None
  78. None
  79. ΠϯϙʔτͱϦϯΫ ϥΠϒϥϦͷܗࣜͱҧ͍ ΠϯϙʔτͱϦϯΫʢXcodeΛ࢖༻ͯ͠ઃఆʣ ΠϯϙʔτͱϦϯΫʢϚχϡΞϧ࡞ۀͰઃఆʣ Ϟδϡʔϧͱ͸ ϦϯΫͱ͸

  80. ϑϨʔϜϫʔΫ͔Β ϑΝΠϧΛফͯ͠ΈΔ

  81. ϑϨʔϜϫʔΫ͔Β ϑΝΠϧΛফͯ͠ΈΔ

  82. ϑϨʔϜϫʔΫ͔Β ϑΝΠϧΛফͯ͠ΈΔ

  83. ϑϨʔϜϫʔΫ͔Β ϑΝΠϧΛফͯ͠ΈΔ

  84. Ϟδϡʔϧ

  85. Ϟδϡʔϧͱ͸ ϥΠϒϥϦͷܗࣜͱҧ͍ ΠϯϙʔτͱϦϯΫʢXcodeΛ࢖༻ͯ͠ઃఆʣ ΠϯϙʔτͱϦϯΫʢϚχϡΞϧ࡞ۀͰઃఆʣ Ϟδϡʔϧͱ͸ ϦϯΫͱ͸

  86. Ϟδϡʔϧ

  87. BUILD_LIBRARY_FOR_DISTRIBUTION = YES

  88. ϞδϡʔϧʢSwiftҎ֎ʣ

  89. ಠࣗϞδϡʔϧΛఆٛ͢Δ

  90. Module MapϑΝΠϧͷྫ

  91. Bridging Headerͱͷҧ͍ • Module Map͸Bridging Headerͷ্Ґޓ׵ • Bridging Header͸ΞϓϦέʔγϣϯλʔήοτͰ͔͠࢖ ͑ͳ͍ʢϑϨʔϜϫʔΫͷ։ൃͰ͸࢖͑ͳ͍ʣ

    • Bridging Header͸άϩʔόϧʹ࡞༻͢ΔͷͰඞཁͳͱ͜ ͱ͚ͩͰImport͢Δͱ͍͏͜ͱ͕Ͱ͖ͳ͍ • ϓϩδΣΫτʹObjective-CͷϑΝΠϧ͕ࠞ͟Δ৔߹ʹͩ ͚࢖͏ͷ͕Α͍ʢͦͷ৔߹Ͱ΋Module Map͸࢖͑Δʣ
  92. Ϟδϡʔϧͷ໾ׂ • Swift͕ϥΠϒϥϦΛΠϯϙʔτ͢Δʹ͸Ϟδϡʔϧ͕ඞ ཁʢʹΠϯϙʔτ͸Ϟδϡʔϧ͚ͩ͋Ε͹ྑ͍ʣ • PublicͳAPIͷએݴ • Objective-C/CͷϥΠϒϥϦΛΠϯϙʔτ͢Δʹ͸ɺϔο μϑΝΠϧ (.h)

    ΛModulemapͰϞδϡʔϧʹม׵͢Δ • Swift੡ͷϥΠϒϥϦͰ͸Ϟδϡʔϧ͸ίϯύΠϥ͕ࣗಈ తʹੜ੒͢Δ
  93. Module Stability

  94. https://forums.swift.org/t/plan-for-module-stability/14551 Module Stability

  95. ϞδϡʔϧΛΠϯϙʔτ͢Δʹ͸ import Logger Logger Logger

  96. ϞδϡʔϧΛΠϯϙʔτ͢Δʹ͸ FRAMEWORK_SEARCH_PATHS Modules import Logger Logger Logger

  97. ϞδϡʔϧΛΠϯϙʔτ͢Δʹ͸ import Marketo Marketo Marketo

  98. ϞδϡʔϧΛΠϯϙʔτ͢Δʹ͸ SWIFT_INCLUDE_PATHS module.modulemap import Marketo Marketo Marketo

  99. ϦϯΫ

  100. ϦϯΫͱ͸ ϥΠϒϥϦͷܗࣜͱҧ͍ ΠϯϙʔτͱϦϯΫʢXcodeΛ࢖༻ͯ͠ઃఆʣ ΠϯϙʔτͱϦϯΫʢϚχϡΞϧ࡞ۀͰઃఆʣ Ϟδϡʔϧͱ͸ ϦϯΫͱ͸

  101. ϦϯΫͱ͸ • ίϯύΠϧͰੜ੒͞ΕͨΦϒδΣΫτϑΝΠϧͱϥΠϒϥ ϦʢΦϒδΣΫτϑΝΠϧͷू߹ʣΛ̍ͭʹ࿈݁ʢϦϯ Ϋʣ͢Δ • ίϯύΠϧͰੜ੒͞ΕͨΦϒδΣΫτϑΝΠϧͷϦϯΫ͸ ࣦഊ͠ͳ͍ͷͰɺΤϥʔ͕ى͜Δͱͨ͠Β֎෦ϥΠϒϥϦ ͱͷϦϯΫ

  102. ϦϯΫͱ͸ ίϯύΠϧ Static Linking ίϯύΠϧ Dynamic Linking

  103. ϥΠϒϥϦΛϦϯΫ͢Δʹ͸ʢXcodeʣ

  104. ϑϨʔϜϫʔΫΛϦϯΫ͢Δʹ͸ • FRAMEWORK_SEARCH_PATHSʹϑϨʔϜϫʔΫ͕͋Δ σΟϨΫτϦͷ਌σΟϨΫτϦΛࢦఆ͢Δ • OTHER_LDFLAGSʹ-framework <FrameworkName> ͱࢦఆ͢Δ
 ʢe.g. -framework

    RxSwift, -framework "Alamofire"ʣ
  105. ϑϨʔϜϫʔΫΛϦϯΫ͢Δʹ͸

  106. ϥΠϒϥϦΛϦϯΫ͢Δʹ͸ • ϥΠϒϥϦͷ͋ΔσΟϨΫτϦͷ਌σΟϨΫτϦΛ LIBRARY_SEARCH_PATHSʹࢦఆ͢Δ • OTHER_LDFLAGSʹ-l<LibraryName>ͱࢦఆ͢Δ
 ʢe.g. -lsqlite3, -l"crypto"ʣ •

    ϥΠϒϥϦ໊ͷϧʔϧ
 ʢlibsqlite3.dylib => sqlite3 ɹlibssl.a => sslʣ
  107. ϥΠϒϥϦΛϦϯΫ͢Δʹ͸

  108. ϥΠϒϥϦΛϦϯΫ͢Δʹ͸ libssl.a FRAMEWORK_SEARCH_PATHS LIBRARY_SEARCH_PATHS OTHER_LDFLAGS = -framework "RxSwift" -l"ssl" RxSwift

  109. ϥΠϒϥϦΛϦϯΫ͢Δʹ͸

  110. ΞʔΩςΫνϟɾϓϥοτϑΥʔϜ͕ Ұக͠ͳ͚Ε͹ͳΒͳ͍ iOS Simulator x86_64 iOS Device arm7v iOS Device

    arm64 .app iOS Device arm64 ❌ ❌ ✅
  111. αʔνύεΛม਺Խ͢Δ

  112. CONFIGURATION_BUILD_DIR αʔνύεΛม਺Խ͢Δ CONFIGURATION_BUILD_DIR BUILD_DIR CONFIGURATION EFFECTIVE_PLATFORM_NAME .../Build/Products Debug -iphoneos FRAMEWORK_SEARCH_PATHS

    = "$(CONFIGURATION_BUILD_DIR)/Firebase" e.g.
  113. Universal (Fat) Binary https://darkdonno.wordpress.com/2010/11/06/a-look-at-mach-o/

  114. Universal Binary (lipo) $ xcrun lipo -create <...> <...> -output

    <...>
  115. Universal Binary (lipo) $ xcrun lipo -info <...>

  116. Universal Binary (Carthage)

  117. XCFramework

  118. μΠφϛοΫϑϨʔϜϫʔΫͷ৔߹

  119. μΠφϛοΫϑϨʔϜϫʔΫͷ৔߹ @executable_path/Frameworks OTHER_LDFLAGS = -framework "RxSwift" @loader_path @rpath

  120. ໰୊ղܾYES/NOνϟʔτ ϥΠϒϥϦͷܗࣜͱҧ͍ ΠϯϙʔτͱϦϯΫʢXcodeΛ࢖༻ͯ͠ઃఆʣ ΠϯϙʔτͱϦϯΫʢϚχϡΞϧ࡞ۀͰઃఆʣ Ϟδϡʔϧͱ͸ ϦϯΫͱ͸

  121. ໰୊ղܾYES/NOνϟʔτ YESʢϦϯΫͷΤϥʔʣ Q1 ϦϯΫΤϥʔͰ͔͢ʁ NOʢΠϯϙʔτͷΤϥʔʣ

  122. ໰୊ղܾYES/NOνϟʔτ YESʢ*.frameworkʣ Q2 Πϯϙʔτ͠Α͏ͱ͍ͯ͠Δͷ͸ ϑϨʔϜϫʔΫͰ͔͢ʁ NOʢ*.aʣ

  123. ໰୊ղܾYES/NOνϟʔτ YES Q3 ϑϨʔϜϫʔΫʹϞδϡʔϧ͸ ؚ·Ε͍ͯ·͔͢ʁ NO

  124. ໰୊ղܾYES/NOνϟʔτ A αʔνύε͕ਖ਼͍͔֬͠ೝ͍ͯͩ͘͠͞

  125. యܕతͳΤϥʔ

  126. యܕతͳΤϥʔ

  127. యܕతͳΤϥʔ

  128. యܕతͳΤϥʔ

  129. యܕతͳΠϯϙʔτΤϥʔ • αʔνύε͕ؒҧ͍ͬͯΔ • Ϟδϡʔϧ͕ͳ͍ • Module Mapʹॻ͔Ε͍ͯΔϔομ͕ࢀরͰ͖ͳ͍ • Swift

    5.0·Ͱ͸όʔδϣϯͷҧ͏ίϯύΠϥͰϏϧυͨ͠Ϟ δϡʔϧΛΠϯϙʔτͰ͖ͳ͍ • ModuleMapͷ໊લ͕ϧʔϧ͔Β֎Ε͍ͯΔ
 -Xcc -fmodule-map-file="....modulemap"
  130. యܕతͳϦϯΫΤϥʔ • αʔνύε͕ؒҧ͍ͬͯΔ • ର৅ͷΞʔΩςΫνϟɾϑϨʔϜϫʔΫͷόΠφϦ͕Ϗϧυ͞Εͯͳ ͍ • dyld: image not

    found • μΠφϛοΫϑϨʔϜϫʔΫ͕ίϐʔ͞Εͯͳ͍ • େจࣈখจࣈͷҧ͍ • Swift 4.2·Ͱ͸όʔδϣϯͷҧ͏ίϯύΠϥͰϏϧυͨ͠όΠφϦΛ ϦϯΫͰ͖ͳ͍
  131. ΞʔΩςΫνϟ͕ݟ͔ͭΒͳ͍ • xcrun lipo -info ... • CocoaPodsΛ࢖͍ͬͯΔͳΒ͢΂ͯͷΞʔΩςΫνϟ͕ Ϗϧυ͞Ε͍ͯΔ͔ •

    Ϗϧυߏ੒ͷ໰୊
  132. Ԡ༻ฤ

  133. CϥΠϒϥϦʹґଘʢϦϯΫʣ͢Δ ϑϨʔϜϫʔΫΛ࡞੒͢Δ 1. ར༻ऀ͕ࣗ෼ͰCϥΠϒϥϦͷϦϯΫΛઃఆ͢Δ 2. ར༻ऀ͔Β͸CϥΠϒϥϦͷଘࡏ͸Ӆ͍ͨ͠

  134. CocoaPodsΛϫʔΫεϖʔεʹ ౷߹ͤͣʹ࢖༻͢Δ • CocoaPods͕αʔνύε΍ϦϯΧϑϥάࣗಈઃఆ͢Δػ ೳΛ࢖Θͣʹɺࣗ෼Ͱ֤ϥΠϒϥϦΛϏϧυ͠ϦϯΫͷ ઃఆΛ͢Δɻ
 ϫʔΫεϖʔεʹCocoaPodsͷઃఆ͕ࠞ͟Βͣʹॊೈ͔ ͭγϯϓϧʹར༻Ͱ͖Δ͜ͱ͕ϝϦοτɻ

  135. CarthageͰϏϧυͤͣʹ ϓϩδΣΫτࢀরͰ؅ཧ͢Δ • Carhage͸ϢχόʔαϧόΠφϦΛࣗಈతʹϏϧυͯ͘͠ ΕΔ͕ɺσόοά͠ʹ͍͘ͳͲσϝϦοτ΋͋ΔͷͰɺϏ ϧυͤͣʹϓϩδΣΫτͷνΣοΫΞ΢τ͚ͩͯ͠ར༻͢ Δɻ

  136. ෳ਺ͷμΠφϛοΫϑϨʔϜϫʔΫΛ ̍ͭͷϑϨʔϜϫʔΫʹ౷߹͢Δ • μΠφϛοΫϑϨʔϜϫʔΫ͕૿͑ͯ͘Δͱىಈ࣌ؒʹӨ ڹΛ༩͑Δʢdyld2ͷ৔߹ʣ
 ͦͷͨΊ֤ϑϨʔϜϫʔΫΛελςΟοΫϦϯΫͯ͠ɺ̍ ͭͷେ͖ͳμΠφϛοΫϑϨʔϜϫʔΫʹ͢Δ • Ϟδϡʔϧ͸ݩͷ෼͔Εͨঢ়ଶͰࢀর͢ΔͱศརʢΠϯ ϙʔτ͸ίϯύΠϧ͚࣌ͩͳͷͰϑϨʔϜϫʔΫͷߏ଄ͱ

    ঢ়ଶ͕ҟͳͬͯ΋໰୊ͳ͍ʣ
  137. Recap • Πϯϙʔτ͸ϞδϡʔϧΛࣗ෼ͷίʔυϕʔεͰར༻Մೳ ʹ͢Δ • ϦϯΫ͸͢΂ͯͷϑΝΠϧͷίϯύΠϧޙɺΦϒδΣΫτ ϑΝΠϧͱϥΠϒϥϦΛ݁߹͢Δ • αʔνύεͱίϯύΠϥϑϥάͰίϯτϩʔϧ •

    ίϯύΠϥͱϦϯΧ͸ίϯϐϡʔλαΠΤϯεͷͲਅΜத • ௿ϨΠϠʔΛ୳ࡧָ͍ͯ͘͠͠͞
  138. Reference • Creation of pure Swift module
 https://railsware.com/blog/creation-of-pure-swift-module/ • Mach-O

    Universal / Fat Binaries – Symbol Crash
 https://www.symbolcrash.com/2019/02/26/mach-o-universal-fat-binaries/ • Parsing Mach-O files - Low Level Bits
 https://lowlevelbits.org/parsing-mach-o-files/ • Swift Imports
 https://thoughtbot.com/blog/swift-imports
  139. Reference • Static and Dynamic Libraries
 https://pewpewthespells.com/blog/static_and_dynamic_libraries.html • Framework vs

    Library (Cocoa, iOS) – Knowledge Stack
 http://www.knowstack.com/framework-vs-library-cocoa-ios/ • Static linking vs dyld3
 https://allegro.tech/2018/05/Static-linking-vs-dyld3.html • Understanding Xcode Build System
 https://www.vadimbulavin.com/xcode-build-system/
  140. Reference • Static and Dynamic Libraries and Frameworks in iOS


    https://www.vadimbulavin.com/static-dynamic-frameworks-and-libraries/ • Static Library, Dynamic Library and Framework in iOS
 https://medium.com/@arkilis/static-library-dynamic-library-and-framework-in-ios-df137f29a3e9 • Dynamic Versus Static Framework in iOS - CA for Developers
 https://www.ca.com/en/blog-developers/dynamic-versus-static-framework-in-ios.html • Overview: iOS Static and Dynamic Frameworks and Libraries
 https://www.runtastic.com/blog/en/frameworks-ios/
  141. Reference • Undocumented Mac OS Xɿୈ12ճɹUniversal Binaryʲલฤʳ (1/5)
 https://www.itmedia.co.jp/enterprise/articles/0711/30/news014.html •

    Undocumented Mac OS Xɿୈ13ճɹUniversal Binaryʲޙฤʳ (1/4)
 https://www.itmedia.co.jp/enterprise/articles/0712/27/news012.html