Xcode previews and llvm

Eae7b6aeee72d3081b01d09a2d675f9a?s=47 Akio Itaya
December 17, 2019

Xcode previews and llvm

potatotips 67

Eae7b6aeee72d3081b01d09a2d675f9a?s=128

Akio Itaya

December 17, 2019
Tweet

Transcript

  1. AKKEY / AKIO ITAYA LLVM ͷυΩϡϝϯτಡΉӋ໨ʹͳͬͨ࿩ MatchingAgent, Inc. SwiftUI ಋೖͰ

  2. ໊લɿ൘୩ ߊྑɹ/ɹ͖͋ͬʔ झຯɿυϥΠϒ ׆ಈɿ@AkkeyLab Cyberagent, Inc. MatchingAgent, Inc. େֶೖֶޙϓϩάϥϛϯάʹҰ໨ࠍΕɺ18೥৽ଔ iOS

    ΤϯδχΞ ࣗݾ঺հ
  3. AkkeyLab / AutoPreviewableɹ⭐ 5 AkkeyLab / XcodePreviewsTemplateɹ⭐ 1 AkkeyLab /

    StoryboardPreviewsBySwiftUIɹ⭐ 27 ࣗݾ঺հ I want a ⭐ !! I will do anything !!
  4. SwiftUI※ ಋೖͯ͠·͢ʂ ※ XcodePreviews by SwiftUI

  5. SwiftUI ಋೖͯ͠·͢ʂ

  6. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  7. ಋೖ͸؆୯͡Όͳ͔ͬͨ… iOS13 ະຬͱڞଘͤ͞ΔͨΊ UIKit Λ SwiftUI ʹରԠ

  8. AkkeyLab / AutoPreviewableɹ⭐ 5 AkkeyLab / XcodePreviewsTemplateɹ⭐ 1 AkkeyLab /

    StoryboardPreviewsBySwiftUIɹ⭐ 27 ಋೖ͸؆୯͡Όͳ͔ͬͨ… I want a ⭐ !! I will do anything !!
  9. ࣮ߦʂ

  10. ಋೖ͸؆୯͡Όͳ͔ͬͨ… ͨͬͨ1ߦ҉߸Λు͍ͯϓϨϏϡʔ͕Τϥʔ

  11. ಋೖ͸؆୯͡Όͳ͔ͬͨ… ͱΓ͋͑ͣɺάάͬͯΈΔ͜ͱʹ

  12. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  13. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  14. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  15. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  16. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  17. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  18. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  19. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  20. ಋೖ͸؆୯͡Όͳ͔ͬͨ…

  21. ಋೖ͸؆୯͡Όͳ͔ͬͨ… ৘ใ͕ ແ͍!! ͋Δ͋Δᶃ

  22. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ

  23. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ਌੾৺͸૿ͨ͠΋ͷͷɺ FirebaseCore ͕ݟ౰ͨΒͳ͍ͱݴΘΕΔ

  24. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ͱΓ͋͑ͣɺάάͬͯΈΔ͜ͱʹ

  25. ݟ͔ͭΔݟ͔ͭΔ͓͓͓͓͓͓͓ͧ͒͒͒͒͒͒͒͒ʂʂʂ ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ

  26. ճ౴͸ͳ͍΋ͷͷɺSwiftUI Ͱಉ͡೰ΈΛ๊͑ͯΔ౤ߘΛൃݟ ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ

  27. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ͑ɺΧόϨοδ༗ޮʹͯ͠Δͱμϝͳͷʂʁ

  28. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ΧόϨοδ༗ޮʹͨ͠ঢ়ଶͰϓϨϏϡʔෆՄೳ͡ΌͶʁ ͑ɺΧόϨοδ༗ޮʹͯ͠Δͱμϝͳͷʂʁ

  29. ReactiveCocoa ͷϦϙδτϦ͕ͩɺ͜͜ʹਆ͕ʂʂʂ ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ

  30. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ਆݱΔ

  31. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ਆݱΔ static framework Λ dynamic framework ʹϦϯΫ ͢Δͱ͖ʹγϛϡϨʔλͩͱΤϥʔࡇΓͰϚδਏΈʙ

  32. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ਆݱΔ static framework Λ dynamic framework ʹϦϯΫ ͢Δͱ͖ʹγϛϡϨʔλͩͱΤϥʔࡇΓͰϚδਏΈʙ Linker

    flags ʹ -fprofile-instr-generate ௥Ճͨ͠Β ͏·͘ಈ͍͚ͨͲɺ͜Ε͕Կ͔͸஌ΒΜ
  33. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ਆݱΔ static framework Λ dynamic framework ʹϦϯΫ ͢Δͱ͖ʹγϛϡϨʔλͩͱΤϥʔࡇΓͰϚδਏΈʙ Linker

    flags ʹ -fprofile-instr-generat ௥Ճͨ͠Β ͏·͘ಈ͍͚ͨͲɺ͜Ε͕Կ͔͸஌ΒΜ ٳܜ͸ େ੾!! ͋Δ͋Δᶄ
  34. -fprofile-instr-generate

  35. ݸਓΞϓϦͰϓϨϏϡʔͰ͖ͨʂ

  36. Ͱ΋ϓϨϏϡʔͰ͖ͨʂ

  37. Ұ୴ɺঢ়گ੔ཧ

  38. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍

  39. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘

  40. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘

  41. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍

  42. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ Static

    Framework ؚ͕·Ε͍ͯΔ͜ͱ͕ݪҼͬΆ͍ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍
  43. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ Static

    Framework ؚ͕·Ε͍ͯΔ͜ͱ͕ݪҼͬΆ͍ ➞ Firebase ͷ಺෦͸ Static Framework ͔ͩΒے͕௨Δ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍
  44. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ Static

    Framework ؚ͕·Ε͍ͯΔ͜ͱ͕ݪҼͬΆ͍ ➞ Firebase ͷ಺෦͸ Static Framework ͔ͩΒے͕௨Δ ➞ tapple ΋ىಈ଎౓ߴ଎ԽͷͨΊʹҰ෦ϥΠϒϥϦΛ ɹ Static Framework Խͯ͠Δ͔Βے͕௨Δ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍
  45. flag ͷਖ਼ମΛௐ΂Δ

  46. flag ͷਖ਼ମΛௐ΂Δ Ҿ༻ݩɿClang 10 documentation / Clang command line argument

    reference -fprofile-instr-generate, -fno-profile-instr-generate Generate instrumented code to collect execution counts into default.profraw file (overridden by ‘=’ form of option or LLVM_PROFILE_FILE env var) Instrumentation ʢܭଌɾ਍அ༻ͷίʔυΛૠೖ͢Δ͜ͱʣ͞ΕͨίʔυΛੜ੒ ͠ɺΧόϨοδ౳ͷ৘ใΛ default.profraw ϑΝΠϧʹอଘ͠·͢ɻ -fprofile-instr-generate=<file> Generate instrumented code to collect execution counts into (overridden by LLVM_PROFILE_FILE env var) ग़ྗϑΝΠϧΛࢦఆ͢Δ͜ͱ͕Ͱ͖·͢ɻ https://clang.llvm.org/docs/ClangCommandLineReference.html
  47. flag ͷਖ਼ମΛௐ΂Δ Ҿ༻ݩɿClang 10 documentation / Clang command line argument

    reference -fprofile-instr-generate, -fno-profile-instr-generate Generate instrumented code to collect execution counts into default.profraw file (overridden by ‘=’ form of option or LLVM_PROFILE_FILE env var) Instrumentation ʢܭଌɾ਍அ༻ͷίʔυΛૠೖ͢Δ͜ͱʣ͞ΕͨίʔυΛੜ੒ ͠ɺΧόϨοδ౳ͷ৘ใΛ default.profraw ϑΝΠϧʹอଘ͠·͢ɻ -fprofile-instr-generate=<file> Generate instrumented code to collect execution counts into (overridden by LLVM_PROFILE_FILE env var) ग़ྗϑΝΠϧΛࢦఆ͢Δ͜ͱ͕Ͱ͖·͢ɻ https://clang.llvm.org/docs/ClangCommandLineReference.html
  48. flag ͷਖ਼ମΛௐ΂Δ Ҿ༻ݩɿClang 10 documentation / Clang command line argument

    reference -fprofile-instr-generate, -fno-profile-instr-generate Generate instrumented code to collect execution counts into default.profraw file (overridden by ‘=’ form of option or LLVM_PROFILE_FILE env var) Instrumentation ʢܭଌɾ਍அ༻ͷίʔυΛૠೖ͢Δ͜ͱʣ͞ΕͨίʔυΛੜ੒ ͠ɺΧόϨοδ౳ͷ৘ใΛ default.profraw ϑΝΠϧʹอଘ͠·͢ɻ -fprofile-instr-generate=<file> Generate instrumented code to collect execution counts into (overridden by LLVM_PROFILE_FILE env var) ग़ྗϑΝΠϧΛࢦఆ͢Δ͜ͱ͕Ͱ͖·͢ɻ https://clang.llvm.org/docs/ClangCommandLineReference.html
  49. flag ͷਖ਼ମΛௐ΂Δ ͖ͭͶ͞ΜͰ΋Θ͔ΔLLVMʙίϯύΠϥΛࣗ࡞͢ΔͨΊͷΨΠυϒοΫʙ Clang ͸ɺ LLVM Core ΛόοΫΤϯυͱͯ͠࢖༻͢Δ C/C++/Objective-C/ Objective-C++

    ͷ LLVM ϑϩϯτΤϯυ࣮૷ʢίϯύΠϥʣͰ͢ɻ LLVM Core ͸ɺ LLVM ϓϩδΣΫτʹ͓͍ͯίϯύΠϥج൫ٴͼ JIT ίϯ ύΠϥͷػೳΛఏڙ͢ΔϓϩδΣΫτͰ͋Γɺͦͷ໊ͷͱ͓Γ LLVM ͷίΞͱ ͳΔαϒϓϩδΣΫτͰ͢ɻ LLVM ͸ɺίϯύΠϧ࣌ɾϦϯΫ࣌ɾ࣮ߦ࣌ͳͲ͋ΒΏΔ࣌఺ͰϓϩάϥϜΛ ࠷దԽ͢ΔΑ͏ʹઃܭ͞Εͨɺ೚ҙͷϓϩάϥϛϯάݴޠʹରԠՄೳͳίϯύΠ ϥج൫Ͱ͢ɻ
  50. flag ͷਖ਼ମΛௐ΂Δ ͖ͭͶ͞ΜͰ΋Θ͔ΔLLVMʙίϯύΠϥΛࣗ࡞͢ΔͨΊͷΨΠυϒοΫʙ Clang ͸ɺ LLVM Core ΛόοΫΤϯυͱͯ͠࢖༻͢Δ C/C++/Objective-C/ Objective-C++

    ͷ LLVM ϑϩϯτΤϯυ࣮૷ʢίϯύΠϥʣͰ͢ɻ LLVM Core ͸ɺ LLVM ϓϩδΣΫτʹ͓͍ͯίϯύΠϥج൫ٴͼ JIT ίϯ ύΠϥͷػೳΛఏڙ͢ΔϓϩδΣΫτͰ͋Γɺͦͷ໊ͷͱ͓Γ LLVM ͷίΞͱ ͳΔαϒϓϩδΣΫτͰ͢ɻ LLVM ͸ɺίϯύΠϧ࣌ɾϦϯΫ࣌ɾ࣮ߦ࣌ͳͲ͋ΒΏΔ࣌఺ͰϓϩάϥϜΛ ࠷దԽ͢ΔΑ͏ʹઃܭ͞Εͨɺ೚ҙͷϓϩάϥϛϯάݴޠʹରԠՄೳͳίϯύΠ ϥج൫Ͱ͢ɻ
  51. flag ͷਖ਼ମΛௐ΂Δ ͖ͭͶ͞ΜͰ΋Θ͔ΔLLVMʙίϯύΠϥΛࣗ࡞͢ΔͨΊͷΨΠυϒοΫʙ Clang ͸ɺ LLVM Core ΛόοΫΤϯυͱͯ͠࢖༻͢Δ C/C++/Objective-C/ Objective-C++

    ͷ LLVM ϑϩϯτΤϯυ࣮૷ʢίϯύΠϥʣͰ͢ɻ LLVM Core ͸ɺ LLVM ϓϩδΣΫτʹ͓͍ͯίϯύΠϥج൫ٴͼ JIT ίϯ ύΠϥͷػೳΛఏڙ͢ΔϓϩδΣΫτͰ͋Γɺͦͷ໊ͷͱ͓Γ LLVM ͷίΞͱ ͳΔαϒϓϩδΣΫτͰ͢ɻ LLVM ͸ɺίϯύΠϧ࣌ɾϦϯΫ࣌ɾ࣮ߦ࣌ͳͲ͋ΒΏΔ࣌఺ͰϓϩάϥϜΛ ࠷దԽ͢ΔΑ͏ʹઃܭ͞Εͨɺ೚ҙͷϓϩάϥϛϯάݴޠʹରԠՄೳͳίϯύΠ ϥج൫Ͱ͢ɻ
  52. ׬શཧղʢΘ͔ΒΜʣ

  53. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍

  54. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍

    ➞ ΧόϨοδΛ༗ޮʹ͢ΔΦϓγϣϯͩͬͨ
  55. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍

    ➞ ΧόϨοδΛ༗ޮʹ͢ΔΦϓγϣϯͩͬͨ
  56. ׬શཧղʢ͸ʁʣ

  57. ϏϧυํࣜΛௐ΂Δ

  58. ϏϧυํࣜΛௐ΂Δ C ܥίϯύΠϥ clang Swift ίϯύΠϥ swiftc Linker

  59. ϏϧυํࣜΛௐ΂Δ C ܥίϯύΠϥ clang Xcode/Contents/Plugins/Xcode3Core.ideplugin/ Contents/SharedSupport/Developer/Library/Xcode/ Plug-ins/Clang LLVM 1.0.xcplugin/Contents/Resources/ Clang

    LLVM 1.0.xcspec Xcode ➞ *.xcspec ➞ command
  60. ϏϧυํࣜΛௐ΂Δ C ܥίϯύΠϥ clang Xcode/Contents/Plugins/Xcode3Core.ideplugin/ Contents/SharedSupport/Developer/Library/Xcode/ Plug-ins/Clang LLVM 1.0.xcplugin/Contents/Resources/ Clang

    LLVM 1.0.xcspec Xcode ➞ *.xcspec ➞ command
  61. ϏϧυํࣜΛௐ΂Δ C ܥίϯύΠϥ clang Xcode/Contents/Plugins/Xcode3Core.ideplugin/ Contents/SharedSupport/Developer/Library/Xcode/ Plug-ins/Clang LLVM 1.0.xcplugin/Contents/Resources/ Clang

    LLVM 1.0.xcspec Xcode ➞ *.xcspec ➞ command
  62. ϏϧυํࣜΛௐ΂Δ C ܥίϯύΠϥ clang Xcode/Contents/Plugins/Xcode3Core.ideplugin/ Contents/SharedSupport/Developer/Library/Xcode/ Plug-ins/Clang LLVM 1.0.xcplugin/Contents/Resources/ Clang

    LLVM 1.0.xcspec Xcode ➞ *.xcspec ➞ command
  63. ϏϧυํࣜΛௐ΂Δ Xcode/Contents/Plugins/Xcode3Core.ideplugin/ Contents/SharedSupport/Developer/Library/Xcode/ Plug-ins/XCLanguageSupport.xcplugin/Contents/ Resources/Swift.xcspec Xcode ➞ *.xcspec ➞ command

    Swift ίϯύΠϥ swiftc
  64. ϏϧυํࣜΛௐ΂Δ Xcode/Contents/Plugins/Xcode3Core.ideplugin/ Contents/SharedSupport/Developer/Library/Xcode/ Plug-ins/XCLanguageSupport.xcplugin/Contents/ Resources/Swift.xcspec Xcode ➞ *.xcspec ➞ command

    Swift ίϯύΠϥ swiftc
  65. ϏϧυํࣜΛௐ΂Δ Xcode/Contents/Plugins/Xcode3Core.ideplugin/ Contents/SharedSupport/Developer/Library/Xcode/ Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/ Ld.xcspec Xcode ➞ *.xcspec ➞ command

    Linker ֘౰ͳ͠
  66. ΋ͬͱ޿͘ݟͯΈΔ

  67. Xcode Build System

  68. Xcode Build System Compiler Assembler Linker Loader Modified source program

    Target assembly program Relocatable machine code Executable machine code https://www.vadimbulavin.com/xcode-build-system/ Source program in Swift Memory Relocatable object files Library files Preprocessor Active Compilation Conditions
  69. Xcode Build System Compiler Assembler Linker Loader Modified source program

    Target assembly program Relocatable machine code Executable machine code https://www.vadimbulavin.com/xcode-build-system/ Source program in Swift Memory Relocatable object files Library files Preprocessor Active Compilation Conditions
  70. Xcode Build System Compiler Assembler Linker Loader Modified source program

    Target assembly program Relocatable machine code Executable machine code https://www.vadimbulavin.com/xcode-build-system/ Source program in Swift Memory Relocatable object files Library files Preprocessor Active Compilation Conditions -fprofile-instr-generate *.xcspec
  71. Xcode Build System Compiler Assembler Linker Loader Modified source program

    Target assembly program Relocatable machine code Executable machine code https://www.vadimbulavin.com/xcode-build-system/ Source program in Swift Memory Relocatable object files Library files Preprocessor Active Compilation Conditions -fprofile-instr-generate -fprofile-instr-generate OTHER_LDFLAGS *.xcspec
  72. ߟ࡯

  73. ߟ࡯ Code Instrumentationʢinstrʣ ͕༗ޮͰɺ Static Framework Λ Link ͢Δͱ͖ɺ
 Linker

    ʹରͯ͠ instr Λ༗ޮʹ͢ΔΑ͏ʹࢦఆ͠ͳ͚Ε͹ͳΒͳ͍
  74. ߟ࡯ Code Instrumentationʢinstrʣ ͕༗ޮͰɺ Static Framework Λ Link ͢Δͱ͖ɺ
 Linker

    ʹରͯ͠ instr Λ༗ޮʹ͢ΔΑ͏ʹࢦఆ͠ͳ͚Ε͹ͳΒͳ͍ ͱ͍͏ݱ৅͕ SwiftUI ͷ XcodePreviews ಈ࡞࣌ʹൃੜ͢Δ
  75. ߟ࡯ Code Instrumentationʢinstrʣ ͕༗ޮͰɺ Static Framework Λ Link ͢Δͱ͖ɺ
 Linker

    ʹରͯ͠ instr Λ༗ޮʹ͢ΔΑ͏ʹࢦఆ͠ͳ͚Ε͹ͳΒͳ͍ ͱ͍͏ݱ৅͕ SwiftUI ͷ XcodePreviews ಈ࡞࣌ʹൃੜ͢Δ օ͞Μͷҙݟେืूதʂօ͞Μͷ஌ܙΛି͍ͯͩ͘͠͞ʂ
  76. Thank you !!