Cocoapods: UI Test Targets do not generate valid test bundles when using frameworks

Created on 11 Mar 2016  ·  4Comments  ·  Source: CocoaPods/CocoaPods

What did you do?

Added a KIF UI Testing target to my project

What did you expected to happen?

I expect to be able to run my UI Test target using CP's generated frameworks

What happened instead?

The test bundle cannot be loaded:

2016-03-10 17:20:03.344 FrameworksIntegration[4274:1256151] The bundle “FrameworksIntegrationKIFTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-03-10 17:20:03.345 FrameworksIntegration[4274:1256151] (dlopen_preflight(/Users/michele/Library/Developer/Xcode/DerivedData/FrameworksIntegration-cneyifjmzbeardhlhwpbojjoaxrp/Build/Products/Debug-iphonesimulator/FrameworksIntegrationKIFTests-Runner.app/PlugIns/FrameworksIntegrationKIFTests.xctest/FrameworksIntegrationKIFTests): Library not loaded: @rpath/KIF.framework/KIF
  Referenced from: /Users/michele/Library/Developer/Xcode/DerivedData/FrameworksIntegration-cneyifjmzbeardhlhwpbojjoaxrp/Build/Products/Debug-iphonesimulator/FrameworksIntegrationKIFTests-Runner.app/PlugIns/FrameworksIntegrationKIFTests.xctest/FrameworksIntegrationKIFTests
  Reason: image not found)

This is (likely) due to a different TARGET_BUILD_DIR causing @rpath to be further down the tree from the main CONFIGURATION_BUILD_DIR where the frameworks are:

TARGET_BUILD_DIR = /Users/michele/Library/Developer/Xcode/DerivedData/FrameworksIntegration-gqwvjrovjkymuvgxnryvnnwzcchu/Build/Products/Debug-iphoneos/FrameworksIntegrationKIFTests-Runner.app//PlugIns

Aka Xcode is complaining that KIF.framework is not in PlugIns.

Sample project is here.

Podfile

platform :ios, '9.0'

use_frameworks!

target 'FrameworksIntegration' do 
    pod 'CocoaLumberjack'
end

target 'FrameworksIntegrationKIFTests' do
    pod 'KIF'
    pod 'CocoaLumberjack'
end

This became an issue in beta4 when frameworks moved out of the Pods-TargetName folders and into their own folders. Thankfully beta3 allows us to run tests. We cannot update to a newer version until the paths issues are resolved.

I've done a lot of digging so let me know if other info is needed.

awaiting validation defect

Most helpful comment

Is this issue fixed? I am facing the same issue and not able to find a solution.

All 4 comments

Excellent investigation so far. :+1: I'm looking further into that. But it's really odd that the test binary is not picking up the frameworks from the xctest bundle, where they are all back in a flat structure.

Okay, so for UI tests Xcode generates an on-the-fly app, which uses the xctest bundle as plugin. It overwrites the TARGET_BUILD_DIR for that purpose in an undocumented way. :tada: We're relying in the generated embed frameworks script on CONFIGURATION_BUILD_DIR as destination, which is indeed not the correct var. Fix is on the way, you might be able to adopt it manually if needed until it is shipped.

Solution: Just set manually your Host Application
screen shot 2016-10-17 at 16 23 37

Is this issue fixed? I am facing the same issue and not able to find a solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marzapower picture marzapower  ·  3Comments

pallaviMN picture pallaviMN  ·  3Comments

steffendsommer picture steffendsommer  ·  3Comments

Mingmingmew picture Mingmingmew  ·  3Comments

intelliot picture intelliot  ·  3Comments