Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly process multiple xcframeworks a pod provides. #10884

Merged
merged 1 commit into from Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -12,7 +12,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Bug Fixes

* None.
* Correctly process multiple `xcframeworks` a pod provides.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#10378](https://github.com/CocoaPods/CocoaPods/issues/10378)


## 1.11.0.beta.2 (2021-08-11)
Expand Down
32 changes: 2 additions & 30 deletions lib/cocoapods/generator/copy_xcframework_script.rb
Expand Up @@ -70,8 +70,8 @@ def script
local destination="$2"

# Use filter instead of exclude so missing patterns don't throw errors.
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" \\"${source}\\" \\"${destination}\\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}" "${destination}"
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" \\"${source}*\\" \\"${destination}\\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}"/* "${destination}"
Copy link
Contributor Author

@dnkoutso dnkoutso Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we now make rsync expand the file list from the directory rather than copying the directory itself. Since we use --delete it also meant we delete other folders or files as part of this process when multiple xcframeworks are installed by a single pod.

From SO:


  --delete
    This  tells  rsync to delete extraneous files from the RECEIVING SIDE (ones
    that AREN’T ON THE SENDING SIDE), but only for the directories that are
    being synchronized.  **You must have asked rsync to send the whole directory
    (e.g.  "dir" or "dir/") without using a wildcard for the directory’s contents
    (e.g. "dir/*") since the wildcard is expanded by the shell and rsync thus
    gets a request to transfer individual files, not the files’ parent directory.**
    Files  that  are  excluded  from  the transfer are also excluded from being
    deleted unless you use the --delete-excluded option or mark the rules as
    only matching on the sending side (see the include/exclude modifiers in the
    FILTER RULES section).  ...

This also preserves the --delete functionality that if a .framework inside an .xcframework has changed (due to updating the pod) that added files are included and deleted files are removed.

}

SELECT_SLICE_RETVAL=""
Expand Down Expand Up @@ -130,33 +130,6 @@ def script
done
}

install_library() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amorde I noticed this isn't called anywhere along with the one below.

are they used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these dont seem to be used, all tests pass and examples build now without it. I think its dead code

local source="$1"
local name="$2"
local destination="#{Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/${name}"

# Libraries can contain headers, module maps, and a binary, so we'll copy everything in the folder over

local source="$binary"
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" \\"${source}/*\\" \\"${destination}\\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}/*" "${destination}"
}

# Copies a framework to derived data for use in later build phases
install_framework()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
local source="$1"
local name="$2"
local destination="#{Pod::Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/${name}"

if [ ! -d "$destination" ]; then
mkdir -p "$destination"
fi

copy_dir "$source" "$destination"
echo "Copied $source to $destination"
}

install_xcframework() {
local basepath="$1"
local name="$2"
Expand All @@ -179,7 +152,6 @@ def script
fi

copy_dir "$source/" "$destination"

echo "Copied $source to $destination"
}

Expand Down