UI Tests fail to run when project is first created with a Framework, and application target comes later

Number:rdar://23412056 Date Originated:05-Nov-2015 08:38 AM
Status:Open Resolved:
Product:iOS Product Version:Xcode: Version 7.1 (7B91b) - iOS Simulator: Version 9.1 (13B137)
Classification:Crash Reproducible:Always
Given a project with at least 3 targets: Framework, Application, UI Tests.

If the first target created in a project is a framework, then the application target isn't properly linked with the framework when it get's created and added to the project.  Because of the improper linking of the framework with the application, the UI Test target is not able to execute it's tests, even though it compiles properly.

Steps to Reproduce:
I've included two example projects, along with the logs.  

The project "Example-Broken-Frmwrk" was created by: 
1. Select "Cocoa Touch Framework" as the new project template
2. Configure Options (name, org ID, etc.) however you'd like.  I left "Include Unit Tests" checked
3. Add code to the framework, to be used in the next target (Application)
4. Create a new target (iOS -> Application -> Single View Application)
    a. Language: Swift
    b. Devices Universal
    c. Leave checked the boxes to create the Unit Tests and UI Tests
    d. Project: Same "Example-Broken"
5. Create a simple UI in the newly created target, making sure to import/use the code from the framework (first target). - This is where the bug happens.  Don't do this, and the UI Tests in step 8 will run just fine.
7. Create a simple UI Test that tests something about Target #2
8. Run the UI Tests

The difference between the "Broken" project and the "Works" project is simply that I had to go in and add the framework to the "Embedded Binaries" section on the project settings page.

Expected Results:
I expect the UI Tests to run and report on the pass/failure of the UI Tests written

Actual Results:
An error is thrown and the process ends because it cannot run the tests.

dyld: Library not loaded: @rpath/Broken.framework/Broken
  Referenced from: /Users/<username>/Library/Developer/CoreSimulator/Devices/A8610398-E90B-4480-8F01-C5146D86D39A/data/Containers/Bundle/Application/3CDF0C66-52FF-4EC2-B917-7962801F5ACB/BrokenDemo.app/BrokenDemo
  Reason: image not found

The plot thickens when you have a workspace, and the frameworks are in a different project from the Application Target and accompanying tests.  For some reason I cannot add frameworks from Project A into the demo app in Project B.  When I click on the add button on "Embedded Binaries" on Project B (Demo App), the frameworks in Project A show up, but when I select the framework -> Ok, the framework acts like it's going to be added, but never is added.  I haven't found a way to work around this, and it prevents UI Tests from being run.

I've included the file "ReallyBroken.zip" with an example project that illustrates that.

iPhone 6s simulator, 9.1

'Session-2015-11-04_11:14:02-6elAwb.log', 'Broken.zip', 'ReallyBroken.zip' and 'Works.zip' were successfully uploaded.


To fix this I had to create a new Copy Files build phase in the UI tests App target (not the UI tests target). That build phase copied the framework to the Frameworks destination.

Hi there! Did you found a way to solve that? Experience the same issue atm: created Swift Framework and trying to add it into TestApp. TestApp works good, but TestAppUITests fails to run correctly, outputs:

dyld: Library not loaded: @rpath/MySDK.framework/MySDK Referenced from: /Users/user/Library/Developer/CoreSimulator/Devices/A5D10093-13FA-424A-91B1-52CDDDAC8EEB/data/Containers/Bundle/Application/C13307D2-157A-4045-B4C1-EFA715464F2A/TestApp.app/TestApp Reason: image not found

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!