premake / premake-core

Premake

Home Page:https://premake.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XCode does not show linked Libraries

erikmartinessanches opened this issue · comments

What seems to be the problem?
Libraries (such as spdlog, glfw3) linked in the links{} section do not show up in the xcode project property’s "Frameworks and Libraries" section. Only frameworks such as Cocoa.framework and IOKit.framework appear.

What did you expect to happen?
I expect the library to appear in the generated xcode project properties -> Target -> General -> Framework and Libraries.

What have you tried so far?
See the steps below.

How can we reproduce this?

  1. Install vcpkg for dependency management into vendor/packages: git submodule add -f https://github.com/Microsoft/vcpkg.git ./vendor/packages
  2. Bootstrap vcpkg ./vendor/packages/bootstrap-vcpkg.sh
  3. Create or edit vcpkg.json to contain { "dependencies": ["spdlog", "glfw3", "vulkan", "glm"] }
  4. Install dependencies into vendor/vcpkg-installed ./vendor/packages/vcpkg install --x-install-root=vendor/vcpkg-installed
  5. Create a premake5.lua:
workspace "Vulkan2"
   configurations { "Debug", "Release" }
   architecture "ARM64"
   location "./"

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

project "Vulkan2"
   kind "ConsoleApp"
   language "C++"
   targetdir ("bin/" .. outputdir .. "/%{prj.name}/")
   objdir ("bin-int/" .. outputdir .. "/%{prj.name}/")
   staticruntime "On"
   cppdialect "C++17"
   files { "src/**.h", "src/**.cpp"}

   includedirs{"vendor/vcpkg-installed/" .. "arm64-osx" .. "/include/*"}
   externalincludedirs{"vendor/vcpkg-installed/" .. "arm64-osx" .. "/include/*"} 

   xcodebuildsettings = { ["HEADER_SEARCH_PATHS"] = { "vendor/vcpkg-installed/" .. "arm64-osx" .. "/include/*"}}
   libdirs {"vendor/vcpkg-installed/" .. "arm64-osx" .. "/lib/"}
   links {"spdlog", "glwf3", "vulkan", "Cocoa.framework", "IOKit.framework", "fmt"}

   filter "configurations:Debug"
      defines { "DEBUG" }
      symbols "On"

   filter "configurations:Release"
      defines { "NDEBUG" }
      optimize "On"
  1. Generate xcode project ./vendor/bin/premake/premake5 xcode4
  • Visual Studio 2022 (vs2022)
  • Visual Studio 2019 (vs2019)
  • Visual Studio 2017 (vs2017)
  • Visual Studio 2015 (vs2015)
  • Visual Studio 2012 (vs2012)
  • Visual Studio 2010 (vs2010)
  • Visual Studio 2008 (vs2008)
  • Visual Studio 2005 (vs2005)
  • GNU Makefile (gmake)
  • GNU Makefile 2 (gmake2)
  • XCode (xcode)
  • Codelite
  • Other (Please list below)

What version of Premake are you using?
5.0.0-dev

Other details
Apple Silicon M1 Macbook Pro.

Can you confirm that you are indeed using v6? It is far from ready and should not be used.

Can you confirm that you are indeed using v6? It is far from ready and should not be used.

By bad, it’s indeed 5.0.0-dev!

Do the other libraries show up as expected?

The other libraries do not appear in ‘Frameworks and Libraries”, only the frameworks ending in .framework appear.

Okay, good info to know. I don't have access to any apple devices, so I won't be able to triage this myself, but hopefully one of the other devs with access to one will be able to get you a fix.

For info, posted on stackoverflow

There was a typo in my glfw in my OP!
I have now managed to generate an xcode project that has libvulkan.1.dylib (along with files ending in .framework) listed in “Frameworks and Libraries” with this updated premake5.lua file.

workspace "Vulkan2"
   configurations { "Debug", "Release" }
   architecture "ARM64"
   location "./"
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
project "Vulkan2"
   kind "ConsoleApp"
   language "C++"
   targetdir ("bin/" .. outputdir .. "/%{prj.name}/")
   objdir ("bin-int/" .. outputdir .. "/%{prj.name}/")
   staticruntime "On"
   cppdialect "C++17"
   files { "src/**.h", "src/**.hpp", "src/**.cpp" }
   includedirs{"%{prj.location}/vendor/vcpkg-installed/" .. "arm64-osx" .. "/include"}
   externalincludedirs{"%{prj.location}/vendor/vcpkg-installed/" .. "arm64-osx" .. "/include"} 
   xcodebuildsettings = {["HEADER_SEARCH_PATHS"] = { "%{prj.location}/vendor/vcpkg-installed/" .. "arm64-osx" .. "/include/" }}
   libdirs {"%{prj.location}/vendor/vcpkg-installed/" .. "arm64-osx" .. "/lib/"}
   links {"spdlog", "glfw3", "libvulkan.1.dylib", "Cocoa.framework", "IOKit.framework", "fmt"}
   filter "configurations:Debug"
      defines { "DEBUG" }
      symbols "On"
   filter "configurations:Release"
      defines { "NDEBUG" }
      optimize "On"

I suppose it’s not intended for spdlog, glfw3 and fmt (all .a files) to appear in “Frameworks and Libraries”, since if I add them, it says it ignores duplicates. I guess only frameworks and dynamic libraries go here.

However, when trying to add libvulkan.1.dylib with with premake5.lua as in this post, the error in the xcode project is

/Users/erik/Dev/Projects/Vulkan2/libvulkan.1.dylib /Users/erik/Dev/Projects/Vulkan2/libvulkan.1.dylib: No such file or directory

Note that it's looking in the wrong location for the libvulkan.1.dylib. libvulkan.1.dylib is in fact located in %{prj.location}/vendor/vcpkg-installed/" .. "arm64-osx" .. "/lib/.

Is there any was to tell links{} where the libvulkan.1.dylib is located? (How do I generally add a dynamic library?)

Just added sample project to test "external" links.
It compiles with xcode4 (on CI, I don't have MacOS).
It is possible though that you cannot see the libraries where you expect in the project (check also in extra link options for example)(that happens also for visual studio for some options).

Is there any was to tell links{} where the libvulkan.1.dylib is located?

Not to only one library, but there is libdirs to add to search path.