Xcode, embedding Racket.framework

60 views
Skip to first unread message

Nate Griswold

unread,
Jun 24, 2020, 12:54:46 PM6/24/20
to Racket Users
Hello

I recently went through the process of embedding the Racket.framework in Xcode, and i just wanted to share the steps in case anyone else would like to do this.


"On Mac OS, besides "libracketcs.a" for static linking, a dynamic library is provided by the "Racket" framework, which is typically installed in "lib" sub-directory of the installation. Supply -framework Racket to gcc when linking, along with -F and a path to the "lib" directory. At run time, either "Racket.framework" must be moved to a location in the standard framework search path, or your embedding executable must provide a specific path to the framework (possibly an executable-relative path using the Mach-O @executable_path prefix)."

That sets the rpath search paths but the library binary still needs to reference @rpath to make use of these search paths. Below we use install_name_tool to fix up the binary to reference the @rpath directly.

Note also that Xcode is hard coded to codesign in the Versions/A subdirectory and hasn't added any support for signing other major versions, so i link version A in the below steps. This step is only necessary if you wish to sign the framework on copy.

Note also for a proper framework structure, the framework should have an Info.plist in Resources and a Versions/Current symlink. Top-level symlinks directly in Racket.framework should reference only Versions/Current and both Resources and the binary library (Racket) should be referenced. (see https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html)

Note also i did all of this with racket cs, you would have to modify the steps if you were using normal racket.

All that said, here are the steps:

Drag the framework into xcode
select copy if needed, ok
Click on project, General tab, "Frameworks, Libraries, and Embeddeed Content"
Change do not embed to either embed or embed and sign
cd to your copied framework in your project
cd Versions
ln -s 7.7_CS Current
if "embed and sign" was chosen:
  ln -s 7.7_CS A (xcode is hard coded to sign the major version A, see https://developer.apple.com/forums/thread/65963)
cp /path/to/Info.plist 7.7_CS/Resources
cd ..
rm -f Racket
ln -s Versions/Current/Racket
ln -s Versions/Current/Resources
install_name_tool -id @rpath/Racket.framework/Versions/7.7_CS/Racket ./Racket
otool -L Racket (to verify)
Switch to Xcode, build and run

Nate
Info.plist

Stephen De Gabrielle

unread,
Jun 25, 2020, 5:30:27 AM6/25/20
to Nate Griswold, Racket Users
This world be great content for the wiki

Hi Nate,
This would be great content for the racket wiki 

You can post it yourself or I am happy to do it for you. 

Kind regards,
Stephen

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAM-xLPpC3Ona-zbV6r43dD_xjSmXa_eGGRLfFERuQ_tBgG%3D4HQ%40mail.gmail.com.
--
----

Nate Griswold

unread,
Jun 26, 2020, 3:05:25 PM6/26/20
to Stephen De Gabrielle, Racket Users
Reply all
Reply to author
Forward
0 new messages