xcode add embedded binary with buildscript
Asked Answered
H

2

9

I have been given a dynamic framework from a third party which does not compile on X86_64 based archs at linker stage due missing symbols, I have asked them repeatedly bundle this architecture with their framework, but they haven't been able to do so until now.

Now my question is the following, I can't find anyway to add the stage embedded binary stage using the build settings, how are the embedded binaries linked to the app during the build/linker process?

I know that if they do so, i might have to strip the arch from the framework, but it beats to not being able to compile the framework.

Heimdall answered 3/11, 2016 at 11:13 Comment(0)
A
14

Thank you @RicardoDuarte; There is my script for both iPhone & simulator.

Example_To=$BUILT_PRODUCTS_DIR"/"$PRODUCT_NAME".app/Frameworks/Example.framework/"
Example_From=$PROJECT_DIR"/../out/Build/Products/"$CONFIGURATION$EFFECTIVE_PLATFORM_NAME"/Example.framework"

mkdir -p $BUILT_PRODUCTS_DIR"/"$PRODUCT_NAME".app/Frameworks"
cp -Rv $Example_From $Example_To

if [[ $PLATFORM_NAME == 'iphoneos' ]]; then
    CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}"

    if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then
        CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}"
    fi

    codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" $Example_To
fi

I also added path to framework

$(PROJECT_DIR)/../out/Build/Products/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

to "Framework Search Paths" and "Header Search Paths", your's path and framework name can be different of course.

Allantoid answered 22/5, 2019 at 11:8 Comment(2)
And one more interesting way to solve 'universal-framework' problem.. medium.com/allatoneplace/…Allantoid
I was having issues until I realised that it couldn't handle spaces. The fix was to add extra quotes e.g: "$Example_To".Suzy
H
11

It turns out that the embedded binary stage is nothing more than xcode copying the .framework into the an target bundle Framework folder so to achieve my final intentions of creating a script that adds a framework completely manually.

Which resulted in two scripts, one that is added right after target dependencies in build phases, must be before compile sources:

if [[ $PLATFORM_NAME == 'iphoneos' ]]; then

    SOME_FRAMEWORK=$BUILT_PRODUCTS_DIR"/"$PRODUCT_NAME".app/Frameworks/someframework.framework/"
    export LIBRARY_SEARCH_PATHS=$LIBRARY_SEARCH_PATHS" "$SDKROOT"/someframework.framework"
fi

and Another script and link binary with Libraries, where i copy and sign the framework.

if [[ $PLATFORM_NAME == 'iphoneos' ]]; then
    MY_FRAMEWORK=$BUILT_PRODUCTS_DIR"/"$PRODUCT_NAME".app/Frameworks/someframework.framework/"
    mkdir -p $BUILT_PRODUCTS_DIR"/"$PRODUCT_NAME".app/Frameworks"
    cp -Rv $PROJECT_DIR"/someframework.framework" $MY_FRAMEWORK

    CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
    if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then
        CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}"
    fi

    codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" $MY_FRAMEWORK"/<binary of framework>"
fi

this is just a quick rough script i created quickly to achieve this. I only allow this to happen i target is a device as this was my original intentions. but it can be removed.

Heimdall answered 8/11, 2016 at 10:18 Comment(1)
Worked for me! Additionally do not forget to set Runpath Search Path to @executable_path/Frameworks in Build Settings.Burd

© 2022 - 2024 — McMap. All rights reserved.