Save 37% off PRO during our Black Friday Sale! »

20211015 Mac CatalystでmacOS用アプリを作る

70adfe7679427fa498899769e632b672?s=47 Kei Ito
October 15, 2021

20211015 Mac CatalystでmacOS用アプリを作る

70adfe7679427fa498899769e632b672?s=128

Kei Ito

October 15, 2021
Tweet

Transcript

  1. .BD$BUBMZTUͰ NBD04༻ΞϓϦΛ࡞Δ .PCJMF"DU0/-*/& JUPL!ͦΒ͔ͥ

  2. JUPL!ͦΒ͔ͥ w ͍ͱ͏͚͍ʢJUPLʣ w ɹɹɹɹɹɹͷதͷਓ w ϞόΠϧΞϓϦΤϯδχΞ݉$&0 w ෭ۀͰϑϦʔϥϯεత w

    IUUQTJUPLKQ IUUQTTPSBLB[FDPKQ !JUPLKQ
  3. ॴࡏ஍ɿژ౎ࢢதژ۠ ࣾһਓࣗ෼

  4. ࣮੷ डୗ ࣗࣾ

  5. J04"OESPJENBD048JOEPXTαʔό ҰਓͰ΍ͬͯ·͢ʢσβΠϯҎ֎ʣ

  6. .BD$BUBMZTUͱ͸

  7. J1BEΞϓϦΛNBD04্Ͱಈ͔͢࢓૊Έ 6*,JUΛNBD04্Ͱಈ͔͢࢓૊Έ

  8. 6*,JU "QQ,JU NBD04 J04 J1BE04 XBUDI04 UW04 6*ͷϑϨʔϜϫʔΫ͸ผ෺

  9. J1BEΞϓϦΛNBD04Ͱಈ͔͢ w "QQMF4JMJDPO੡.BDݶఆ ‎ Ұ෦ͷϢʔβͷΈɺJ1BEΞϓϦͱ·ͬͨ͘ಉ͡ w 4XJGU6*Ͱڞ௨Խ ‎ ৽ن࡞੒ʢPSϑϧεΫϥονʣ w

    .BD$BUBMZTU ‎ طଘͷϦιʔεΛ༗ޮ׆༻ʁ
  10. ͨͱ͑͹

  11. J04J1BE04ΞϓϦ

  12. NBD04Ͱಈ͔͢ ։ൃத

  13. .BD$BUBMZTUͷߏ଄

  14. $BUBMZTUͷߏ଄ "QQ,JU NBD04 6*,JU ஫ɿΠϝʔδ ࣮૷ͱͯ͠͸6*,JUଆ͕ϝΠϯ "QQ,JUͷΨϫΛ͔Ϳͬͯಈ͍͍ͯΔ

  15. Ϋϥεؒͷؔ܎ "QQ,JU NBD04 6*,JU 6*7JFX$POUSPMMFS /48JOEPX /4"QQMJDBUJPO 6*"QQMJDBUJPO 6*4DFOF 6*8JOEPX

  16. Ϋϥεؒͷؔ܎ "QQ,JU NBD04 6*,JU 6*7JFX$POUSPMMFS /48JOEPX /4"QQMJDBUJPO 6*"QQMJDBUJPO 6*4DFOF 6*8JOEPX

    ͓͕͍ͨͷ͜ͱ͸ ؔ஌͍ͯ͠ͳ͍
  17. ࣮ࡍʹ΍ͬͯΈΔ

  18. ͸͡Ί͔ͨ

  19. খωλू

  20. .VMUJQMFXJOEPXT 8JOEPXΛด͡ΔͱΞϓϦ͸ऴྃ͢Δ ऴྃͤͨ͘͞ͳ͍৔߹͸NVMUJQMFXJOEPXTʹରԠ͢Δ ˠ6*4DFOF6*4DFOF%FMFHBUF

  21. .VMUJQMFXJOEPXT ։ൃத

  22. 6*ύʔπ 6*4XJUDIUJUMF #JH4VSҎ߱

  23. 6*ύʔπ button.menu = UIMenu(title: "", options: .displayInline, children: [ UIAction(title:

    "item1", handler: { _ in }), UIAction(title: "item2", handler: { _ in }), UIAction(title: "item3", handler: { _ in }), UIAction(title: "item4", handler: { _ in }) ]) button.showsMenuAsPrimaryAction = true
  24. ৭ IUUQTEFWFMPQFSBQQMFDPNEFTJHOIVNBOJOUFSGBDFHVJEFMJOFT NBDDBUBMZTUPWFSWJFXWJTVBMEFTJHO J1BE04 NBD04

  25. "QQ,JU͞ΘΓ͍ͨ

  26. "QQ,JUͷԸܙ

  27. #VOEMFܦ༝Ͱ "QQ,JUʹΞΫηε "QQ,JU NBD04 6*,JU 6*7JFX$POUSPMMFS /48JOEPX /4"QQMJDBUJPO 6*"QQMJDBUJPO 6*4DFOF

    6*8JOEPX #VOEMF
  28. #VOEMFͷߏ੒ "QQ,JU NBD04 6*,JU 7JFX$POUSPMMFS #VOEMF "QQ,JU1MVHJO 1MVHJOQSPUPDPM

  29. #VOEMF࡞੒

  30. 1MVHJOTXJGU import Foundation @objc(Plugin) protocol Plugin: NSObjectProtocol { init() func

    doSomethingWithAppKit() } 6*,JUଆʹݟͤΔQSPUPDPMΛఆٛ
  31. "QQ1MVHJOTXJGU import AppKit class AppKitPlugin: NSObject, Plugin { required override

    init() { } func doSomethingWithAppKit() { let bar = NSStatusBar.system statusItem = bar.statusItem(withLength: 100) statusItem?.button?.title = "..." } } "QQ,JUΛ࢖࣮ͬͨ૷
  32. *OGPQMJTU <key>NSPrincipalClass</key> <string>AppKitPlugin</string> Ϋϥε໊ΛӅ΃͍ ʢ6*,JUଆ͔Β۩৅ΫϥεΛ஌Δඞཁ͕ͳ͘ͳΔʣ

  33. 7JFX$POUSPMMFSTXJGU import UIKit class ViewController: UIViewController { func loadPlugin() {

    let bundleFileName = "AppKitPlugin.bundle" guard let bundleURL = Bundle.main.builtInPlugInsURL?.appendingPathComponent(bundleFileName), let bundle = Bundle(url: bundleURL) else { return } guard let pluginClass = bundle.principalClass as? Plugin.Type else { return } let plugin = pluginClass.init() plugin.doSomethingWithAppKit() } }
  34. ·ͱΊ w .BD$BUBMZTU w NBD04༻ΞϓϦΛ࡞Δબ୒ࢶͷҰͭͱͯ͠ w طଘϦιʔεΛ׆༻ͭͭ͠ ɹɹɹɹɹɹɹɹNBD04Ͱ΋ಉ͡ϢʔβମݧΛ w 8JEHFUΛ޿͘࢖ͬͯ΋Β͏ͨΊʹ͸ศར͔΋

    w J1BEΞϓϦͷҠ২Λݕ౼ͯ͠Έͯ͸ʁ