# Swift Packages in multiple targets results in “This will result in duplication of library code.” errors

**URL:** <https://forums.swift.org/t/swift-packages-in-multiple-targets-results-in-this-will-result-in-duplication-of-library-code-errors/34892>\
**Category:** Using Swift\
**Tags:** xcode, packagemanager\
**Created:** [March 28, 2020, 4:35pm UTC](https://forums.swift.org/t/swift-packages-in-multiple-targets-results-in-this-will-result-in-duplication-of-library-code-errors/34892 "2020-03-28T16:35:48Z")\
**Posts on this page:** 1\
**Showing post:** 57

<div class="post-metadata">

**Author:** ![pewe](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pewe/32/4631_2.png) [@pewe](https://forums.swift.org/u/pewe)\
**Post date:** [May 21, 2021, 5:12am UTC](https://forums.swift.org/t/swift-packages-in-multiple-targets-results-in-this-will-result-in-duplication-of-library-code-errors/34892/57 "2021-05-21T05:12:13Z")

</div>

So we finally seem to have solved our problem with a post-build script that moves all embedded frameworks to "APP.app/Frameworks" (and re-signs everything):

```
cd "${CODESIGNING_FOLDER_PATH}/Frameworks/"
    for framework in *; do
        if [-d "$framework"]; then
            if [-d "${framework}/Frameworks"]; then
                echo "Moving embedded frameworks from ${framework} to ${PRODUCT_NAME}.app/Frameworks"
                cp -R "${framework}/Frameworks/" .
                rm -rf "${framework}/Frameworks"
            fi
        fi
    done
    
    if [[ "${CONFIGURATION}" == "Debug"] & ["${SDKROOT}" != *Simulator*] ] ; then
        find "${CODESIGNING_FOLDER_PATH}" -name "*.framework" -print0 | while read -d $'\\0' framework
        do
            if ["${framework}" != "NULL"] ; then
                codesign --force --deep --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --preserve-metadata=identifier,entitlements --timestamp=none "${framework}"
            fi
        done
        
        echo "Resigning ${PRODUCT_NAME}.app after moving frameworks"
        codesign --force --deep --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --preserve-metadata=identifier,entitlements --timestamp=none "${CODESIGNING_FOLDER_PATH}"
    else
        echo "Info: CODESIGNING is only needed for Debug on device (will be re-signed anyway when archiving) "
    fi

```

This has also solved this problem for us: [SwiftPM binaryTarget dependency and code signing](https://forums.swift.org/t/swiftpm-binarytarget-dependency-and-code-signing/38953/1)

---

_[View the full topic](https://forums.swift.org/t/swift-packages-in-multiple-targets-results-in-this-will-result-in-duplication-of-library-code-errors/34892)._
