Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a Host Application yo my test target #528

Closed
asalom opened this issue Oct 2, 2019 · 2 comments
Closed

Setting a Host Application yo my test target #528

asalom opened this issue Oct 2, 2019 · 2 comments

Comments

@asalom
Copy link

asalom commented Oct 2, 2019

Need/problem

I need to set a specific Host Application to my Target of type .unitTests which tests a Target of type .framework.

Motivation

I have a Target of type .framework which makes use of the Keychain. In order to test the Keychain, the tests have to run in a device, they can't run directly on the framework. In other words, there can't be a Keychain without a Simulator or device.

I've tried to change the test target settings with:

Settings(
  base: [
    "TEST_HOST": "$(BUILT_PRODUCTS_DIR)/HostTarget.app/HostTarget"
  ], 
  configurations: [.debug(name: "Debug"), .release(name: "Release")], 
  defaultSettings: .recommended
)

However, this is not enough and it produces the following configuration, where the Host Application is not being set properly.
Screenshot 2019-10-01 at 17 11 46

I've tried to manually change the Host Application from Xcode user interface, and the changes that are applied to the xcodeproj file include setting TEST_HOST to $(BUILT_PRODUCTS_DIR)/HostTarget.app/HostTarget but also TestTargetID = E4E2F9AB233E5A0600B3CE9B; and this I have no idea how to obtain from the Project.swift file

Visual desired outcome

Screenshot 2019-10-01 at 16 53 29

@kwridan
Copy link
Collaborator

kwridan commented Oct 2, 2019

Hi @asalom

I believe this is already supported

#300

The way to get it working is to add the Application targets as a dependency to the unit test target and that should set the appropriate test host.

We should update the docs to capture this :)

Hope this helps

@asalom
Copy link
Author

asalom commented Oct 2, 2019

It worked like a charm, thank you. I will leave my configuration in case someone else faces the same issue.

let tests = Target(
  name: "CommonTests",
  platform: .iOS,
  product: .unitTests,
  bundleId: "com.vodafone.CommonTests",
  infoPlist: "Tests/Info.plist",
  sources: "Tests/**",
  dependencies: [
    .target(name: "Common"), // product is .framework
    .target(name: "HostTarget") // product is .app
  ]
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants