I am developing an app and I am using an open source component.
I have a workspace containing both MyApp.xcodeproj and Component.xcodeproj. My app has three configurations: Debug, App Store and In House but the component has only two: Debug and Release
In the Debug configuration, everything works fine, but I can't compile my app in App Store or In House configuration because the configuration names do not match. I get a file not found error when trying to #import <Component/Component.h>
I need both App Store and In House configurations and I would really like to avoid modifying the component's configurations in order to ease future updates of the component.
I know I could use CocoaPods to solve this issue but I would like to know if there is a simple solution in Xcode
You can get your project to compile with some tweaks to your app’s settings.
I suggest you to modify all settings at the project level so that all your targets can inherit these settings.
Add a new
DEFAULT_CONFIGURATION
user-defined setting and define your configuration mapping. This is how it should look like:Set
FRAMEWORK_SEARCH_PATHS
to$(BUILD_DIR)/$(DEFAULT_CONFIGURATION)-$(PLATFORM_NAME)
for all configurations, add Any OS X SDK variants and set the value to$(BUILD_DIR)/$(DEFAULT_CONFIGURATION)
. SetHEADER_SEARCH_PATHS
to$(FRAMEWORK_SEARCH_PATHS)/include
andLIBRARY_SEARCH_PATHS
to$(FRAMEWORK_SEARCH_PATHS)
. This is how it should look like:This step is quite tedious, it can be automated with the xcproj tool and by running this script in your project directory. Edit your configurations mapping as needed.
If the component is distributed as a static library, you are done here. If the component comes as a framework you have to update its path reference by editing your project.pbxproj file in a text editor. In the PBXFileReference section (under
/* Begin PBXFileReference section */
) findComponent.framework
and update itspath
like this:Also make sure that the
sourceTree
is set toBUILT_PRODUCTS_DIR
, i.e. relative to built products. Once you edited the project file, this should look like:Your project should now build as expected.