-
[iOS] Carthage 로 RIBs 프로젝트 셋팅하기 #1👻 iOS 2020. 12. 28. 21:30
(주의!) 이 글은 실패 사례입니다. 성공사례는 maart.tistory.com/82 를 참고해주세요 :)
RIBs 를 이용해서 구조를 잡기로 했고,
모듈의 버전관리는 Carthage 로 해보기로(?) 했어요.
그래서 Quick Start 를 보며 무작정 뛰어들어 봅니다.
github.com/Carthage/Carthage#quick-start
1. Carthage 설치
> brew install carthage . . . 🍺 /usr/local/Cellar/carthage/0.36.0: 8 files, 7.6MB
v0.36.0 이 설치 되었네요
버전은 무지막지 한테 아직 1.0이 아니군요?
2. Cartfile 생성
RIBs 가이드에서 아래와 같이 쓰라고 했으니 그대로 넣어 봅니다
github "uber/RIBs" ~> 0.9
3. carthage update 실행
> carthage update --use-xcframeworks
어.. 그런데 아래와 같이 쉘 실행 오류가 나네요
Unrecognized arguments: --use-xcframeworks
.... 막힘.
가이드에 나온 쉘 옵션인데 왜...?
한참 헤메다가 Carthage issues에서 관련 이슈를 찾았습니다.
github.com/Carthage/Carthage/issues/3097#issuecomment-751226864
v0.36.0 에 해당 옵션이 포함되지 않아서 라니..
소스를 직접 받아서 빌드하면 된다네요.
git clone 하고 make install 해서 설치완료.
다시 carthage update 를 실행합니다.
> carthage update --use-xcframeworks *** Fetching RIBs *** Fetching RxSwift *** Checking out RIBs at "v0.9.2" *** Checking out RxSwift at "4.5.0" *** xcodebuild output can be found in /var/folders/51/xtqfh8c52t72sbcqnc1ymz3m0000gp/T/carthage-xcodebuild.nHGiXX.log *** Downloading RxSwift.framework binary at "[4,5]" *** Skipped installing RxSwift.framework binary due to the error: "Incompatible Swift version - framework was built with 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3) and the local version is 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)." Falling back to building from the source *** Building scheme "RxAtomic" in Rx.xcworkspace *** Building scheme "RxSwift" in Rx.xcworkspace *** Building scheme "RxCocoa" in Rx.xcworkspace Build Failed Task failed with exit code 65: /usr/bin/xcrun xcodebuild -workspace /Users/maart/work/ribs/ribs-carthage/Carthage/Checkouts/RxSwift/Rx.xcworkspace -scheme RxCocoa -configuration Release -derivedDataPath /Users/maart/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/RxSwift/4.5.0 ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive VALIDATE_WORKSPACE=NO -archivePath /var/folders/51/xtqfh8c52t72sbcqnc1ymz3m0000gp/T/RxSwift SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/maart/work/ribs/ribs-carthage/Carthage/Checkouts/RxSwift) This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/51/xtqfh8c52t72sbcqnc1ymz3m0000gp/T/carthage-xcodebuild.nHGiXX.log
... 또 막힘.
멘탈을 좀 수습하고 내용을 좀 살펴보니
패키지에 존재하는 바이너리를 이용 하려는데 로컬의 swift 버전과 맞지 않아서 호환성 오류로 빌드에 실패했다.. 뭐 이런.
게다가 RxSwift 는 v5 가 아니네요.
...속도를 위해서 빌드 설정의 복잡성을 가져가는게 맞는지
잠깐동안의 고뇌를 거쳐 좀 더 진행해보기로 합니다;;
오랜만에 다시 시작하니까 모르는게 너무 많네요 ㅋㅋ
구글의 도움으로 관련된 문제의 해결방법을 하나 찾았는데 일단 시도해 봅니다
stackoverrun.com/ko/q/12838504#46915496
RIBs 에 버전이 아닌 커밋 해시를 직접 지정해 줍니다. 최신으로 쓰려고요.
github "uber/RIBs" "ffc489f00db785c8c0051678393f7aba0d52f1a4"
> carthage bootstrap --no-use-binaries --platform iOS --cache-builds *** No Cartfile.resolved found, updating dependencies *** Fetching RxSwift *** Checking out RxSwift at "5.1.1" *** Checking out RIBs at "ffc489f00db785c8c0051678393f7aba0d52f1a4" *** No cache found for RxSwift, building with all downstream dependencies *** xcodebuild output can be found in /var/folders/51/xtqfh8c52t72sbcqnc1ymz3m0000gp/T/carthage-xcodebuild.cGZAY1.log *** Building scheme "RxBlocking" in Rx.xcworkspace A shell task (/usr/bin/xcrun lipo -create /Users/maart/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/RxSwift/5.1.1/Build/Intermediates.noindex/ArchiveIntermediates/RxBlocking/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/RxBlocking.framework/RxBlocking /Users/maart/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/RxSwift/5.1.1/Build/Products/Release-iphonesimulator/RxBlocking.framework/RxBlocking -output /Users/maart/work/ribs/ribs-carthage/Carthage/Build/iOS/RxBlocking.framework/RxBlocking) failed with exit code 1: fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/maart/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/RxSwift/5.1.1/Build/Intermediates.noindex/ArchiveIntermediates/RxBlocking/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/RxBlocking.framework/RxBlocking and /Users/maart/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/RxSwift/5.1.1/Build/Products/Release-iphonesimulator/RxBlocking.framework/RxBlocking have the same architectures (arm64) and can't be in the same fat output file Building universal frameworks with common architectures is not possible. The device and simulator slices for "RxBlocking" both build for: arm64 Rebuild with --use-xcframeworks to create an xcframework bundle instead.
RxBlocking 빌드하다 오류가 났네요.
Xcode가 문제인가! Carthage 가 문제인가!
일단 옵션이 빠져서 문제라고 하니 --use-xcframeworks 를 넣어서 다시 시도해 봅니다.
> carthage bootstrap --no-use-binaries --platform iOS --cache-builds --use-xcframeworks *** Checking out RIBs at "ffc489f00db785c8c0051678393f7aba0d52f1a4" *** Checking out RxSwift at "5.1.1" *** No cache found for RxSwift, building with all downstream dependencies *** xcodebuild output can be found in /var/folders/51/xtqfh8c52t72sbcqnc1ymz3m0000gp/T/carthage-xcodebuild.HqwpSf.log *** Building scheme "RxBlocking" in Rx.xcworkspace *** Building scheme "RxSwift" in Rx.xcworkspace *** Building scheme "RxRelay" in Rx.xcworkspace *** Building scheme "RxCocoa" in Rx.xcworkspace *** Building scheme "RxTest" in Rx.xcworkspace *** Building scheme "RIBs" in RIBs.xcodeproj Build Failed Task failed with exit code 65: /usr/bin/xcrun xcodebuild -project /Users/maart/work/ribs/ribs-carthage/Carthage/Checkouts/RIBs/ios/RIBs.xcodeproj -scheme RIBs -configuration Release -derivedDataPath /Users/maart/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/RIBs/ffc489f00db785c8c0051678393f7aba0d52f1a4 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive VALIDATE_WORKSPACE=NO -archivePath /var/folders/51/xtqfh8c52t72sbcqnc1ymz3m0000gp/T/RIBs SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/maart/work/ribs/ribs-carthage/Carthage/Checkouts/RIBs) This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/51/xtqfh8c52t72sbcqnc1ymz3m0000gp/T/carthage-xcodebuild.HqwpSf.log
로그를 확인해 보니 RIBs를 빌드하면서 아래와 같이 RxSwift의 arm64 혹은 armv7 빌드하면서 문제가 발생하는 것 같아요
요건 또 잘 모르는 영역이니 따로 파보도록 하겠습니다.
/Users/maart/work/ribs/ribs-carthage/Carthage/Checkouts/RIBs/ios/RIBs/Classes/LeakDetector/LeakDetector.swift:17:8: error: no such module 'RxSwift' import RxSwift ^ ** ARCHIVE FAILED ** The following build commands failed: CompileSwift normal arm64 CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler CompileSwift normal armv7 (4 failures)
(잠깐 검색해보니 좋은 블로그가 있어서 링크 걸어봅니다.)
jusung.github.io/Xcode12-Build-Error/
다시 빌드오류로 돌아와서 또 문제를 해결해 봐야 겠습니다.
대충 이것 저것 시도해 봤는데 잘 안 되어서
Carthage README에 있는 Alamofire 를 빌드해 보았습니다만
너무 쉽게 잘 되네요..
하아ㅏㅏㅏㅏㅏ... 뭐가 문제일까요
이번 포스트 너무 길어서 그만 끊고 다음 포스트에 이어 가겠습니다.
요약
Carthage 설치해서 RIBs 가져와 빌드해보려 하니 빌드 오류로 진행이 불가.
Xcode 12.3, swift 5.3.2 를 사용하는데 문제가 있어 보임.
[2020. 03. 19 update]
maart.tistory.com/81 에서 carthage 빌드 오류를 해결 할 수 있습니다.
[2020. 03. 21 update]
maart.tistory.com/82 이 포스트로 다시 정리했습니다. ㅠㅠ