xcodexctestbuild-settings

Exclude a file form project at compile time swift3.2 - xcode


I have one file which reference I have added in xcode main project target and test case both.

This file reference needs to be added to main project only when test cases are running.

I don't want to include it when I create main project build since this file is for testing purpose only.

What is the best way to remove reference from main project when test cases are not running?


Solution

  • I have resolved my issue by using Exclude files setting from xcode's build setting.

    I have added mock file reference to both app and test target.

    Then for release and AppStore build configuration I have excluded mock file so that it doesn't any extra size in app store build.

    Since test cases run only in debug mode. This is safe solution.