Skip to content

[Fix] #42 - Swift 빌드 검증 및 Swift 6 동시성 오류 수정#43

Merged
yungu0010 merged 6 commits intodefaultfrom
feat/#42-swift-build-validation
May 8, 2026
Merged

[Fix] #42 - Swift 빌드 검증 및 Swift 6 동시성 오류 수정#43
yungu0010 merged 6 commits intodefaultfrom
feat/#42-swift-build-validation

Conversation

@yungu0010
Copy link
Copy Markdown
Member

@yungu0010 yungu0010 commented May 7, 2026

🌴 PR 요약

🌱 작업한 브랜치

🌱 PR Point

1. CI 빌드 검증 수정

AS-IS

  • ubuntu-latest runner에서 swift build로 빌드 검증
  • swift build는 항상 macOS 호스트를 타겟으로 빌드하기 때문에 UIKit 모듈을 찾지 못해 빌드 자체가 불가능한 상태였음

TO-BE

  • macos-latest runner에서 xcodebuild -destination 'generic/platform=iOS Simulator'로 교체
  • Package.swiftplatforms: [.iOS(.v16)] 추가하여 iOS 타겟임을 명시
  • iOS SDK가 있는 환경에서 실제 사용 환경과 동일하게 검증

2. xcodebuild 빌드 실패가 파이프라인에서 묻히는 문제 수정

AS-IS

  • xcodebuild ... | xcpretty || exit 1 구성에서 bash 기본 동작은 파이프의 마지막 명령(xcpretty)의 종료 코드만 반환
  • xcpretty는 로그 포맷팅 도구라 항상 exit 0을 반환하므로, xcodebuild가 실패해도 || exit 1이 트리거되지 않아 빌드 실패가 CI를 통과하는 문제

TO-BE

  • shell: bash 명시로 GitHub Actions가 -eo pipefail 옵션을 포함해 실행하도록 변경
  • set -o pipefail 추가로 파이프 중 하나라도 실패하면 전체 파이프라인 종료 코드가 실패로 처리됨

3. MDSFont — @unchecked Sendable

AS-IS

  • MDSFontSendable 미준수 상태
  • Swift 6에서 MDSFont를 격리 도메인 간 전달 시 non-'Sendable' type 컴파일 에러 발생

TO-BE

  • @unchecked Sendable 추가
  • UIFont는 class 타입이라 컴파일러가 자동으로 Sendable을 증명할 수 없음
  • 모든 프로퍼티(font, lineHeight, letterSpacing)는 생성 후 불변(let)이므로 동시 접근이 안전 — 개발자가 직접 보장

@MainActor가 아닌 @unchecked Sendable을 선택한 이유

  • MDSFontUILabel, UIButton 같은 UI 컴포넌트가 아니라 폰트 정보를 담는 데이터 타입
  • @MainActor는 "이 타입은 메인 스레드에서만 써야 한다"는 의미인데, MDSFont는 어떤 폰트를 어떻게 쓸지에 대한 명세(spec)에 가까움
  • UI에 실제로 적용하는 건 이 값을 받아서 쓰는 쪽(label.font = ...)의 책임이므로 MDSFont 자체를 메인 스레드에 귀속시킬 이유가 없음
  • CGSize, UIEdgeInsets처럼 어느 스레드에서든 자유롭게 들고 다닐 수 있는 값으로 설계

4. FontLoader — @MainActor

AS-IS

  • isRegisteredprivate static var로 선언
  • Swift 6에서 mutable global state는 여러 Task가 동시 접근 시 데이터 레이스 위험으로 컴파일 에러 발생

TO-BE

  • FontLoader 전체에 @MainActor 추가
  • registerIfNeeded()는 UIKit 초기화 컨텍스트(메인 스레드)에서만 호출되므로 @MainActor 격리가 의미적으로 적합
  • nonisolated(unsafe) 대신 @MainActor를 선택한 이유: 실제 호출 시점이 메인 스레드로 보장되므로 불필요한 unsafe 없이 컴파일러가 안전성을 검증할 수 있음

5. build.js — SemanticColor invalid redeclaration 수정

AS-IS

  • capitalize(toSwiftName(base))로 state 그룹 enum 이름 생성
  • toSwiftName이 먼저 실행되어 default`default`(backtick 포함)로 변환한 뒤 capitalize가 첫 글자인 backtick을 대문자화하려다 무력화됨
  • 결과적으로 같은 스코프에 static let \default`(프로퍼티)와 enum `default`(타입)이 동시 생성 → Swift invalid redeclaration` 에러

TO-BE

  • toSwiftName(capitalize(base))로 순서 변경
  • capitalize가 먼저 실행되어 defaultDefault로 변환 후 toSwiftName이 keyword 여부를 검사
  • Default는 Swift 예약어가 아니므로 backtick 없이 enum Default로 생성 → 프로퍼티 `default`와 이름이 달라 충돌 없음

📌 참고 사항

📸 스크린샷

해당 없음

📮 관련 이슈

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yungu0010 yungu0010 self-assigned this May 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Walkthrough

패키지 매니페스트에 iOS 16을 추가하고 일부 동시성 어노테이션 및 코드 생성 네이밍을 조정한 뒤, GitHub Actions를 macOS로 전환해 토큰으로 생성된 Swift 파일을 xcodebuild로 검증하도록 CI를 확장합니다.

변경사항

Swift 빌드 검증 파이프라인

Layer / File(s) Summary
패키지 플랫폼 설정
MDS/Package.swift
platforms: [.iOS(.v16)]을 패키지 매니페스트에 추가하여 iOS 16을 최소 배포 대상으로 지정합니다.
동시성 어노테이션
MDS/Sources/MDS/Foundation/Base/FontLoader.swift, MDS/Sources/MDS/Foundation/MDSFont.swift
FontLoader@MainActor를 추가하고 MDSFont@unchecked Sendable으로 선언합니다.
코드 생성 네이밍 변경
build.js
SemanticColor.swift 생성 로직에서 enum 이름을 만들 때 capitalize()를 먼저 적용한 다음 toSwiftName()을 호출하도록 변경합니다.
CI 워크플로우 업데이트
.github/workflows/style-dictionary.yml
워크플로우 실행 환경을 macos-latest로 변경하고, 토큰 생성 후 xcodebuildMDS 스킴의 Swift 빌드를 검증하는 단계를 추가합니다. 빌드 실패 시 워크플로우가 중단됩니다.

Sequence Diagram(s)

sequenceDiagram
  participant Runner
  participant StyleDict
  participant XcodeBuild
  participant Git
  Runner->>StyleDict: npm install & build tokens
  StyleDict->>Runner: emit Swift files
  Runner->>XcodeBuild: xcodebuild MDS scheme (simulator)
  XcodeBuild->>Runner: build result
  Runner->>Git: commit & create PR if needed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • juri123123
  • kwonseokki

시 🐰

토큰이 스위프트로 깜짝 변신하네,
맥 위에서 한 번 빌드해보니 반짝반짝✨
iOS 16 약속하고 검증까지 끝!
토끼가 당근 들고 축하드려요 🥕🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed 모든 코드 변경사항이 이슈 #42의 목표인 Swift 빌드 검증 스텝 추가 및 Swift 6 동시성 오류 수정을 충족합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #42의 범위 내에 있으며, 명확한 목적과 정당성을 갖고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed PR 제목이 Swift 빌드 검증과 Swift 6 동시성 오류 수정이라는 주요 변경사항을 명확하게 요약하고 있으며, 이슈 번호 #42를 포함하여 구체적입니다.
Description check ✅ Passed PR 설명은 변경 사항과 밀접하게 관련되어 있으며, 각 파일 수정의 목적과 기술적 근거를 상세히 설명합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#42-swift-build-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/style-dictionary.yml (1)

12-12: macos-latest 런너 비용 급증 유의

xcodebuild를 위해 macOS 런너는 불가피하지만, GitHub Actions 과금 모델에서 macOS 런너는 Linux 대비 약 10배 비쌉니다. 이 워크플로우가 token-sync 브랜치 push마다 실행되므로, 비용이 예상보다 빠르게 누적될 수 있습니다.

Swift 빌드 검증 스텝만 별도 job으로 분리하고 needs: 의존성을 설정하면, npm 빌드/diff 생성/커밋은 저렴한 Linux 런너에서 실행하고, xcodebuild만 macOS에서 실행하는 구조로 비용을 최적화할 수 있습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/style-dictionary.yml at line 12, The workflow currently
uses runs-on: macos-latest for the whole job causing high costs; refactor the
job into two jobs: (1) a Linux job to run npm build/diff generation/commit steps
(keep the existing steps that produce npm artifacts and commits) and (2) a
macOS-only job that runs the Swift/xcodebuild validation step; make the macOS
job depend on the Linux job using needs: so the Linux job runs on push to
token-sync and only the xcodebuild step runs on macOS (runs-on: macos-latest)
while everything else uses runs-on: ubuntu-latest to reduce runner costs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/style-dictionary.yml:
- Around line 103-109: The "Validate Swift build" step can hide xcodebuild
failures because the pipeline uses a pipe to xcpretty without pipefail; update
the "Validate Swift build" step to run its shell with bash and enable pipefail:
set shell to "bash" for the step and prepend the command with "set -o pipefail"
(or use "set -eo pipefail") before running the existing cd MDS && xcodebuild ...
| xcpretty || exit 1 so that any non-zero exit from xcodebuild fails the step;
reference the step name "Validate Swift build" and the existing pipeline command
string to locate where to change.

---

Nitpick comments:
In @.github/workflows/style-dictionary.yml:
- Line 12: The workflow currently uses runs-on: macos-latest for the whole job
causing high costs; refactor the job into two jobs: (1) a Linux job to run npm
build/diff generation/commit steps (keep the existing steps that produce npm
artifacts and commits) and (2) a macOS-only job that runs the Swift/xcodebuild
validation step; make the macOS job depend on the Linux job using needs: so the
Linux job runs on push to token-sync and only the xcodebuild step runs on macOS
(runs-on: macos-latest) while everything else uses runs-on: ubuntu-latest to
reduce runner costs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b0768d0b-6bd1-42cc-b50f-aac5f632efbd

📥 Commits

Reviewing files that changed from the base of the PR and between 2a281cc and 9f3cdea.

📒 Files selected for processing (2)
  • .github/workflows/style-dictionary.yml
  • MDS/Package.swift

Comment thread .github/workflows/style-dictionary.yml
yungu0010 added 3 commits May 8, 2026 17:14
<원인>
UIFont는 class 타입이라 plain Sendable 선언 시 컴파일 에러가 발생함.
<해결>
UIFont는 생성 후 불변이므로 동시 접근이 안전하지만, 컴파일러가
이를 정적으로 증명할 수 없어 @unchecked Sendable로 개발자가 직접 보장함을 명시
<원인>
isRegistered는 mutable static var로, Swift 6에서 여러 Task가 동시
접근 시 데이터 레이스가 발생할 수 있음.

<해결>
registerIfNeeded()는 UIKit
컨텍스트(메인 스레드)에서만 호출되므로 @mainactor 격리. 별도 동기화 없이 안전하게 상태를 보호할 수 있음.
<원인>
capitalize(toSwiftName(base))는 toSwiftName이 먼저 backtick을 붙여 `default`로 만들어버려 capitalize가 동작하지 않음.

<해결>
toSwiftName(capitalize(base))로 순서를 바꾸면 default → Default로 대문자화된 뒤 keyword 검사를 하므로 backtick 없이 enum Default가 생성됨.

빌드 에러의 원인이었던 중복 선언 에러가 제거 됨.
- 같은 스코프의 static let `default`와 enum Default가 이름이 달라 invalid redeclaration 에러 사라짐.
@yungu0010 yungu0010 changed the title [Setting] #42 - swift build 검증 스텝 추가 및 iOS 플랫폼 선언 [CI] #42 - Swift 빌드 검증 및 Swift 6 동시성 오류 수정 May 8, 2026
@yungu0010 yungu0010 changed the title [CI] #42 - Swift 빌드 검증 및 Swift 6 동시성 오류 수정 [Fix] #42 - Swift 빌드 검증 및 Swift 6 동시성 오류 수정 May 8, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@MDS/Sources/MDS/Foundation/MDSFont.swift`:
- Line 8: Add a brief documentation comment on the MDSFont struct that justifies
the use of `@unchecked` Sendable by citing the thread-safety basis (e.g., that
stored properties like UIFont and CGFloat are effectively immutable and Apple
documents UIFont as safe to use from multiple threads), mention any invariants
you rely on, and note that you considered `@MainActor` if stronger isolation is
needed; target the comment to appear immediately above the MDSFont declaration
so reviewers can see the rationale for `@unchecked` Sendable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c3089b76-3274-4d9e-94f2-06ab11dde8be

📥 Commits

Reviewing files that changed from the base of the PR and between 9f3cdea and 8f4ac50.

📒 Files selected for processing (3)
  • MDS/Sources/MDS/Foundation/Base/FontLoader.swift
  • MDS/Sources/MDS/Foundation/MDSFont.swift
  • build.js
✅ Files skipped from review due to trivial changes (1)
  • MDS/Sources/MDS/Foundation/Base/FontLoader.swift

Comment thread MDS/Sources/MDS/Foundation/MDSFont.swift
yungu0010 added 2 commits May 8, 2026 19:06
xcodebuild ... | xcpretty 구성에서 bash의 기본 동작은 파이프의 마지막 명령(xcpretty)의 종료 코드만 반환함. xcpretty는 포맷팅 도구라 항상 exit 0을 반환하므로 xcodebuild가 실패해도 || exit 1이 트리거되지 않아 빌드 실패가 CI를 통과하는 문제가 있었음.

shell: bash 명시로 GitHub Actions가 -eo pipefail 옵션을 포함해
실행하도록 하고, set -o pipefail을 추가해 파이프 중 하나라도 실패하면
전체 파이프라인 종료 코드가 실패로 처리되도록 수정.
@yungu0010 yungu0010 merged commit 135423b into default May 8, 2026
1 check passed
@yungu0010 yungu0010 deleted the feat/#42-swift-build-validation branch May 8, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Setting] style-dictionary workflow에 swift build 검증 추가

1 participant