Development Tip

Xcode 7-코드 커버리지 데이터 생성 실패

yourdevel 2021. 1. 8. 22:27
반응형

Xcode 7-코드 커버리지 데이터 생성 실패


테스트를 실행할 때 오류가 발생합니다.

코드 커버리지 데이터 생성에 실패했습니다.
'UIDevice'에서 프로필 데이터 파일을 검색 할 수 없습니다.

여기에 이미지 설명 입력

콘솔에서 경고가 인쇄되었습니다.

시뮬레이터 부팅을 위해 120 초 동안 대기하는 시간이 초과되었습니다. 현재 상태는 1입니다.

그 이유는 무엇입니까?


프로젝트를 타사 동적 프레임 워크와 통합하는 경우 빌드 설정에 경로를 추가해야 할 수 있습니다. -> Build Settings-> "Runpath search paths"를 찾아 프레임 워크 경로가 포함되어 있는지 확인하십시오.

우리 팀이 작업하고있는 프레임 워크를 사용하도록 프로젝트를 설정 한 후이 정확한 문제를 직접 확인했습니다. 이 특정 설정을 업데이트 한 후 문제가 해결되었습니다. 필자의 경우 경로는 "프레임 워크 검색 경로"설정에 대해 이미 설정해야하는 경로와 동일합니다.


대부분의 XCode 문제를 해결 한 것처럼이 문제를 해결했습니다.

  1. DerivedData( Xcode>Preferences>Locations>DerivedData→파인더 에서 이동하려면)에서 프로젝트 파일을 삭제하십시오.
  2. Product>Clean
  3. (Alt- 버튼을 누른 상태로 유지) Product>Clean Build Folder
  4. XCode 종료
  5. XCode 다시 시작
  6. 기기 / 시뮬레이터에서 앱 제거

다시 시도하십시오. 그래도 작동하지 않는 경우 몇 번의 실행을 위해 다른 시뮬레이터 / 장치를 사용하십시오. 조만간 원본에서 다시 작동합니다.


코코아 포드를 사용하는 경우 Cocoapods 저장소에서 다음 스레드를 확인 하세요 . https://github.com/CocoaPods/CocoaPods/issues/5385#issuecomment-226269847

이것은 내 문제를 해결했습니다.

@dfleming 응답 복사 :

어떤 이유로 CocoaPods는 프로젝트 작업 공간을 생성 할 때 UI 테스트 대상에 "[CP] Embed Pods Frameworks"빌드 단계를 추가하지 않는 것으로 보입니다.

수동으로 추가했고 UI 테스트를 다시 실행할 수있었습니다.

이 빌드 단계는 다음 스크립트를 실행해야합니다. ({YourProject}를 프로젝트 이름으로 바꿉니다.)

"${SRCROOT}/Pods/Target Support Files/Pods-{YourProject}UITests/Pods-{YourProject}UITests-frameworks.sh"


나는 똑같은 오류를 경험했고 결국 작동하게되었고 이것이 내가 취한 단계입니다.

  1. 앱을 정리하고 삭제 한 후 Xcode와 시뮬레이터를 다시 시작했지만 작동하지 않았습니다.

  2. 그런 다음 제안대로 Mac을 다시 시작했지만 여전히 작동하지 않았습니다.

  3. 그런 다음 시뮬레이터에서 테스트 할 새 장치를 선택했고 이전에는 5s를 사용하고 6으로 전환했는데 작동했습니다.

흥미롭게도 iPhone 6 시뮬레이터로 전환했을 때 앱을 실행하고 작동하기 전에 로딩 바가있는 Apple 로고가 표시되었습니다.

5s 시뮬레이터로 다시 전환 할 때 이전에는 해보지 않았던 Apple 로딩 바를 사용하여 정확히 똑같은 작업을 수행했으며 5s가 작동했습니다.

따라서 시뮬레이터 문제로 보이며 다른 장치로 전환하면 효과가 있습니다. 콘텐츠 및 설정을 재설정하는 것이 작동하지 않는 장치에 대한 해결책 일 수 있습니다.


Cocoapods link_with방법으로이 문제가 발생할 수 있습니다!

xcode 7.2에서 똑같은 오류가 발생했습니다. 시뮬레이터 또는 장치 재설정 횟수가 없어도 문제가 해결되지 않았습니다. 내 UITest 대상을 완전히 다시 빌드 한 후 모든 것이 잘 작동했습니다. .pbxproj파일 의 방대한 git diff에서 많은 시간을 보낸 후 내 프로젝트에 대한 해결책을 찾았습니다. 이 오류를 보는 모든 사람의 근본 원인을 해결하는지 확실하지 않지만 분명히 나를 위해 일을 정리합니다.

"배포 대상"아래의 프로젝트 정보에서 "구성"은 애플리케이션에 대해 가능한 모든 구성을 나열합니다. 실행하려는 구성을 확장하면 모든 대상 목록이 표시됩니다. 제 경우에는 cocoapods가 UITest 대상에 대한 기본 구성을 자동으로 추가했습니다.

여기에 이미지 설명 입력

none드롭 다운에서로 설정합니다 .
받는 메뉴에서 다음으로 다음 UITest 대상을 선택 왼쪽 build phases당신은 제거해야합니다 check pods manifest.lock link binary with libraries emebd pods frameworkscopy pods resources.

마지막으로 포드 파일로 이동하여 UITest 대상에 대한 언급이 있는지 확인합니다. 제 경우에는 podfile 상단에 지정했습니다.

platform :ios, '8.4'
use_frameworks!

link_with 'My App', 'My UITesting Target' 

pod 'A Pod', '~> 1.0'

대신 podfile은 각 대상에 대한 특정 종속성을 나열해야합니다.

platform :ios, '8.4'
use_frameworks!

target 'My App', :exclusive => true do
    pod 'A Pod I want to use in my app', '~> 1.0'
end

UITests에서 포드를 사용하지 않았다고 가정하면 대상이 오류없이 다시 빌드되어야하며 테스트가 실행됩니다!

이 문제의 근원에 대한 나의 이해는 각 UITest 대상이 앱 용과 UITest 컨트롤러 용으로 하나씩 두 개의 개별 번들을 빌드한다는 것입니다. 불행히도 cocoapods link_with로직은 번들에서 pods.framework를 기대하도록 지정된 모든 대상을 수정합니다. 빌드 단계 스크립트는 UITest 컨트롤러 번들이 아닌 앱 번들에 프레임 워크를 추가하므로 테스트를 시작할 때 UITest 컨트롤러 번들에 프레임 워크가 누락 된 것으로 나타나고 xcode가 설치를 중단합니다.

UITests에서 포드를 사용하는 경우 동일한 방식으로 지정할 수 있어야합니다.

target 'My UITesting Target', :exclusive => true do
    pod 'Another Pod I want only for UITesting', '~> 1.0'
end

그리고 실행하면 pod install모든 것이 올바르게 연결되어야합니다.


This problem can also appears when you use Cocoapods with a framework where some dependencies are missing. For example if you are using Framework A, and this framework depends of Framework B but in the Podspec of Framework A the dependency is not declared.


One of the reasons this can happen is if the host application that the test target is testing is not linked to the right dependencies. For example, if you have are testing a framework, make sure the host app is linked to those frameworks and also embedded. 여기에 이미지 설명 입력


My problem was caused by incorrect deployment version of unittest target. Tested App deployment version was 7.0, but the unittest's was not set up correctly automatically. It was set to 10.0, while my simulator's version was 8.4. Change the UT target's deployment version to 8.0 in build settings and then all the problems disappeared.


I tried a bunch of these solutions with no luck. I turned off the Code Coverage option in my Scheme's Test section, which suppressed the error but Tests would not run. Then I noticed quite a bit of stuff in NSLog console. Somewhere in there, it mentioned reference to a framework that I was no longer using and trying to load.

I searched the app for it, and Build Settings -> Other Linker Flags was trying to load the framework that wasn't there anymore.

I removed: -framework 3rd_party_libname

Then tests worked again. This was confusing, but please check for NSLog msgs. I was using XCode 8.3


One or more of your simulators has gotten stuck. The only thing that always works to fix this for me is to reset the simulator content and settings from the Simulator menu.

콘텐츠 및 설정 재설정 ...

Note: this will delete all app data from the simulator.


After a long time trying to figure this out, it turned out that I had to create a brand new test target. Then after rebooting the device the problem no longer resurfaced.


In my case, I had added Swift files to a framework that was (until then) purely Objective-C. The test bundle did not have any Swift code in it.

Once I added a Swift file to the test bundle, Xcode automatically updated some project settings and the error went away.

You should keep the Swift file in the test bundle, even though it may not contain any code. Either Xcode or Cocoapods evidently use the existence of Swift files in the test bundle to determine whether to run the tests in "swift mode".


The root cause is probably the simulator failure. Issues with the simulator are common, especially on first launch.

If the problem occurs even after successful simulator launch and connect, please post the details of the error.

To get the simulator to launch, I often have to cancel the first run (after launching Xcode cleanly), and try re-running a few times.

If this is repeatable, happens on multiple projects, and persists after relaunch and cleaning of the projects, consider submitting a defect to Apple if the Stack Overflow community cannot help.


I had this same problem but it was due to having a test target and renaming the application's target. Make sure you have a valid Host Application set.

  • Choose the test target on the project page
  • Under the General tab there should be a Host Application select box
  • Choose the target you want to test against

I also faced same issue :

Tried following things for different projects :

1.For project where i had some third party frameworks, The problem was that test bundle can't find the framework at runtime. For this update test target's Runpath Search Paths build settings by adding $(PROJECT_DIR)/Frameworks (assuming you keep your frameworks at that location)., It fixed my problem for this project You can look for it at below location :

Project file -> Test target -> Build Settings -> Runpath Search Paths
  1. In other workspace, When I changed my testing device to some other simulator or change the device itself. it helped.

  2. Restart the xcode or your mac system.

hope it will help u


Carthage users:

This happened to me after I added a new framework to my Cartfile.

I ran carthage update but forgot to drag the .framework file from Finder into the Embedded Binaries section of my app target!

Once I did that, the problem went away.

(Note this is a specific case of the general problem mentioned by @Mustafa above.)


I was having this problem on Xcode 8.3 on Sierra 10.12.4

I opened the Keychain Access application on my Mac

After a few seconds, I got several system pop-ups asking for my password, to grant permissions to Keychain items.

I entered my password into the pop-ups, and then my tests starting working.


Steps that worked in my case Delete the scheme and clicking Manage Scheme->Auto generate scheme resolved the issue in my case.

Issue was caused by installing the certificate in the simulator and in the keychain


Using Xcode 9.1 with multiple build targets and standard compiler we were working on UI tests and I started seeing this problem. So, you will probably hate me for this answer, and I fully expect it to be downvoted, BUT this actually worked for me: I had to completely remove Xcode and my project from my machine to make this error disappear.

I tried every single suggestion in this thread, some multiple times, tried clearing cache files, deleting derived data, tinkering with build settings, updating podfiles, cleaning, rebuilding after each attempt, cleaning the simulator, manually recreating the simulators in 'manage devices'. After hours and hours of frustration it was still a complete mystery why this machine was failing to build our UI test. It seemed to work fine on other machines and on our CI. In addition to the items in this thread I manually modified the pbxproj file to set all options related to code coverage to "NO".

Finally, I was 1 step away from reformatting the entire machine. I decided to completely remove Xcode following the suggestions here: Stackoverflow: How to completely uninstall Xcode.

특히, 작업 공간을 비우고, 모든 프로그램을 종료하고, 나열된 모든 파일을 삭제하고, 시뮬레이터에서 콘텐츠와 설정을 지우고, 시뮬레이터를 삭제하고, 20 분 동안 머신을 끄고, 돌아와서 Xcode를 다시 설치하고, 저장소를 복제했습니다. ! 오류가 없습니다.

누군가를 위해 문제가 해결되기를 바랍니다. 그것은 '핵'옵션이고, 당신은 이것을 절대로 할 필요가 없지만, 제가 말했듯이, 이것이 저에게 효과가 있었던 유일한 것입니다.

참조 URL : https://stackoverflow.com/questions/32223965/xcode-7-code-coverage-data-generation-failed

반응형