Sunday, October 29, 2023

Parallels for macOS running under macOS

I am a long term VMWare user. My VMs were Windows. I tried macOS Mojave on VMWare Fusion 13 running on macOS Ventura and it runs fine. But the problem starts with inter host operability. I am unable to transfer files from Ventura to Mojave. Without this the VM is useless to me. So I tried Parallels. I had seen good reviews about Parallels in general. Installation experience was good just like VMWare and I am able to transfer files from Ventura to Mojave. I also tried with Catalina in the VM and it works without any problem.

Friday, October 20, 2023

Cannot read properties of undefined TestableReference

I received this error with iOS build in Microsoft App Center for Flutter app. There was flavors configured with dev, qa and prod envs. The dev.xcscheme and qa.xcsheme under Runner.xcodeproj/xcshareddata/xcschemes should have Testables under TestAction. Otherwise it will throw Cannot read properties of undefined (reading 'TestableReference') error. The code should look like:
      buildConfiguration = "Debug-qa"
      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
      shouldUseLaunchSchemeArgsEnv = "YES"
      shouldAutocreateTestPlan = "YES">

Friday, October 6, 2023

Fixing Created Date 1970 For Blu-ray In macOS

Blu-ray is a good way to store data for archival purposes. macOS has built-in support for writing blu-ray disks. However there is an issue with file creation date. All files Created date gets reset to 1 January 1970 at 5:30 AM. This the unix epoch time. Clearly this makes lot of things difficult. This issue is present for years and still not fixed with macOS Ventura. I checked the date at a later point in time and by then I have most of my image files written into blu-ray. This makes ordering files by created date difficult and also it's a bug. Luckily we have two other attributes to our rescue. Photos taken by iPhone have Content Created attribute. This value is intact and so is Modified. If you don't edit you image files, then any of these are valid. So I created a little bash script to update the Created date to Content Created date if it is valid or use Modified.

resetted_date="1970-01-01 00:00:00 +0000"
resetted_content_created_date="1970-01-01 00:00:00 +0000"

function update_created_date {
  local file="$1"

  fs_created_date_utc=$(mdls "$file" | grep "kMDItemFSCreationDate" | awk -F '= ' '{print $2}')
  fs_created_date_local=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$fs_created_date_utc" "+%m/%d/%Y %H:%M:%S %z")

  # Get the kMDItemContentCreationDate value
  content_created_date_utc=$(mdls "$file" | grep "kMDItemContentCreationDate[^_]" | awk -F '= ' '{print $2}')
  content_created_date_local=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$content_created_date_utc" "+%m/%d/%Y %H:%M:%S %z")

  fs_modified_date_utc=$(mdls "$file" | grep "kMDItemFSContentChangeDate" | awk -F '= ' '{print $2}')
  fs_modified_date_local=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$fs_modified_date_utc" "+%m/%d/%Y %H:%M:%S %z")

  # Check if creation date is not empty and fs created date got reset to 1970
  if [ "$fs_created_date_utc" == "$resetted_date" ] && [ -n "$content_created_date_utc" ] && [ "$content_created_date_utc" != "$resetted_content_created_date" ]; then
    SetFile -d "$content_created_date_local" "$file"
    echo "Content created date set $content_created_date_local for $file"
  elif [ "$fs_created_date_utc" == "$resetted_date" ]; then
    SetFile -d "$fs_modified_date_local" "$file"
    echo "Modified date set $fs_modified_date_local for $file"

# Check for folder path arg
if [ $# -ne 1 ]; then
  echo "Usage: $0 "
  exit 1


# Check if the folder exists
if [ ! -d "$folder_path" ]; then
  echo "Folder '$folder_path' not found."
  exit 1

# recursively process files in folder
while IFS= read -r -d '' file; do
  if [ -f "$file" ] || [ -d "$file" ]; then
    if [ "$(basename "$file")" != ".DS_Store" ]; then  # ignore .DS_Store
      update_created_date "$file"
done < <(find "$folder_path" -type f -print0)

# recursively update created for the directory as well
while IFS= read -r -d '' dir; do
  if [ -d "$dir" ]; then
    update_created_date "$dir"
done < <(find "$folder_path" -type d -print0)

Run this script by specifying the folder like set-created-date-to-image-date Pictures-2018. It will recusively set the created date for folders and files.

The above script will fix the date problem. To prevent this issue with blu-ray disk image writing, one solution is to create a dmg container and format it into the same file system type used by the macOS. I use APFS case-sensitive. So I use the same format as the dmg as well.

To create a new disk image, open Disk Utility > File > New Image > Blank Image and set the parameters as below.
Name: beetles-all-the-way
Size: 25GB
Partitions: Single parition - GUID Partition Map
Format: APFS (Case-Sensitive)
Image Format: read/write disk image
Encryption: none

Save this to say Burn Folder, mount it, copy files. Then insert the blu-ray and drag and drop the dmg for burning. This will preserve the file attributes.

Thursday, October 5, 2023

Using same DB by multiple users in DEVONthink 3

DEVONthink stores all data in a dtBase2 file. It's a container which contains the file and other settings. I have a DB called CSE where I keep my web archives, bookmarks and I want to use it from my work and personal accounts in the computer. I created the DB under the personal account. So it belongs to that user. It is advised to close the DB before opening by other user. Since the work user does not have permissions, it opens in read-only mode. To fix this we can add read-write permission to the DB file. Now if we try to open it will show "Database seems to be already in use" warning and when clicked on continue anyway it won't open. The solution as suggested by cgrunenberg is to quit DEVONthink, remove the .dtBase2 extension, which will now appear as a folder. Now add the work user with read-write permission for the folder and apply changes for enclosing files and folders. Add back the .dtBase2 extension. Open the DB and it will work just fine!

NB: It's adviced to never use the open the same database by mutliple users at the same time.

Saturday, September 23, 2023

Finding files differences between folders

I wrote a small script to find the files which are not present between two folders. Initially I used diff which works fine for source codes but when I want to just check for folders and files newly added to a directory without having to compare its content, diff is very slow. I wrote it mainly for backup purposes. For example, I have documents written to optical disk for archiving. I want to know which are the newly added files since the archival. So I can quickly compare the folder from optical disk and the hard drive to get a list of file I need to backup.

if [ $# -ne 2 ]; then
    echo "Usage: $0  "
    exit 1


# List all files in first folder
find "$folder1_path" -type f | sed "s#${folder1_path}/##" | sort > files_in_folder1.txt

# List all files in second folder
find "$folder2_path" -type f | sed "s#${folder2_path}/##" | sort > files_in_folder2.txt

echo 'Files in folder1 that are not in folder2:'
comm -23 files_in_folder1.txt files_in_folder2.txt

echo ''
echo 'Files in folder2 that are not in folder1:'
comm -23 files_in_folder2.txt files_in_folder1.txt

# Clean up
rm files_in_folder1.txt files_in_folder2.txt
For checking content difference

# find difference between file and folder contents

diff -rq "$1" "$2"

Thursday, September 21, 2023

Bookmarks Organiser v4.0 is live

Bookmarks Organizer is a nifty browser extension that automatically sorts bookmarks alphabetically when added. We can also sort all bookmarks manually using the reorder button. Chrome has moved to new version of manifest which is v3 making incompatible differences in how extensions work. All manifest v2 extensions will be removed from the store starting Jan 2024.

The previous version of the Bookmarks Organizer used web worker for compute intensive sort operation. With manifest v3, the default background script runs as a service worker. Currently chrome cannot create nested workers. So I rewrote the entire extension as I cannot use web worker and made it more streamlined. The current version excludes Other Bookmarks/Other Favourites from sorting so that any manual ordering can be placed there.

Get Bookmarks Organizer for Google Chrome which is a featured extension in the chrome web store.
Now Bookmarks Organizer is also available for Microsoft Edge browser as Edge Add-on!

Thursday, July 6, 2023

Integrity could not be verified error on launching app in iOS

When trying to install a build from third party websites like Microsoft App Center, if we get the error "This app cannot be installed because its integrity could not be verified", when launching the app, it means that the current provisioning profile used does not contain the UDID of the device used. To fix this, add the UDID in the Devices section in Apple Developer Portal and regenerate the provisioning profile. If using App Center, upload the new provisioning profile and generate a new build.