Giovanni Giovanni - 2 months ago 17
Swift Question

Xcode target membership for test and project files

In our project the target membership separates our test and project files. However we need to have a few files that can see both the project and test files so that we can modify data in our app for test certain automated-test cases. If I try to change the target membership in one location, every other file the changed file touches must also have the target membership modified, meaning we eventually must change every single file in the project.

Is there an easy way to add a file that can see both the project and test files without modifying every single file in the project?


So this was the workaround that was used to solve this problem. I could not get the test files to see the app, but I could get the app to see the test files, without changing every single file in the project. What I had to do was duplicate the object structures within the test files themselves so we could create test object from those file that could be used in our database.

From there, I created an object mapper that transformed the test objects that were located in our test files to app objects(the objects the test files could not see). This worked because our app was able to see both the testObject and the actual object, as well as the data mapper, allowing us to insert testObjects into our database as app objects during our automated testing, which is essentially what we wanted.

Lengthy workaround, but it worked.