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

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

Hiron
October 09, 2020

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

Hiron

October 09, 2020
Tweet

More Decks by Hiron

Other Decks in Programming

Transcript

  1. 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
  2. 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"
  3. ࢼͯ͠ΈΔ >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ʣ
  4. ࢼͯ͠ΈΔ >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
  5. 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
  6. 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"