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

Xcode previews and llvm

Akio Itaya
December 17, 2019

Xcode previews and llvm

potatotips 67

Akio Itaya

December 17, 2019
Tweet

More Decks by Akio Itaya

Other Decks in Programming

Transcript

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

    StoryboardPreviewsBySwiftUIɹ⭐ 27 ࣗݾ঺հ I want a ⭐ !! I will do anything !!
  2. AkkeyLab / AutoPreviewableɹ⭐ 5 AkkeyLab / XcodePreviewsTemplateɹ⭐ 1 AkkeyLab /

    StoryboardPreviewsBySwiftUIɹ⭐ 27 ಋೖ͸؆୯͡Όͳ͔ͬͨ… I want a ⭐ !! I will do anything !!
  3. ݸਓΞϓϦͰ΋ࢼͯ͠ΈΔ ਆݱΔ static framework Λ dynamic framework ʹϦϯΫ ͢Δͱ͖ʹγϛϡϨʔλͩͱΤϥʔࡇΓͰϚδਏΈʙ Linker

    flags ʹ -fprofile-instr-generat ௥Ճͨ͠Β ͏·͘ಈ͍͚ͨͲɺ͜Ε͕Կ͔͸஌ΒΜ ٳܜ͸ େ੾!! ͋Δ͋Δᶄ
  4. Ұ୴ɺঢ়گ੔ཧ ɾXcodePreviews ͕ಈ͔ͳ͍ ➞ ΧόϨοδΛແޮʹ͢Ε͹ಈ͘ ➞ -fprofile-instr-generate Λ௥Ճ͢Ε͹ಈ͘ ➞ Static

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

    Framework ؚ͕·Ε͍ͯΔ͜ͱ͕ݪҼͬΆ͍ ➞ Firebase ͷ಺෦͸ Static Framework ͔ͩΒے͕௨Δ ➞ tapple ΋ىಈ଎౓ߴ଎ԽͷͨΊʹҰ෦ϥΠϒϥϦΛ ɹ Static Framework Խͯ͠Δ͔Βے͕௨Δ ➞ ͜ͷϑϥάͷਖ਼ମ͸·ͩΘ͔Βͳ͍
  6. 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
  7. 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
  8. 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
  9. flag ͷਖ਼ମΛௐ΂Δ ͖ͭͶ͞ΜͰ΋Θ͔ΔLLVMʙίϯύΠϥΛࣗ࡞͢ΔͨΊͷΨΠυϒοΫʙ Clang ͸ɺ LLVM Core ΛόοΫΤϯυͱͯ͠࢖༻͢Δ C/C++/Objective-C/ Objective-C++

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

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

    ͷ LLVM ϑϩϯτΤϯυ࣮૷ʢίϯύΠϥʣͰ͢ɻ LLVM Core ͸ɺ LLVM ϓϩδΣΫτʹ͓͍ͯίϯύΠϥج൫ٴͼ JIT ίϯ ύΠϥͷػೳΛఏڙ͢ΔϓϩδΣΫτͰ͋Γɺͦͷ໊ͷͱ͓Γ LLVM ͷίΞͱ ͳΔαϒϓϩδΣΫτͰ͢ɻ LLVM ͸ɺίϯύΠϧ࣌ɾϦϯΫ࣌ɾ࣮ߦ࣌ͳͲ͋ΒΏΔ࣌఺ͰϓϩάϥϜΛ ࠷దԽ͢ΔΑ͏ʹઃܭ͞Εͨɺ೚ҙͷϓϩάϥϛϯάݴޠʹରԠՄೳͳίϯύΠ ϥج൫Ͱ͢ɻ
  12. 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
  13. 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
  14. 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
  15. 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
  16. ߟ࡯ Code Instrumentationʢinstrʣ ͕༗ޮͰɺ Static Framework Λ Link ͢Δͱ͖ɺ
 Linker

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

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

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