제라스의 Swift 공부/iOS 개발 오류

[iOS 개발 오류] No Such Module 'Testing' in Xcode

Xerath(제라스) 2024. 10. 7. 02:21
728x90
반응형

서론

안녕하세요! 개발자 제라스입니다~!! 👋🏻🤖👋🏻

 

오늘은 가볍게 에러 포스팅을 하려고 합니다!

 

최근 회고에서도 언급했다시피 이번 프로젝트에선 다양한 새로운 것들을 경험하면서 프로젝트를 해보려고

Xcode16에 Swift6를 적용해서 개발을 하는 중입니다.

 

그래서 새로 프로젝트를 만들었는데...!

 

새로 Swift Testing이란게 나왔더라구요..!?!?!

(나만 이제 알았어...!! 왜 안 알려주심??엉?앙? 🥲🥲🥲 남탓 제라스👍🏻 🤖 👍🏻)

 

그래도 XCTest를 먼저 쓰고 Swift Testing으로 Migrating 해보는게 나으려나 싶어서

XCTest로 만들었습니다.

 

근데...!

갑자기 마음이 바껴서 Swift Testing을 적용하려고 한 Xerath...!!

(뭔 마음이 왔다 갔다하냐...)

 

그래서 XCTest가 아닌

 

요렇게 Swift Testing Unit Test 파일을 만들었거든요??

 

그렇게 열심히 뚝딱 뚝딱 Test코드를 짜고 한번 돌려보려고 하니...!

 

 

여기서 import Testing 부분이 Error가 나더라구요...

Error 내용은 

 

No such module 'Testing'

 

그래서 열심히 검색하다보니 한글로 된 에러 해결 문서가 없어서...

https://stackoverflow.com/questions/32008403/no-such-module-when-using-testable-in-xcode-unit-tests

 

"No such module" when using @testable in Xcode Unit tests

I recently updated to Xcode 7 beta 5. I tried adding a unit test to an earlier project, but I am getting the error message "No such module [myModuleName]" on the @testable import myModuleName line....

stackoverflow.com

 

이곳에서 사과개발자짱짱 형님들의 얘기를 들어보고,

https://www.polpiella.dev/swift-testing

 

polpielladev 📱 | A blog about iOS mobile app development and Swift

Blog posts about iOS mobile app development and Swift by Pol Piella.

www.polpiella.dev

 

이 문서를 보다보니 해결을 할 수 있었습니다.

 

Xcode 16에 Swift 6인데 이게 왜 뜰까요?

저도 이 부분이 문제였습니다.

 

근데, 문제가 있을 리가 없습니다...

제가 문제 있던 부분은 바로 테스트 번들에서 Target Membership에서

기존의 프로젝트(MusicExtractor)를 추가해두었다는 점입니다.

제대로 된 해결 방법이 없어서 골 때리고 있었는데, 저걸 지워주니 문제가 사라지더라구요.

 

https://stackoverflow.com/questions/18266649/xctest-build-errors-for-test-target-xcode-5

 

XCTest build errors for test target Xcode 5:

I have set up an XCode 5 iOS 7 project for unit tests. Of course, setting up the unit tests are taking me so long that I'm trying to keep the faith that it's worth it. Struggling for hours over t...

stackoverflow.com

여기서도 많이들 말씀해주신 부분인데, XCTest를 사용할 때도 사실 마찬가지입니다.

 

"Make sure that you all your test files belong only to your test target."

 

즉, target을 오직 자기자신만 하라는 거였습니다.

왜 하필 No such Module이 뜨는지는 모르겠지만,

문제는 이거긴 했다~~~입니다.

 

사실 처음엔 Swift6 tool-chain이 적용이 안되어서 그런건가 싶어서 버젼 확인을 해보았는데..

응~아니야

잘 적용이 되어있긴 하더라구용

버젼 문제는 아니긴 하지만 혹시나 Swift6가 적용되었는지도 다들 확인 한번 해보시기 바랍니다!

Xcode 15에서 쓰고 싶은데... 새로 올리기는 무서워요

새로 나온 Xcode 16 너무 좋은데...ㅎㅎㅎ

이걸 안 쓰시다니 ㅠㅠㅠ

 

이런 분들을 위해서는 다음 Repository에서 받아다가 사용하시면 됩니다.

https://github.com/swiftlang/swift-testing

 

GitHub - swiftlang/swift-testing: A modern, expressive testing package for Swift

A modern, expressive testing package for Swift. Contribute to swiftlang/swift-testing development by creating an account on GitHub.

github.com

(TMI지만 이건 https://github.com/apple/swift-testing 하고 동일한 링크로 연결이 됩니다!)

 

얘를 SPM으로 받아와서 Package로 등록해서도 쓸 수가 있습니다!

더 자세한 건 다음 아티클을 참고하시면 좋습니다!

https://www.polpiella.dev/swift-testing

 

polpielladev 📱 | A blog about iOS mobile app development and Swift

Blog posts about iOS mobile app development and Swift by Pol Piella.

www.polpiella.dev

마무리

이번에 우연히 Swift6에서 나온 Swift Testing을 써보고 있는데,

생각보다 간단하면서도 되게 좋은 툴이 나왔다고 생각이 듭니다!

 

사실 XCTest를 아주 빠삭하게 알지는 않기에 그 차이가 객관적으로 느끼지는 못하지만,

Migrating 과정들을 보면서 차차 확인하고,

일단 다음에 맛볼 WWDC는...

 

https://developer.apple.com/kr/videos/play/wwdc2024/10179/

 

Swift Testing 소개 - WWDC24 - 비디오 - Apple Developer

Swift Testing을 Swift로 작성된 코드를 테스트하기 위한 새로운 패키지입니다. 새롭고 강력한 API의 기본 구성 요소에 대해 알아보고, Swift Testing을 일반적인 테스트 작업 흐름에 적용할 수 있는 방법

developer.apple.com

https://developer.apple.com/kr/videos/play/wwdc2024/10195/

 

Swift Testing으로 테스트 심화하기 - WWDC24 - 비디오 - Apple Developer

Swift Testing에 추가된 기능으로 (테스트) 모음 세트를 작성하는 방법을 알아봅니다. 기본 구성 요소를 활용하여 더 많은 시나리오에 적용할 수 있도록 테스트를 확장하고, 다른 테스트 모음에서

developer.apple.com

 

이 놈들입니다 ㅋㅋㅋㅋㅋㅋㅋ (맛있겠다...🥹🥹🥹)

요즘 이력서 시즌이라 참 바쁘긴 하지만 빨리 시간내서 보고 싶습니다 ㅎㅎㅎ

 

이번 프로젝트에서 Swift-Testing 야무지게 써보고 후기 남기겠습니다~!!

그럼 다음에도 좋은 포스팅으로 돌아오겠습니다!

 

참고

https://github.com/swiftlang/swift-testing

 

GitHub - swiftlang/swift-testing: A modern, expressive testing package for Swift

A modern, expressive testing package for Swift. Contribute to swiftlang/swift-testing development by creating an account on GitHub.

github.com

 

https://www.swift.org/blog/announcing-swift-6/#:~:text=and%20localization%20data.-,Swift%20Testing,-Swift%206%20introduces

 

Announcing Swift 6

We’re delighted to announce the general availability of Swift 6. This is a major new release that expands Swift to more platforms and domains.

www.swift.org

 

https://developer.apple.com/documentation/testing

 

Swift Testing | Apple Developer Documentation

Create and run tests for your Swift packages and Xcode projects.

developer.apple.com

 

https://www.polpiella.dev/swift-testing

 

polpielladev 📱 | A blog about iOS mobile app development and Swift

Blog posts about iOS mobile app development and Swift by Pol Piella.

www.polpiella.dev

 

https://stackoverflow.com/questions/18266649/xctest-build-errors-for-test-target-xcode-5

 

XCTest build errors for test target Xcode 5:

I have set up an XCode 5 iOS 7 project for unit tests. Of course, setting up the unit tests are taking me so long that I'm trying to keep the faith that it's worth it. Struggling for hours over t...

stackoverflow.com

 

https://stackoverflow.com/questions/32008403/no-such-module-when-using-testable-in-xcode-unit-tests

 

"No such module" when using @testable in Xcode Unit tests

I recently updated to Xcode 7 beta 5. I tried adding a unit test to an earlier project, but I am getting the error message "No such module [myModuleName]" on the @testable import myModuleName line....

stackoverflow.com

 

 


아직 꼬꼬마 개발자입니다.

더 나은 설명이나 코드가 있다면 언제든 환영입니다.

적극적인 조언과 피드백 부탁드립니다!

 

그럼 오늘도 개발 가득한 하루되세요!

- Xerath -

🤖🤖🤖🤖🤖🤖🤖

 

728x90
반응형