Be more lenient when stripping frameworks and dSYMs for non fat binaries

parent 9fc47007
...@@ -14,6 +14,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -14,6 +14,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes ##### Bug Fixes
* Be more lenient when stripping frameworks and dSYMs for non fat binaries
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7196](https://github.com/CocoaPods/CocoaPods/issues/7196)
[#5854](https://github.com/CocoaPods/CocoaPods/issues/5854)
* Do not display script phases warnings multiple times per platform * Do not display script phases warnings multiple times per platform
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7193](https://github.com/CocoaPods/CocoaPods/pull/7193) [#7193](https://github.com/CocoaPods/CocoaPods/pull/7193)
......
...@@ -43,10 +43,14 @@ module Pod ...@@ -43,10 +43,14 @@ module Pod
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
# Used as a return value for each invocation of `strip_invalid_archs` function.
STRIP_BINARY_RETVAL=0
# This protects against multiple targets copying the same framework dependency at the same time. The solution # This protects against multiple targets copying the same framework dependency at the same time. The solution
# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
# Copies and strips a vendored framework
install_framework() install_framework()
{ {
if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
...@@ -95,7 +99,7 @@ module Pod ...@@ -95,7 +99,7 @@ module Pod
fi fi
} }
# Copies the dSYM of a vendored framework # Copies and strips a vendored dSYM
install_dsym() { install_dsym() {
local source="$1" local source="$1"
if [ -r "$source" ]; then if [ -r "$source" ]; then
...@@ -112,9 +116,14 @@ module Pod ...@@ -112,9 +116,14 @@ module Pod
strip_invalid_archs "$binary" strip_invalid_archs "$binary"
fi fi
if [[ $STRIP_BINARY_RETVAL == 1 ]]; then
# Move the stripped file into its final destination. # Move the stripped file into its final destination.
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\\" \\"${DWARF_DSYM_FOLDER_PATH}\\"" echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" --filter \\"- Headers\\" --filter \\"- PrivateHeaders\\" --filter \\"- Modules\\" \\"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\\" \\"${DWARF_DSYM_FOLDER_PATH}\\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}"
else
# The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.
touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM"
fi
fi fi
} }
...@@ -136,10 +145,18 @@ module Pod ...@@ -136,10 +145,18 @@ module Pod
# Strip invalid architectures # Strip invalid architectures
strip_invalid_archs() { strip_invalid_archs() {
binary="$1" binary="$1"
# Get architectures for current file # Get architectures for current target binary
archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
# Intersect them with the architectures we are building for
intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\\n' | sort | uniq -d)"
# If there are no archs supported by this binary then warn the user
if [[ -z "$intersected_archs" ]]; then
echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
STRIP_BINARY_RETVAL=0
return
fi
stripped="" stripped=""
for arch in $archs; do for arch in $binary_archs; do
if ! [[ "${ARCHS}" == *"$arch"* ]]; then if ! [[ "${ARCHS}" == *"$arch"* ]]; then
# Strip non-valid architectures in-place # Strip non-valid architectures in-place
lipo -remove "$arch" -output "$binary" "$binary" || exit 1 lipo -remove "$arch" -output "$binary" "$binary" || exit 1
...@@ -149,6 +166,7 @@ module Pod ...@@ -149,6 +166,7 @@ module Pod
if [[ "$stripped" ]]; then if [[ "$stripped" ]]; then
echo "Stripped $binary of architectures:$stripped" echo "Stripped $binary of architectures:$stripped"
fi fi
STRIP_BINARY_RETVAL=1
} }
SH SH
......
Subproject commit cd417b2a8a34c2c8630336b29b4b4405df9500b5 Subproject commit 8c89eea40c9c7fe29af512bae03f63285913e47a
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment