Builds for testing fail when code coverage is enabled

Originator:brennan
Number:rdar://31228255 Date Originated:23-Mar-2017 02:35 PM
Status:Open Resolved:
Product:Xcode Product Version:8.2.1
Classification:bug Reproducible:Always
 
Summary:
I am unable to build due a linking error only when I build for testing when code coverage is enabled. If I turn off code coverage the build for testing is successful. I have added 2 framework targets with their own test targets which may be a contributing factor.

Steps to Reproduce:
1. Create a new iOS app project with a test target
2. Add an external Xcode project as a dependency
3. Add a framework target with tests
4. Add another framework test with tests
5. Enable code coverage in the build scheme
6. Build for testing

Expected Results:
The build should be successful for building the app target with or without test targets.

Actual Results:
Linking fails to the external project dependency. 

Version:
Xcode 8.2.1

Notes:
This is yet another reason many developers working with Xcode use as an excuse for not adding tests. Overcoming these build errors is time consuming and costly and ultimately it affects users who either end up using crashy apps or do not get features which were cut due to time wasted with getting Xcode to work.

Comments

Build Log (Obfuscated)

Ld /Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Intermediates/AnyFramework.build/Debug-iphonesimulator/AnyFramework.build/Objects-normal/x86_64/AnyFramework normal x86_64 cd /Users/username/workspace/Coconut/src/AnyFramework export IPHONEOS_DEPLOYMENT_TARGET=8.0 export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk -L/Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator -L/Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator -L/Users/username/workspace/Coconut/src/AnyFramework/Dependencies/Security -L/Users/username/workspace/Coconut/src/AnyFramework/Dependencies/xlib -L/Users/username/workspace/Coconut/src/AnyFramework/Dependencies/jellybean -F/Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator -F/Users/username/workspace/Coconut/src/AnyFramework -F/Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Products/iphonesimulator -F/Users/username/workspace/Coconut/src/AnyFramework/Dependencies/jellybean/frameworks -F/Users/username/workspace/Coconut/src/AnyFramework/Dependencies/WebRTC -filelist /Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Intermediates/AnyFramework.build/Debug-iphonesimulator/AnyFramework.build/Objects-normal/x86_64/AnyFramework.LinkFileList -install_name @rpath/AnyFramework.framework/AnyFramework -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -mios-simulator-version-min=8.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Intermediates/AnyFramework.build/Debug-iphonesimulator/AnyFramework.build/Objects-normal/x86_64/AnyFramework_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -fprofile-instr-generate -stdlib=libc++ -ObjC -read_only_relocs suppress -lresolv -lylib-videodev -lxlib2 -lyuv -lpjnath -lilbccodec -lz -lssl -lylib -lxlib-ua -lsrtp -lylib-codec -lspeex -lpj -lxlib3 -lxlib32 -lcrypto -lxlib4-util -lylib-audiodev -lxlib-simple -lgsmcodec -lxlib -framework JRE -framework JSR305 -framework Guava -framework WebRTC -single_module -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Intermediates/AnyFramework.build/Debug-iphonesimulator/AnyFramework.build/Objects-normal/x86_64/AnyFramework_dependency_info.dat -o /Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Intermediates/AnyFramework.build/Debug-iphonesimulator/AnyFramework.build/Objects-normal/x86_64/AnyFramework

ld: warning: directory not found for option '-F/Users/username/Library/Developer/Xcode/DerivedData/AnyApp-bgdswhfjrfkmkdgxuheiabddppkg/Build/Intermediates/CodeCoverage/Products/iphonesimulator'


ld: warning: object file (/Users/username/workspace/Coconut/src/CoreLibKit/Dependencies/AnyCLibrary/libsystemx.a(shoes_udp.o)) was built for newer iOS version (8.1) than being linked (8.0)

"_XYComponentMediaManager_initialize", referenced from:

  ___profd_XYComponentMediaManager_initialize in XYCakeManager.o

 (maybe you meant: ___profc_XYComponentMediaManager_initialize, ___profd_XYComponentMediaManager_initialize )

"_XYPeerConnection_initialize", referenced from:

  ___profd_XYPeerConnection_initialize in PeerConnection.o

 (maybe you meant: ___profd_XYPeerConnection_initialize, ___profc_XYPeerConnection_initialize )

"_XYXYWaffleDescription_Type_initialize", referenced from:

  ___profd_XYXYWaffleDescription_Type_initialize in XYWaffleDescription.o

  ___profd_XYXYWaffleDescription_Type_initialize in XYCakeXYWaffle.o

 (maybe you meant: ___profc_XYXYWaffleDescription_Type_initialize, ___profd_XYXYWaffleDescription_Type_initialize )

"_XYSystemCommand_initialize", referenced from:

  ___profd_XYSystemCommand_initialize in VideoEffectCommand.o

 (maybe you meant: ___profc_XYSystemCommand_initialize, ___profd_XYSystemCommand_initialize )

"_XYJellybeanMessage_initialize", referenced from:

  ___profd_XYJellybeanMessage_initialize in Message.o

 (maybe you meant: ___profc_XYJellybeanMessage_initialize, ___profd_XYJellybeanMessage_initialize )

Reproducing the problem

I've assembled an Xcode configuration with multiple build targets and embedded libraries to try to recreate the problem. So far it is not failing. I've included notes at the bottom of the README.md about ways that the bug could be reproduced.

https://github.com/brennanMKE/Radar31228255

Related Radar

http://www.openradar.me/23588122


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!