Open
Conversation
Collaborator
|
좋은데? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
투어스와 Swift6의 공통점은 첫만남은 너무 어렵다는것이다
🔗 연결된 이슈
📄 작업 내용
Sendable 적용:
CalendarRepositoryImpl.swift에서 NetworkService의 thread-safe 처리CalendarUseCase.swift에서 의존성 주입된 repository의 thread-safe 처리ScheduleCategory.swift에서 Enum을 자동으로 Sendable 가능하도록 적용DailySchedule.swift에서 스케줄 배열을 포함한 일일 데이터의 동시성 처리Schedule.swift에서 Swift 6의 데이터 레이스 안전성 요구사항 충족@mainactor 적용:
CalendarView.swift에서 CalendarStore가 @mainactor로 업데이트되면서 Task 최적화CalendarStore.swift에서 클래스 레벨에 @mainactor 적용으로 Task 최적화그외
CalendarModels.swift에서 switch category의 @unknown default 추가로 Swift 6 엄격 모드 요구사항 충족
💻 해결한 오류들
1. Data Race관련
Sendable: Sendable은 동시성 도메인 간에 안전하게 전달될 수 있는 타입을 나타내는 마커 프로토콜.
Swift 6에서는 Task, Actor, async/await 컨텍스트 간 데이터 전달 시 반드시 Sendable 준수를 요구하여 컴파일 타임에 DataRace를 원천 차단.
값 타입(struct, enum)은 모든 저장 프로퍼티가 Sendable이면 자동으로 준수하지만, 참조 타입(class)은 명시적 선언이 필요해졌고. 특히 내부적으로 동기화 메커니즘(NSLock, DispatchQueue 등)을 통해 스레드 안전성을 보장하는 클래스는 @unchecked Sendable을 사용하여 컴파일러에게 안전성을 수동으로 보증해줌
주의사항
Actor나 @mainactor를 활용하여 격리된 컨텍스트에서 실행하거나, 캡처할 값을 Sendable 타입으로 변환 후 전달하는 방식으로 해결할수 있음
𝟐. 비효율적인 UI 업데이트 및 불필요한 Actor Hop
AS-IS
TO-BE
최적화 원칙:
4. "nonisolated global shared mutable state" 오류 해결
defaultValue가 동시성 안전성을 보장하지 못함전역 가변 상태(static var)가 여러 스레드에서 동시 접근 시 DataRace 위험으로 컴파일 에러 발생.
Global State Isolation:
Swift 6는 모든 전역 가변 상태에 대해 동시성 안전성을 컴파일 타임에 검증.
static var는 어떤 스레드에서든 접근 가능한 공유 가변 상태로 분류되어 명시적인 동기화 메커니즘 없이는 사용 불가하고 컴파일러는 데이터 경쟁 가능성이 있는 모든 코드를 사전에 차단하여 런타임 크래시 방지.
AS-IS: 동시성 위험이 있는 가변 전역 상태
TO-BE: 불변 상태로 동시성 안전성 확보
📚 참고자료
Adopting strict concurrency in Swift 6 apps
Swift Concurrency Documentation
Data Race Safety Guide
WWDC24 - Migrate your app to Swift 6
WWDC21 - Meet async/await in Swift
WWDC21 - Protect mutable state with Swift actors (Session 10133)
👀 기타 더 이야기해볼 점
여기 에 남긴것처럼 위 참고자료 내용들 정리해서 마이그레이션 가이드로 남기려 합니다.
생각보다 Concurrency 코드를 나름 잘 짜서인지 규모가 작아서였는지는 모르겟지만 엄청 크리티컬하지않아 다행이네요 다되면 같이 오류 해결해보아요~
✔️ CI Completed