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

Relocation of dylibs in macOS .app Builds with Xcode Rules #5515

Closed
charles-liang opened this issue Aug 27, 2024 · 2 comments
Closed

Relocation of dylibs in macOS .app Builds with Xcode Rules #5515

charles-liang opened this issue Aug 27, 2024 · 2 comments
Labels
Milestone

Comments

@charles-liang
Copy link

Xmake Version

2.9.4

Operating System Version and Architecture

macOS 15.1 Beta

Describe Bug

In a multi-project setup with a main program and multiple shared libraries, using add_rules("xcode.application") to generate a .app file for macOS. The rpath is set to look in .app/Contents/Frameworks/, but the dylibs are being copied to the .app/Contents/Macos directory. Although it's possible to manually move them each time or write an after_build script to handle the move, it's still a hassle.

Expected Behavior

put libhello.dylib in Frameworks, not in Macos

❯ tree /Users/yao/hanabit/experimental/cpp/xmake/build/macosx/arm64/debug/main.app/Contents/
/Users/yao/hanabit/experimental/cpp/xmake/build/macosx/arm64/debug/main.app/Contents/
├── Frameworks
│   └── libhello.dylib
├── Info.plist
├── MacOS
│   └── main
├── Resources
│   ├── Base.lproj
│   │   └── Main.storyboardc
│   │       ├── Info.plist
│   │       ├── MainMenu.nib
│   │       ├── NSWindowController-B8D-0N-5wS.nib
│   │       └── XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
│   └── PkgInfo
└── _CodeSignature
    └── CodeResources

7 directories, 9 files

Project Configuration

-- - xmake.lua
includes("hello", "main")

-- -- hello/xmake.lua
local target_name = "hello"

set_project(target_name)

target(target_name)
    add_rules("mode.debug", "mode.release")
    add_includedirs("include")
    set_kind("shared")
    add_files("src/*.cpp")
    set_targetdir("$(buildir)/lib/$(plat)/$(arch)/$(mode)")

-- -- main/xmake.lua

local target_name = "main"

set_project(target_name)

target(target_name)
    add_rules("mode.debug", "mode.release")
    add_includedirs("../hello/include")
    set_kind("binary")
    add_files("src/*.cpp")
    add_deps("hello")

platform_dir = "platform/macosx"

if is_plat("macosx") then
    add_rules("xcode.application")
    add_files(platform_dir .. "**.mm")
    add_files(platform_dir .. "**.m")
    add_files(platform_dir .. "**.metal")
    add_files(platform_dir .. "**.storyboard", platform_dir .. "**.xcassets")
    add_files(platform_dir .. "**.plist")
end

Additional Information and Error Logs

❯ tree /Users/yao/hanabit/experimental/cpp/xmake/build/macosx/arm64/debug/main.app/Contents/
/Users/yao/hanabit/experimental/cpp/xmake/build/macosx/arm64/debug/main.app/Contents/
├── Info.plist
├── MacOS
│   ├── libhello.dylib
│   └── main
├── Resources
│   ├── Base.lproj
│   │   └── Main.storyboardc
│   │   ├── Info.plist
│   │   ├── MainMenu.nib
│   │   ├── NSWindowController-B8D-0N-5wS.nib
│   │   └── XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
│   └── PkgInfo
└── _CodeSignature
└── CodeResources

6 directories, 9 files

@waruqi
Copy link
Member

waruqi commented Aug 27, 2024

#5519

try xmake update -s github:xmake-io/xmake#app

@charles-liang
Copy link
Author

fixed! Thanks a lot!

waruqi added a commit that referenced this issue Aug 28, 2024
fix install dylib for macos app #5515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants