The concept of directory structure on macOS

This article is aimed to introduce directories hierarchy for macOS. macOS is also followed by Filesystem Hierarchy Standard (FHS). But it has a little difference, that this article collects for you. The content of directories in macOS is divided to two part, standard directories and hidden directories.

Standard Directories

  • /Applications : Application’s contents
    • This directory is where you install apps intended for use by all users of a computer.
  • /Library : Shared libraries, files
    • Apps should use the Library directory to store app-specific (or system-specific) resources.
  • /Network : Network related files and libraries.
    • It contains the list of computers in the local area network.
  • /System : System related files, libraries, and preference.
    • This directory contains the system resource required by macOS to run. These resources are not modified by recommend.
  • /Users : User home directory
    • All of files involves Individual users are placed in there.
  • /Volumes : Mount point for removable media
    • This directory contains subdirectories which are used as mount point for removable media.
    • E.g. cd-rom, floppy disk, dmg mounts etc.


    Hidden Directories
    This directories are followed FHS on Linux. You can also reference “The concept of directory structure on Linux”.

  • /bin : Essential user command binaries
    • All the executable binary programs.
  • /dev : Devices files
    • It contains hardware device files.
  • /etc : Host-specific system configuration
    • It contains all configuration for system.
  • /sbin : System binaries
    • The essential binaries which only can be executed by system.
  • /tmp : Temporary files
    • The temporary files created by apps and system.
  • /usr : Secondary hierarchy
    • It contains nonessential binaries, header files and other data.
  • /var : Variable data
    • Intuitively, it contains log and other file content is variable.


    Reference: macOS File System

    Importing Swift file to Objective-C project

    I think it is very complex when I read Apple's reference. Hence, I decided to write a simple article which illustrates you how to import Swift file into Objective-C project step by step.

    First, you should create an Objective-C project.

    After project be created. We have some parameters should be set in Build Settings.

  • Find “Defines Module”, and set to “YES”. This setting let Xcode use same framework to import Swift to Objective-C project.



  • Find “Always Embed Swift Standard Libraries”, and set to “YES”.



  • The “Product Module Name” names by your project name. In there, we do not need to revise anything.


  • New or add exist Swift file into the project. Then Xcode pop-ups a dialog, follows image. We just click “Create Bridging Header” to automatically crate bridging header. After that, we can see the bridging header file which be names your product name followed by adding "-Bridging-Header.h".


    Finally, we need to import “MixDemo-Swift.h” to any Object-C .m. That header is created by Xcode, but you cannot see in the project folder. The file names your Product Module Name, which we mentioned above, followed by add “-Swift.h”. You can also search "Objective-C Generated Interface Header Name" under Build Settings.
    #import "MixDemo-Swift.h"
    

    Then, we can use swift object in the Objective-C project directly.
        BarcodeScannerViewController *barcodeViewController = [[BarcodeScannerViewController alloc] init];
        barcodeViewController.delegate = self;
        [self presentViewController:barcodeViewController animated:YES completion:nil];
    

    Reference: https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html