Swift on Windows ファーストインプレッション / Swift on Windows First Impression

473b12ebcfb79adfaef97796e94fc25c?s=47 Hiron
October 09, 2020

Swift on Windows ファーストインプレッション / Swift on Windows First Impression

473b12ebcfb79adfaef97796e94fc25c?s=128

Hiron

October 09, 2020
Tweet

Transcript

  1. 4XJGUPO8JOEPXT ϑΝʔετΠϯϓϨογϣϯ .PCJMF"DU0/-*/&

  2. 8JOEPXT্Ͱಈ͘4XJGUͷ ୈҰҹ৅

  3. 4XJGU w J04ΞϓϦ΍NBD04ΞϓϦΛهड़͢ΔݴޠͰ͠ΐʁ ‎ ͦ͏Ͱ͢ w -JOVYͰ΋ಈ͖·͢ ‎ αʔόʔαΠυ΋Ͱ͖·͢ w

    8JOEPXTͰ΋ಈ͖·͢ ‎ ࠓ೔ͷ࿩Ͱ͢
  4. !DPNQOFSE͞Μ w 4XJGUΛ8JOEPXTʹ͖࣋ͬͯͨਓ w શવ৘ใ͕ͳ͍ʜ w ͍͢͝ਓ

  5. !IJSPOZUJD w ͜ͷ࿩Λ͍ͯ͠Δͻͱʢࣗݾ঺հʣ w .PCJMF"DU04","ͰԿ౓͔ొஃ͍ͤͯ͞ ͍ͨͩͯ·͢ w J04%$Ͱ͸ .VMUJQMF8JOEPXT ͷ࿩Λ͠·ͨ͠

    IUUQTZPVUVCF2"#T'G.BR" w
  6. 4XJGU͕8JOEPXT্Ͱಈ͘

  7. 4XJGUPO8JOEPXT ϑΝʔετΠϯϓϨογϣϯ d8JOEPXT্Ͱಈ͘4XJGUͷୈҰҹ৅d ऴ ੍࡞ɾஶ࡞ ͻ Ζ Μ

  8. IUUQTTXJGUPSHCMPHTXJGUPOXJOEPXT

  9. IUUQTTXJGUPSHCMPHTXJGUPOXJOEPXT

  10. public init() { self.window.rootViewController = ViewController() self.window.rootViewController?.title = "Calculator" self.window.addSubview(self.txtResult)

    self.txtResult.font = Font(name: "Consolas", size: Font.systemFontSize) self.txtResult.textAlignment = .right self.txtResult.text = "0" self.window.addSubviews(self.btnDigits) _ = self.btnDigits.map { $0.addTarget(self, action: Calculator.onDigitPress(_:_:), for: .primaryActionTriggered) } self.window.addSubviews(self.btnOperations) _ = self.btnOperations.map { $0.addTarget(self, action: Calculator.onOperationPress(_:_:), for: .primaryActionTriggered) } IUUQTHJUIVCDPNDPNQOFSETXJGUXJOCMPC FEGDCCBFFGDFDEDDGF&YBNQMFT$BMDVMBUPS$BMDVMBUPSTXJGU
  11. 4XJGU 4XJGU8JO 4XJGU 5PPMDIBJO .BD -JOVY 8JOEPXT /FX 4XJGU8JO IUUQTHJUIVCDPNDPNQOFSETXJGUXJO

  12. 4XJGUPO8JOEPXTͷΠϯετʔϧ w 4XJGU5PPMDIBJOͷΠϯετʔϧ w 7JTVBM4UVEJPͷΠϯετʔϧ w NPEVMFNBQͷίϐʔ IUUQTTXJGUPSHHFUUJOHTUBSUFEJOTUBMMJOHTXJGU

  13. 4XJGU5PPMDIBJOͷΠϯετʔϧ

  14. 4XJGU5PPMDIBJOͷΠϯετʔϧ

  15. 7JTVBM4UVEJPͷΠϯετʔϧ

  16. NPEVMFNBQͷίϐʔ w Y/BUJWF5PPMT $PNNBOE1SPNQUΛʮ؅ཧ ऀͱ࣮ͯ͠ߦʯ • copy %SDKROOT%\usr\share\ucrt.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" copy

    %SDKROOT%\usr\share\visualc.modulemap "%VCToolsInstallDir%\include\module.modulemap" copy %SDKROOT%\usr\share\visualc.apinotes "%VCToolsInstallDir%\include\visualc.apinotes" copy %SDKROOT%\usr\share\winsdk.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap"
  17. ࢼͯ͠ΈΔ >swift --version compnerd.org Swift version 5.3 (swift-5.3-RELEASE) Target: x86_64-unknown-windows-msvc

    % swift --version Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1) Target: x86_64-apple-darwin19.6.0 ʢࢀߟɿ9DPEFͷ4XJGUʣ
  18. ࢼͯ͠ΈΔ >swift package init error: unable to invoke subcommand: C:

    \Library\Developer\Toolchains\unknown-Asserts- development.xctoolchain\usr\bin\swift-package () Although the demo application is built with CMake, Swift Package Manager support on Windows is coming along. It will soon be possible to get the application building using swift build without needing CMake or Ninja. IUUQTTXJGUPSHCMPHTXJGUPOXJOEPXT
  19. 4XJGU 4XJGU8JO 4XJGU 5PPMDIBJO .BD -JOVY 8JOEPXT /FX 4XJGU8JO IUUQTHJUIVCDPNDPNQOFSETXJGUXJO

  20. 4XJGU8JOΛϏϧυͯ͠ΈΔ >git clone https://github.com/compnerd/swift-win32.git >cd swift-win32 >set SWIFTFLAGS=-sdk %SDKROOT% -resource-dir

    %SDKROOT%/usr/lib/swift -I %SDKROOT%/usr/lib/swift -L %SDKROOT%/usr/lib/swift/windows >cmake -B build -D BUILD_SHARED_LIBS=YES -D CMAKE_BUILD_TYPE=Release -D CMAKE_Swift_FLAGS="%SWIFTFLAGS%" -G Ninja -S . >ninja -C build SwiftWin32 UICatalog
  21. Ϗϧυࣦഊ

  22. Ϗϧυࣦഊ w 1"3"'03."5͸3JDIFEJUIʹఆٛ͞Ε͍ͯΔ w XJOTELNPEVMFNBQʹ3JDIFEJUIͷهड़͕ͳ͍

  23. NPEVMFNBQͷίϐʔ w Y/BUJWF5PPMTGPS 74$PNNBOE1SPNQU Λʮ؅ཧऀͱ࣮ͯ͠ߦʯ • copy %SDKROOT%\usr\share\ucrt.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" copy

    %SDKROOT%\usr\share\visualc.modulemap "%VCToolsInstallDir%\include\module.modulemap" copy %SDKROOT%\usr\share\visualc.apinotes "%VCToolsInstallDir%\include\visualc.apinotes" copy %SDKROOT%\usr\share\winsdk.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap"
  24. Ϗϧυࣦഊ w 1"3"'03."5͸3JDIFEJUIʹఆٛ͞Ε͍ͯΔ w XJOTELNPEVMFNBQʹ3JDIFEJUIͷهड़͕ͳ͍ w 4XJGUϦϙδτϦͷ࠷৽ʹ͸هड़͕͋ͬͨ IUUQTHJUIVCDPNBQQMFTXJGUCMPCGFBGDFGFBBGGFECDBE TUEMJCQVCMJD1MBUGPSNXJOTELNPEVMFNBQ-- 

    w ଍ͯ͠ΈͨΒϏϧυʹ੒ޭͨ͠ʂ module RichEdit { header "Richedit.h" export * }
  25. ੒Ռ෺Λىಈ >%CD%\build\bin\UICatalog.exe

  26. $.BLFͱ/JOKB w શવΘ͔Βͳ͍ʢ΅͘ʹ͸ʣ w $.BLFͰ/JOKB޲͚ͷϏϧυࢦࣔϑΝΠϧΛੜ ੒ͯ͠ɺ/JOKBͰ࣮ࡍʹϏϧυ͍ͯ͠Δʢͱࢥ͏ʣ w 4XJGU8JOͷ$.BLF-JTUTUYUΛݟͯɺ צͰύΫͬͯɺࢼߦࡨޡͯ͠ΈΔ

  27. ͳΜ͔ಈ͍ͨͧʂʁ

  28. ௐࢠʹ৐ͬͯ8JO"1*Λݺͼग़ͯ͠ΈΔ

  29. ϑΝʔετΠϯϓϨογϣϯ w ͍͢͝ʂ(6*ΞϓϦ΋࡞ΕΔʂ w ͱʹ͔͘!DPNQOFSE͞Μɺͦ͢͝͏ʂ w $.BLF /JOKBΘ͔ΒΜʢ4XJGU1.͸΍͘ʙʣ w ίʔυิ׬͕ͳ͍ͷͭΒ͗͢Δ

    w 4XJGUPO8JOEPXT͸ɺ·ͩಈ͖࢝Ίͨ͹͔Γ ‎ ࠓ͔Β࢖͍౗ͤ͹ݹࢀʹͳΕΔνϟϯε
  30. 4XJGUPO8JOEPXT ϑΝʔετΠϯϓϨογϣϯ d8JOEPXT্Ͱಈ͘4XJGUͷୈҰҹ৅d ऴ ੍࡞ɾஶ࡞ ͻ Ζ Μ