Dynamic "test host" or package loader for testing iOS modules?

How to make a dynamic host / bundle loader dynamic based on the current schema? Currently, the value is:

$(BUILT_PRODUCTS_DIR)/MyApp1.app/MyApp1 

The problem is that I have 4 applications in the workspace, and I would like to use the same set of testing modules for all of them. How can I dynamically change part of "MyApp1" based on the current schema? Is this an environment variable based at build time? I tried setting it up for things like $ (PROJECT_NAME), but it looks like they got the name of the test suite.

+6
source share
1 answer

To do this, you need to have a variable inside the build settings, which seems simple, but it is not. If you set the environment variable through a Pre- or Post-step in an application or testing scheme, it looks like it will not be found here. Build settings, after all, happen before the build. The same applies to the preprocessor macro, although doing this with xcodebuild and passing a custom option may work.

The only way I know is to use the xcconfig file. Create it and apply it (at least) to the test target. Content should include the following: THINGUNDERTEST=FooBar

Now in the settings of your project, in the xcconfig file or in the project file, set BUNDLER_LOADER to: $(BUILT_PRODUCTS_DIR)/$(THINGUNDERTEST).app/$(THINGUNDERTEST)

It will work. Now you can change THINGUNDERTEST using various means and get at least some dynamic behavior. This may work for you or may not, depending on your needs, but it is probably just a starting point.

+7
source

Source: https://habr.com/ru/post/949482/


All Articles