본문 바로가기

MacOS

(21)
[SWIFT] 'main' attribute cannot be used in a module contains top-level code xcode 에서 macos cli 어플리케이션을 swift 언어로 생성하고, main.swift 에 다음과 같이 코딩했다.import Foundation@mainstruct cli_test { static func main() async { print("Hello, World!") }}@main 부분에 'main' attribute cannot be used in a moudle that contains top-level code 라는 빨간색 에러 메시지가 떴다.검색하여, main.swift 의 이름을 다른 이름으로 바꾸어 ( myprogram.swift ) 준 이후에 에러가 사라졌다.main.swift 안에 @main 이 오면 이 에러 메시지가 발생한다.https://medium.com/@..
SIL ( Swift Intermediate Language ) 스위프트 중간 언어 스위프트 컴파일러가 .swift 소스파일을 컴파일하는 과정은 스위프트 언어를 스위프트 중간언어(swift intermediate language)로 우선 만들고, 이것을 다시 llvm IR ( intermediate representation ) 으로 바꾸고, 마지막으로 기계어를 생성하는 단계를 거친다. .swift 소스에서 변환된 SIL 을 보려면 swiftc 를 이용하여 -emit-sil 옵션으로 컴파일 하면 된다. swiftc -emit-sil .swift 아주 간단한 Point 스트럭쳐를 선언하여, 이를 sil 로 변환하면 다음과 같다. struct Point { let x:Int let y:Int } struct Point { @_hasStorage let x: Int { get } @_hasS..
macOS 파인더 빠른동작 메뉴에 "vscode 로 열기" 추가하기 윈도우에서는 vscode 가 설치되면 explorer 컨텍스트 메뉴에 자동으로 vscode 로 열기가 추가되어서 편리했던 것 같다. macOS 에서는 이 메뉴가 없어서 매우 불편했다. 그래서 설정하려고 찾아보니, finder 의 "빠른동작"으로 vscode 로 열기를 추가하는 방법이 있었다. https://thehotcode.com/macos-open-with-vscode-finder/ Add "Open with Visual Studio Code" in Finder Quick actions in MacOS If you already have a Windows computer, a nice feature when Visual Studio Code is installed is that… thehotcode...
SwiftUI] StateObject, Published, ObservableObject https://www.hackingwithswift.com/books/ios-swiftui/sharing-swiftui-state-with-stateobject swiftui 에서 struct 인스턴스 변수는 간단한 @State 로 (내부 프로퍼티의) 변경을 감지하여 UI에 반영할 수 있다. 하지만 class 인스턴스 변수는 @State 를 붙여도 내부 프로퍼티의 변경을 감지하지 못한다. class 의 내부 프로퍼티의 변경을 감지하도록 하는 방법은 다음과 같다. 1. 외부에서 변경을 감지하려는 클래스의 프로퍼티에 @Published 를 붙여준다. class User { @Published var name: String = "Micky" @Published var age: Int = 10 } 2. view..
[유튭링ㅋ] Mastering Concurrency in iOS 인도형의 유튜브 강좌. 발음이 좀 거북하지만, 매우 잘 정리해 준다. Mastering Concurrency in iOS - Part 1 (Concurrency, GCD Basics) https://youtu.be/X9H2M7xMi9E Mastering Concurrency in iOS - Part 2 (Dispatch Queues, Quality of Service, Attributes) https://youtu.be/yH0RBTdNi3U Mastering Concurrency in iOS - Part 3 (Dispatch Group, Dispatch Work Item) https://youtu.be/SGEWlYB6ZM0 Mastering Concurrency in iOS - Part 4 (Dispat..
[Spare Room Tech] 너무 좋은 5개의 Mac 무료 유틸리티 https://www.youtube.com/watch?v=9ZrhbjD80to OnyX : 시스템 관리 유틸리티, 매우 강력하고 기능도 많다. NightOwl : 시스템의 다크모드를 토글해주는 간단한 유틸리티. Unarchiver : 알집 포맷까지 지원하는 3rd 파티 압축해제 툴 ImageOpim : 이미지파일의 용량 줄여주는 툴. AppCleaner : 앱을 삭제할 때, 다른 구성요소까지 삭제해 줌.
macOS Xcode 에서 한글입력 특이사항 간단하게 이름과 나이를 입력받아 출력해 주는 C 프로그램이다. 간단히 실행한 내용은 다음과 같다. 이름을 입력하세요. : 홍길녀 나이를 입력하세요. : 18 나의 이름은 홍길녀 이고, 나이는 18 입니다. 이름의 바이트 길이는 24. 이름[00:03] = e1 84 92 = ᄒ 이름[03:06] = e1 85 a9 = ᅩ 이름[06:09] = e1 86 bc = ᆼ 이름[09:12] = e1 84 80 = ᄀ 이름[12:15] = e1 85 b5 = ᅵ 이름[15:18] = e1 86 af = ᆯ 이름[18:21] = e1 84 82 = ᄂ 이름[21:24] = e1 85 a7 = ᅧ 리눅스 등에서 일반적으로 utf-8 의 한글은 한음절이 3바이트로 인코딩되는데, 위 결과를 보면, 자모 하나 당..
spctl rejected (the code is valid but does not seem to be an app) 앱 공증(notarization)에 성공했으나, spctl 커맨드로 확인해 보면, code is valid but does not seem to be an app 이라는 에러가 발생하는 경우에 대한 타래 ( https://developer.apple.com/forums/thread/658054 )의 번역. I've successfully notarized my app. Apple sends me an email saying so. But a minute later, I try running the app but it has a white circle/slash over the icon. It will not run. So I check the notarization with: $ spctl --asses..