igor-makarov / xcake

:cake: Describe Xcode projects in a human readable format and (re)generate one on demand.
MIT License
634 stars 48 forks source link

Can't run my program, because the framework isn't included. #225

Open srbaker opened 2 years ago

srbaker commented 2 years ago

Hi,

I am new to xcake.

(The Repo is over here: https://github.com/srbaker/Raphael)

I have the following Cakefile, and it references a framework which is built already that I just want to add to my project:

project.name = "Raphael"
project.class_prefix = "RAP"

application_for :osx, 10.11 do |target|
  target.name = "Raphael"
  target.all_configurations.each { |configuration|
    configuration.product_bundle_identifier = "com.stevenrbaker.raphael"
    configuration.settings["FRAMEWORK_SEARCH_PATHS"] = "../libs-renaissance/Source/**"
  }
  target.include_files << "../libs-renaissance/Source/Renaissance.framework"

  target.copy_files_build_phase "Embed Frameworks" do |phase|
    phase.files = [
      "../libs-renaissance/Source/Renaissance.framework"
    ]
    phase.destination = :frameworks
  end

  target.language = :objc
  target.type = :application
end

When I build and run in Xcode, it can't find the framework. And it's not added to the built app.

The error is:

dyld[30429]: Library not loaded: Renaissance.framework/Renaissance
  Referenced from: /Users/srbaker/Library/Developer/Xcode/DerivedData/Raphael-fgxqqojptmejsqhakvbdzhcssxdi/Build/Products/Debug/Raphael.app/Contents/MacOS/Raphael
  Reason: tried: '/Users/srbaker/Library/Developer/Xcode/DerivedData/Raphael-fgxqqojptmejsqhakvbdzhcssxdi/Build/Products/Debug/Renaissance.framework/Renaissance' (no such file), 'Renaissance.framework/Renaissance' (no such file), '/Library/Frameworks/Renaissance.framework/Renaissance' (no such file), '/System/Library/Frameworks/Renaissance.framework/Renaissance' (no such file)

I suspect this is a complete newbie error on my part. Thanks!

igor-makarov commented 2 years ago

Hey!

From the looks of it, you're building and linking your app successfully. Is the framework copied over to the Frameworks folder in the app bundle?

If so, my guess is the dylib loader is missing some rpath to know where to load Renaissance.framework/Renaissance from. However, I'm not a big expert on rpaths on macOS. I think you need to add @executable_path/../Frameworks to your LD_RUNPATH_SEARCH_PATHS build variable.