Pablo Fernandez
Pablo Fernandez

Reputation: 287500

When added an embedded framework in an Xcode project, how do you differentiate between Debug and Release?

When I add a framework to my Xcode project, to be embedded in my app bundle, how do I make two different options for whether it's Debug or Release (I have two versions of the framework, one compiled for release and one for debug).

This is what I'm referring to:

enter image description here

As you see, with that configuration, it'll just copy the one on CEF/Debug regardless of whether it's in being compiled in Release or Debug mode.

Ideally I want something like you have for setting:

enter image description here

Upvotes: 5

Views: 1258

Answers (3)

iUrii
iUrii

Reputation: 13808

You can manage frameworks to embed with your custom Run Script in Build Phases:

#!/bin/bash

# Your frameworks to embed
FRAMEWORK="Debug.framework"
if [ $CONFIGURATION == "Release" ]; then
    FRAMEWORK="Release.framework"
fi

# Destination to copy inside the app's frameworks folder
NAME=$(basename $FRAMEWORK)
DESTINATION=${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/$NAME

# Don't copy if it's already copied
if [ ! -d $DESTINATION ]; then
    # Copy the framework to the app's frameworks folder
    cp -r $FRAMEWORK $DESTINATION

    # Sign (if needed)
    codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements $DESTINATION
fi

Upvotes: 2

David Bemerguy
David Bemerguy

Reputation: 1364

You don't need to. Embedded frameworks will build according to the build of the consumer app. You can test it by adding a build schema on the app (like Debug2) and then compiling. You will receive an error from the embedded because it tried to compile it with the Debug2 schema, which is not available in the embedded framework. Now duplicate some schema and call it Debug2. It will build.

Upvotes: 0

Christopher Ian  Stern
Christopher Ian Stern

Reputation: 1412

Note that you can bring in different shared libraries (such as frameworks) by setting the environment var DYLD_IMAGE_SUFFIX for your app. So if inside your (one) framwork you had CEF.framework/Versions/Curent/CEF and CEF.framework/Versions/Curent/CEF_debug and you set the env var DYLD_IMAGE_SUFFIX=_debug it will load the second for that run.

Upvotes: 0

Related Questions