2017-02-12

Hide files and folders with an Encrypted disk image on Mac

1. Create an Encrypted disk image file
$ hdiutil create -size 100g -layout GPTSPUD -fs "Journaled HFS+" -volname "Secured Repository" -type SPARSEBUNDLE -encryption AES-128 EncDiskImg

Enter a new password to secure "EncryptedDisk.sparsebundle": **********
Re-enter new password: **********

created: /Users/dee/Cloud/EncDiskImg.sparsebundle
* For more options
 $ hdiutil create -help
or use Disk Utility


2. Mount
Double click the image on Finder then answer password you enter the above.
or
$ hdiutil mount EncDiskImg.sparsebundle

Enter password to access "EncDiskImg.sparsebundle": **********

/dev/disk2           GUID_partition_scheme
/dev/disk2s1        EFI
/dev/disk2s2        Apple_HFS /Volumes/Secured Repository

3. Also you can hide the file not to show on Finder. Note that the "ls" command on Terminal can list the file.
$ setfile -a V EncDiskImg.sparsebundle
* Use applescript to mount a hidden file.
do shell script "hdiutil mount /PATH/TO/EndDiskImg.sparsebundle"
It will show you a prompt to get password.

2017-01-31

How to set DYLD_LIBRARY_PATH in Xcode

Open Product > Scheme > Edit Scheme > Run > Arguments
Add DYLD_LIBRARY_PATH under Environment Variables


dyld: Library not loaded: libboost_system.dylib

Got an error when compile boost library and run a sample program.
$ ./PROGRAM
dyld: Library not loaded: libboost_system.dylib
  Referenced from: /PATH/TO/PROGRAM
  Reason: image not found
Abort trap: 6
Check libraries then tried install_name_tool, but failed.
$ otool -L PROGRAM
PROGRAM:
libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
libboost_thread.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

$ install_name_tool -change libboost_system.dylib /PATH/TO/libboost_system.dylib PROGRAM
$ install_name_tool -change libboost_thread.dylib /PATH/TO/libboost_thread.dylib PROGRAM
Solution, add the following to .profile or .bash_profile
export DYLD_LIBRARY_PATH=/PATH/TO/BOOST/stage/lib