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

Fixed compilation of conditional imports using #if. #403

Closed
wants to merge 2 commits into from

Conversation

dzinchenkogd
Copy link

Closes #398

We have a framework that has a build condition SWIFT_ACTIVE_COMPILATION_CONDITIONS = APPEXTENSION; And based on that condition, we are importing the following libraries.

#if APPEXTENSION
import CustomAppExtension
#else
import Custom
#endif

The problem we are facing is that the generated mocks do not have this #if statement. They import both libraries (which causes a build fail) like below:

import CustomAppExtension
import Custom

Instead, we would require the imports to happen as in the original file:

#if APPEXTENSION
import CustomAppExtension
#else
import Custom
#endif

Would it be possible to update Cuckoo to recognize that #if block?

My solution is to check the possibility to import framework:

#if canImport(CustomAppExtension)
import CustomAppExtension
#endif

#if canImport(Custom)
import Custom
#endif

This fix works when the single framework is embedded into the target.

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

Successfully merging this pull request may close these issues.

#if Import condition is not respected
1 participant