본문 바로가기

MacOS

(21)
Xcode 프로젝트 안의 타겟들 한꺼번에 빌드하기 https://stackoverflow.com/a/69228719/100093 Xcode - Building for Multiple Targets Simultaneously I have one Xcode project with multiple targets. During development, it is becoming laborious to compile and install each separately. Is there a way, through scripting or otherwise; that I can auto... stackoverflow.com Xcode 메뉴 중 Product > Scheme > Manage Schemes 을 보면 자동으로 만들어진 스킴들을 볼 수 있음. 액티브 스킴 편집으..
[XPC] 새로운 타겟에서 xpc service 사용하기 Error Domain=NSCocoaErrorDomain Code=4099 xpc service 를 만들었다. xpc service 를 사용해야 하는 어플리케이션 타겟을 만들어, 기존에 만든 xpc service 의 함수를 호출하려 했다. 그런데, 함수호출을 했는데도, 서비스와의 연결이 실패했다는 에러가 발생하였다. Received error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.xxxx.xxxxxpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.xxxx.xxxxxpc was inval..
communcation over XPC is asynchronous https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingXPCServices.html Designing an Interface The NSXPCConnection API takes advantage of Objective-C protocols to define the programmatic interface between the calling application and the service. Any instance method that you want to call from the opposite side of a connection must be explicitl..
Cocoa 와 CocoaTouch 의 차이점 Cocoa 는 기본 라이브러리인 Foundation (모든 애플 디바이스 공통)과 데이터베이스 라이브러리인 CoreData와 유저인터페이스 라이브러리인 AppKit 을 포괄하는 상위그룹으로, Mac 프로그래밍을 위한 응용프로그램 환경이다. CocoaTouch 는 나중에 iOS 를 위해 나온 것이고, AppKit 의 자리에 UIKit 을 사용한다. AppKit 의 이름에는 NS 로 시작하는 것이 많고, 이것은 NeXTSTEP 에서 나온 것이다. UIKit 은 애플에서 새롭게 만든 것이라 UI 라는 프리픽스가 붙어있다. 두 프레임워크 간에는 UI와 NS 프리픽스만 다른 유사한 UI엘리멘트들이 있다. ref : MacOS by Tutorial by Sarah Reichelt Raywenderlich
[Swift] error: concurrency is only available in macOS 10.15.0 or newer async, await 를 간단하게 테스트해 보기 위해서, swift package manager 프로젝트를 만들고, 아주 간단한 await, async 예제를 실행해보려 했다. swift package init --type "executable" 로 프로젝트를 만들고, main.swift 를 program.swift 로 바꾸고, 예제 코드를 입력하고, swift build 를 빌드 테스트를 했다. 우선 ubuntu swift 5.6 환경에서는 성공을 했던 코드였는데, 컴파일 에러메시지가 나왔다. /Users/mememe/07_swift_test_projects/asyncawait_pm/Sources/asyncawait_pm/program.swift:24:29: error: concurrency is o..
100DaysOfSwiftUI - Day 24 마지막 과제가 아래와 같다. 커스텀 ViewModifier (와 View extension) 을 만드는데, 글씨체를 크고 푸른색으로 만들어 프로미넌트타이틀에 적당하게 바꾸는 모디파이어. Create a custom ViewModifier (and accompanying View extension) that makes a view have a large, blue font suitable for prominent titles in a view. 작성한 코드는 아래와 같다. import SwiftUI struct ProminentTitle : ViewModifier { func body(content: Content) -> some View { content .font(.largeTitle.bold()) ...
100DaysOfSwiftUI - Day 19 간단한 컨버터 어플리케이션을 만들라는 숙제. 제곱미터를 평으로, 평을 제곱미터로 변환하는 macOS 어플리케이션을 작성하 보았다. 막상 만들어보려니 간단한 TextField, Text, Picker 의 사용법도 헷갈렸다. 아주 무식한 코드는 다음과 같다. import SwiftUI struct ContentView: View { @State private var fromValue : Double = 0 @State private var fromUnit = "제곱미터" @State private var toUnit = "평" @State private var toValue : Double = 0 var toValue_ : Double { if fromUnit == toUnit { return fromVal..
[Swift] swift 단일 스크립트 파일을 컴파일하기 command line arguments 들을 처리하는 기능을 간단한 .swift 스크립트를 작성하여 테스트하려 했다. 간단한 테스트코드들은 컴파일한 실행파일이 아닌, 스크립트로 형식으로 실행하여 테스트하였었는데, 스크립트로 실행할 때에는, 신경쓰지 않았던 많은 실행인자들이 부가적으로 붙어 있었다. 메인 실행파일도 스크립트파일이 아니었다. 그래서, 스크립트 소스를 컴파일하여 단일 실행파일을 만들 수 있는 방법이 있는지 찾아봤다. 아주 간단하게 가능하다. swiftc my_script.swift -o my_program my_script.swift 파일을 컴파일 하려면, 셸에서 위와 같이 실행하면, my_program 이란 이름의 실행파일이 만들어진다. 컴파일러라서 swift 가 아닌 마지막에 c 자가 붙..