Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Framework Based on Current Target

Tags:

ios

swift

swift3

I get Ambiguous use of method error. The reason is because I have a project with two targets, and the targets use either of two frameworks that have the same methods but with different theme usages.

Based on the selected target, I wish to import a different framework on the same file. For example:

InitializeViewController.swift

For Theme A

import FrameworkX

For Theme B

import FrameworkY

How do I import either framework based on the selected target to avoid ambiguous error? Or is there another better approach?

like image 320
elefante Avatar asked Mar 10 '23 17:03

elefante


1 Answers

In your target's build settings, Swift Compiler - Custom Flags -> Other Swift Flags, add a flag for one target, say -DTargetX

Then…

#if TargetX 
import FrameworkX
#else
import FrameworkY
#endif
like image 135
Ashley Mills Avatar answered Mar 19 '23 23:03

Ashley Mills