Search code examples
macoscocoansfilemanagermacos-carbon

Locate MacOS X Framework folder without using FSFindFolder


I have an old piece of code that uses FSFindFolder to get the location of MacOS X Framework folder using folderType kFrameworksFolderType. FSFindFolder has been deprecated and therefore I need to update this.NSFileManager's URLForDirectory does not contain any equivalent NSSearchPathDirectory constant. Is there a way to locate the Framework folder apart from using FSFindFolder?


Solution

  • To the best of my knowledge, the frameworks directory has always been located in /Library and ~/Library for as long as OS X has existed.

    Since this is legacy code, use NSLibraryDirectory and append "/Frameworks" to the path and you should be fine.

    Note that there are lots of other "standard" paths that don't, or no longer, have standard directory search constants: Preferences, LaunchAgents, and Services to mention just a few. I construct their paths based on NSLibraryDirectory and have never had an issue (and my software runs on systems with truly bizarre configurations).