iOS/UIKit

[UIKit] Command SwiftCompile failed with a nonzero exit Code 오류 해결

Guryss 2024. 11. 15. 23:58

1. 문제상황

댓글 안에 있는 드롭다운 버튼을 클릭했을 때 Input 이벤트 로직을 정의하고 있었다. 

드롭다운 내에는 top, bottom 두개의 버튼이 들어가있고, 내 댓글인지 아닌지의 여부도 반영하면 총 4가지의 분기처리를 해주어야 했다.

그림으로 표현하자면 이런 상황!

 

Input {
	let commentDropdownDidTap: Observable<DropdownButtonType>
}

Output {
	let showCommentSpoilerAlertView: Observable<((Int) -> Observable<Void>, Int)>
    let showCommentImproperAlertView: Observable<((Int) -> Observable<Void>, Int)>
    let myCommentEditing: Observable<Void>
    let showCommentDeleteAlertView: Observable<((Int) -> Observable<Void>, Int)>
}

 

input.commentDropdownDidTap
	.map { ($0, self.isMyComment) }
	.subscribe(with: self, onNext: { owner, result in
    	owner.hideCommentDropdownView.accept(())
        switch result {
        	case (.top, true): owner.pushToFeedEditViewController.accept(())
            case (.bottom, true): owner.showCommentDeleteAlertView.accept((owner.deleteComment, owner.selectedCommentId))
            case (.top, false): owner.showCommentSpoilerAlertView.accept((owner.postSpoilerComment, owner.selectedCommentId))
            case (.bottom, false): owner.showCommentImproperAlertView.accept((owner.postImpertinenceFeed, owner.selectedCommentId))
        }
    })
.disposed(by: disposeBag)

 

map 을 통해 <DropdownButtonType, isMyComment> 로 값을 뱉어주면 해당 값을 구독하여 result에 따라 분기처리를 할 수 있도록 구현하였다. 

 

정말 틀린 코드가 없다고 생각했는데 ..

오류 발생 ㅠㅠ 어떤 오류인지 찾아봤으나 .. 이름 중복, 패키징 오류 등등 오류의 종류가 다양했어서 나는 당최 알 수가 없었다. 

 

2. 해결

완전 바보 이슈였다. 😅

위에 Output을 보면 Observable<((Int) -> Observable<Void>, Int)> 타입을 갖고 있다. 

즉, Observable이 방출하는 값은 튜플 형태 (함수, 정수) 이다. 

 

근데 내가 넣어준 함수였던 deleteComment, postSpoilerComment, postImpertinenceFeed 는

feedId, commentId 두개의 Int를 입력받아 Observable<Void> 를 반환하는 함수였다 .... !

또한 ViewController에게는 feedId, commentId 두개를 전달하기 위해 3개의 값을 갖도록 했어야 했다.

Output {
	let showCommentSpoilerAlertView: Observable<((Int, Int) -> Observable<Void>, Int, Int)>
	let showCommentImpertinenceAlertView: Observable<((Int, Int) -> Observable<Void>, Int, Int)>
	let myCommentEditing: Observable<Void>
	let showCommentDeleteAlertView: Observable<((Int, Int) -> Observable<Void>, Int, Int)>
}

 

결론!
해당 오류가 발생한다면 타입을 잘 작성했는지, 코드 미스가 없는지 잘 디버깅 해야 한다 😅🥲