IT TIP

번들 UITests가 손상되었거나 필요한 리소스가 누락되어로드 할 수 없습니다.

itqueen 2020. 12. 12. 12:54
반응형

번들 UITests가 손상되었거나 필요한 리소스가 누락되어로드 할 수 없습니다. 번들을 다시 설치하십시오.


다음 오류로 인해 테스트 케이스를 실행할 수 없습니다.

  • 번들“UITests”가 손상되었거나 필요한 리소스가 누락되어로드 할 수 없습니다. 번들을 다시 설치하십시오.
  • 라이브러리가로드되지 않음 : @ rpath / Alamofire.framework / Alamofire.
  • 이유 : 이미지를 찾을 수 없습니다.

이틀 이후로 검색 및 해결을 시도했지만이 문제를 해결할 수없는 사람이 도와주세요.


Xcode 10.1에서 생성 한 프로젝트로이 문제를 재현 할 수있었습니다. 저는 Swift 4.2와 CocoaPods를 의존성 관리자로 사용했습니다. 다음 Podfile이 있습니다.

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

target 'MyApp' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for MyApp
  pod 'Alamofire', '4.8.1'

  target 'MyAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'MyAppUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

그런 다음을 제거 했습니다. 자세한 내용 use_frameworks!이 링크 를 참조하십시오.

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

target 'MyApp' do

  # Pods for MyApp
  pod 'Alamofire', '4.8.1'    

  target 'MyAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'MyAppUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

또한 다음과 같은 경고를 받았습니다.

[!] The `MyAppUITests [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-MyApp-MyAppUITests/Pods-MyApp-MyAppUITests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

그래서 MyAppUITests 빌드 설정에서이 줄을 제거했습니다.

MyAppUITests 빌드 설정

그 실행 후 pod deintegrate && pod install문제가 사라졌습니다. 아마도 더 많은 종속성이있는 프로젝트 (예 : 여기 )의 경우 다른 솔루션을 사용해야합니다.


포드가 프레임 워크 대상에만 적용되고 테스트 대상에는 적용되지 않기 때문입니다. podfile에 테스트 대상을 추가합니다.

예 :

target 'MyFramework' do
  use_frameworks!
  pod 'Alamofire', '~> 4.5'
end

target 'MyFrameworkTests' do
  use_frameworks!
  pod 'Alamofire', '~> 4.5'
end

UITest 대상 빌드 설정의 배포 대상이 테스트하려는 호스트 응용 프로그램과 동일하게 설정되어 있는지 확인하십시오. 제 경우에는 나중에 UITesting 대상을 추가했고 기본값 인 배포 대상 iOS 12로 생성했습니다. 그런 다음 iOS 12 미만에서 UITest를 실행하려고하면 질문에 언급 된 오류가 발생했습니다.


제 경우에는 UI 테스트 대상을 use_frameworks!.

Podfileuse_frameworks! 상단의 어딘가에 전역 적으로 지정한 경우 UI 테스트 대상을 중첩 된 구조에서 자체 구조로 이동해도 도움이되지 않습니다 .

오류가 있는 Podfile (원본) :

platform :ios, '10.0'

inhibit_all_warnings!
use_frameworks!

target 'MyProject' do
  pod 'R.swift', '~> 5.0'
  pod 'Moya/RxSwift', '~> 12.0'
  # and other pods

  target 'MyProjectTests' do
    inherit! :search_paths

    pod 'iOSSnapshotTestCase', '~> 6.0'
  end

  target 'MyProjectUITests' do
    inherit! :search_paths
  end
end

오류가 있는 Podfile (먼저 수정 시도) :

platform :ios, '10.0'

inhibit_all_warnings!
use_frameworks!

def shared_pods
  pod 'R.swift', '~> 5.0'
end

target 'MyProject' do
  shared_pods

  pod 'Moya/RxSwift', '~> 12.0'
  # and other pods

  target 'MyProjectTests' do
    inherit! :search_paths

    pod 'iOSSnapshotTestCase', '~> 6.0'
  end
end

target 'MyProjectUITests' do
  shared_pods
end

최종 작업 Podfile :

platform :ios, '10.0'

inhibit_all_warnings!

def shared_pods
  pod 'R.swift', '~> 5.0'
end

target 'MyProject' do
  use_frameworks!

  shared_pods

  pod 'Moya/RxSwift', '~> 12.0'
  # and other pods

  target 'MyProjectTests' do
    inherit! :search_paths

    pod 'iOSSnapshotTestCase', '~> 6.0'
  end
end

target 'MyProjectUITests' do
  shared_pods
end

targets> mytestTarget> Build Settings> Runpath Search Path 아래의 Runpath 검색 경로에 프레임 워크의 위치를 ​​추가해야했습니다.


레거시 빌드 시스템으로 전환하면 Xcode 10의 문제가 해결되었습니다.


테스트 대상 inherit! :search_paths에서 inherit! :complete. 이것이 수행하는 작업에 대한 문서참조하십시오 .


1

2 [! [3] 3

  1. 빌드 단계로 이동
  2. Copy Pods Resources를 열고 경로를 복사합니다.
  3. Paste the path that you have copied from Copy Pods Resources and change tag name resources with frameworks
  4. Clean and Build
  5. Run your UITestsFile

I was able to fix this issue by following Roman Podymov answer then running pod deintegrate then pod install


What solved my problem was following the following steps: 1) delete the UITests target from the pod file. Initially, I had the following in the pod file:

target 'XUITests' do
    inherit! :search_paths   
end

2) Deintegrate the pods (with pod deintegrate)

3) Install the pods (with pod install)

4) Clean your project and run the project or your UITest


This error happened to me when I added a framework to the project (that's a framework itself, too), and tried to run the tests. I made it optional instead of required, and the tests succeeded. 여기에 이미지 설명 입력


나를 위해 UITests를 빌드 할 때 오류가 발생했습니다. 해결책 : Targer가 잘못된 iOS 버전을 사용했습니다. 테스트 대상과 모든 것이 작동하는 동일한 버전으로 교체했습니다 !!


실제로 Cocoapods를 사용하고 있다면 "pod install"을 실행하기 만하면 빌드 설정이 자동으로 업데이트됩니다.

참고 URL : https://stackoverflow.com/questions/40480503/the-bundle-uitests-couldn-t-be-loaded-because-it-is-damaged-or-missing-necessary

반응형