Xcode custom build configuration causes “library/file not found” for static libraries

前端 未结 7 2000
心在旅途
心在旅途 2020-12-02 14:13

I have a workspace with a project which links with the static libraries in another project (which is also in the workspace). It\'s a problem in Kobold2D I haven\'t been able

7条回答
  •  青春惊慌失措
    2020-12-02 15:02

    I have a similar problem using CocoaPods and trying to have more than one Adhoc (or Enterprise, or Beta) configurations.

    Here is what seems to work (let's say that both projects are lying in the same xcworkspace):

    • Add the subproject generated lib to the mainproject Link Binary with Libraries.

    • As the configuration Adhoc is not known by the subproject, Xcode will use the Release config as a fallback (or maybe the first config of the list) when building it.

    • The linker will complain because it cannot find the lib… ok, let's handle this one.

    • Add a Run Script build phase to the mainproject, right after the Target Dependencies phase. Enter this script:

    if [ "$CONFIGURATION" = "Adhoc" ]; then
        echo "====================================="
        echo "Copying libPods Release into the Adhoc product build dir!"
        echo "====================================="
        cp "$BUILT_PRODUCTS_DIR/../Release-$PLATFORM_NAME/libPods.a" "$BUILT_PRODUCTS_DIR"
    else
        echo "No manual lib copy."
    fi
    

    This will copy the lib generated by the subproject Release build (which will happen when mainproject is built) in the Adhoc build directory, so that the linker will find the lib. And we should be good to go! Yeah!

提交回复
热议问题