Project로 나눈 Framework에 대해 SwiftUI Preview가 생성 안 됨.
상황. Framework로 나눈 것들에 대해서 Preview 생성이 제대로 되지 않음. (Xcode13 RC)
1 2 3 4 5 6 7 8 9 |
MessageSendFailure: Message send failure for send previewInstances message to agent ================================== | RemoteHumanReadableError | | LoadingError: failed to load library at path "/Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/FileBrowser.framework/FileBrowser": Optional(dlopen(/Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/FileBrowser.framework/FileBrowser, 0x0000): Library not loaded: @rpath/BitByteData.framework/BitByteData | Referenced from: /Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/FileBrowser.framework/FileBrowser | Reason: tried: '/Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/UserData/Previews/Simulator Devices/2512C6DC-4C4A-4D28-BDA1-D48A80F1FCBD/data/Containers/Bundle/Application/355A2472-198B-4606-86E3-25C8F18D5657/XCPreviewAgent.app/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/FileBrowser.framework/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/UserData/Previews/Simulator Devices/2512C6DC-4C4A-4D28-BDA1-D48A80F1FCBD/data/Containers/Bundle/Application/355A2472-198B-4606-86E3-25C8F18D5657/XCPreviewAgent.app/../../Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/UserData/Previews/Simulator Devices/2512C6DC-4C4A-4D28-BDA1-D48A80F1FCBD/data/Containers/Bundle/Application/355A2472-198B-4606-86E3-25C8F18D5657/XCPreviewAgent.app/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/FileBrowser.framework/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/UserData/Previews/Simulator Devices/2512C6DC-4C4A-4D28-BDA1-D48A80F1FCBD/data/Containers/Bundle/Application/355A2472-198B-4606-86E3-25C8F18D5657/XCPreviewAgent.app/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/FileBrowser.framework/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/UserData/Previews/Simulator Devices/2512C6DC-4C4A-4D28-BDA1-D48A80F1FCBD/data/Containers/Bundle/Application/355A2472-198B-4606-86E3-25C8F18D5657/XCPreviewAgent.app/../../Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/UserData/Previews/Simulator Devices/2512C6DC-4C4A-4D28-BDA1-D48A80F1FCBD/data/Containers/Bundle/Application/355A2472-198B-4606-86E3-25C8F18D5657/XCPreviewAgent.app/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Users/jinho/Library/Developer/Xcode/DerivedData/FunView-doriyytcvkwskufjredpmpopwfbs/Build/Intermediates.noindex/Previews/FileBrowser/Products/Debug-iphonesimulator/FileBrowser.framework/Frameworks/BitByteData.framework/BitByteData' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/BitByteData.framework/BitByteData' (no such file)) |
위와 같은 에러를 얻는다.
원인은 SwiftUI Preview에서 요청하는 Library의 주소와 실제 라이브러리가 생성된 주소가 다르기 때문이다. (@rpath/BitByteData.framework/BitByteData와 같은 식으로 요청하나, 실제로는 @rpath/BitByteData/BitByteData.framework/BitByteData가 생성물의 주소이다.)
실제 구조는 위와 같다.
CocoaPod install 시에 각 프레임워크에 Search Path는 의도된 대로 잘 들어가고, Preview가 아닌 실제 프레임워크는 제대로 빌드가 되는 상황. (오직 메인 어플리케이션에서만 Preview 빌드가 정상적이다.)
임시 해결 방법
방법1. Preview를 빌드할 때 요청하는 주소(BitByteData/BitByteData.framework -> BitByteData.framework)에도 빌드된 프레임워크를 붙여넣기
방법2. 일일이 프레임워크마다 CONFIGURATION_BUILD_DIR 수정, 참조하는 것들 Framework Search Paths도 동일하게 바꿔주기. 스크립트 만들기.
일단 방법1 처럼 해서 Xcode 스크립트로 되게 했으나, 이게 Xcode의 버그인지, 아니면 내가 모르는 부분이 있어서 트러블 슈팅이 미비한 것인지 아직 파악이 안 됨.
PS: Github 쓰레드 참조하여 스크립트 삽입하면 해결됨. -> https://github.com/CocoaPods/CocoaPods/issues/9275