From e43e3e3ff780d130a1e1402ed9eabf0aa54c5c1d Mon Sep 17 00:00:00 2001 From: Akaps316 <48785708+Akaps316@users.noreply.github.com> Date: Fri, 3 Apr 2026 19:54:54 +0530 Subject: fix(xcode.application): use the correct framework rpath for iOS apps Use @executable_path/Frameworks for iphoneos application bundles when embedding dependent frameworks. The existing @executable_path/../Frameworks rpath is correct for macOS app layout, but incorrect for iOS where the executable lives directly in MyApp.app and embedded frameworks live in MyApp.app/Frameworks. Add a regression test that builds an iOS simulator app with an embedded framework and verifies the generated LC_RPATH. --- xmake/rules/xcode/application/build.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xmake/rules/xcode/application/build.lua') diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua index 8ea734d28..7d1c836fa 100644 --- a/xmake/rules/xcode/application/build.lua +++ b/xmake/rules/xcode/application/build.lua @@ -49,7 +49,8 @@ function main (target, opt) -- @see https://github.com/xmake-io/xmake/issues/2679#issuecomment-1221839215 local targetfile = path.join(binarydir, path.filename(target:targetfile())) try { function () os.vrunv("install_name_tool", {"-delete_rpath", "@loader_path", targetfile}) end } - os.vrunv("install_name_tool", {"-add_rpath", "@executable_path/../Frameworks", targetfile}) + local rpath = target:is_plat("macosx") and "@executable_path/../Frameworks" or "@executable_path/Frameworks" + os.vrunv("install_name_tool", {"-add_rpath", rpath, targetfile}) -- copy dependent dynamic libraries and frameworks for _, dep in ipairs(target:orderdeps()) do @@ -109,4 +110,3 @@ function main (target, opt) end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}, changed = target:is_rebuilt()}) end - -- cgit v1.3.1 From d0f83e55778e37afc767cf8fa382e16d6e5dc001 Mon Sep 17 00:00:00 2001 From: Akaps316 <48785708+Akaps316@users.noreply.github.com> Date: Sun, 5 Apr 2026 10:38:00 +0530 Subject: fix(xcode.application): resolve merge conflict with upstream dev - add rpath duplicate guard Co-authored-by: Qwen-Coder --- xmake/rules/xcode/application/build.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'xmake/rules/xcode/application/build.lua') diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua index 7d1c836fa..d55d71a9c 100644 --- a/xmake/rules/xcode/application/build.lua +++ b/xmake/rules/xcode/application/build.lua @@ -23,6 +23,7 @@ import("core.base.option") import("core.theme.theme") import("core.project.depend") import("private.tools.codesign") +import("utils.binary.rpath", {alias = "rpath_utils"}) import("utils.progress") function main (target, opt) @@ -49,8 +50,13 @@ function main (target, opt) -- @see https://github.com/xmake-io/xmake/issues/2679#issuecomment-1221839215 local targetfile = path.join(binarydir, path.filename(target:targetfile())) try { function () os.vrunv("install_name_tool", {"-delete_rpath", "@loader_path", targetfile}) end } + -- macOS uses @executable_path/../Frameworks due to Contents/MacOS/ layout + -- iOS/watchOS/tvOS/visionOS use flat bundle layout where frameworks are in the same directory as the executable local rpath = target:is_plat("macosx") and "@executable_path/../Frameworks" or "@executable_path/Frameworks" - os.vrunv("install_name_tool", {"-add_rpath", rpath, targetfile}) + local rpathdirs = rpath_utils.list(targetfile, {plat = target:plat(), arch = target:arch()}) or {} + if not table.contains(rpathdirs, rpath) then + os.vrunv("install_name_tool", {"-add_rpath", rpath, targetfile}) + end -- copy dependent dynamic libraries and frameworks for _, dep in ipairs(target:orderdeps()) do -- cgit v1.3.1