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

Fix build error after embedded framework changed #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/motion/project/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,23 @@ def build(config, platform, opts)
FileUtils.mkdir_p(app_frameworks)
embedded_frameworks.each do |src_path|
dest_path = File.join(app_frameworks, File.basename(src_path))
if !File.exist?(dest_path) or File.mtime(src_path) > File.mtime(dest_path)

# If the framework changed -- for example, it was recompiled or
# updated to a newer version -- then we need to first remove the old
# version from the app bundle in the build folder.
#
# Otherwise the copy command below copies the new framework version
# as a *subfolder* of the old one.
#
# Also, we can't simply pass `remove_destination: true` to the copy
# command below because that only works if the destination is a
# regular file, and not a directory.
if File.exist?(dest_path) and File.mtime(src_path) > File.mtime(dest_path)
App.info 'Remove', dest_path
FileUtils.rm_r dest_path if File.exist?(dest_path)
end

if !File.exist?(dest_path)
App.info 'Copy', src_path
FileUtils.cp_r(src_path, dest_path)
end
Expand Down