FreeCAD Pre Releases on macOS

0

Full article

With the release of macOS Big Sur, the FreeCAD pre-releases for version .19 found on the Github release page are not currently working. While there are different ways to install FreeCAD pre-releases on your Mac, I have found that using MiniConda is the easiest way to obtain a working version of .19 with a relatively current revision level.

The FreeCad developers package the current macOS pre-releases with Conda.   It is easy to install MiniConda on your Mac and use it to install FreeCad.  

** PLEASE NOTE:  The Addon Manager in the version located in the Conda Forge may not work correctly.  Please refer to the section "Updating to a Later Version" below to update Freecad to a later release while leaving the underlying components at a release that still works on Big Sur.

Installing MiniConda

The first step is to install MiniConda on your Mac.  You will find the instructions for installing MiniConda at:

https://docs.conda.io/en/latest/miniconda.html

I selected the 64bit package installer, which requires that you download the package file and then double-click on it to proceed with the installation.  

*** PLEASE NOTE:   You should not have the Terminal APP open while running the Conda package installation.   When prompted give the installation access to your disk so it can modify your shell profiles. ***

Installing FreeCAD .19

After installing MiniConda open a macOS terminal window and execute the following command:

conda update --all
conda create --name fcenv --channel conda-forge freecad

(base) irvshapiro@DrVax-iMac ~ %  conda update --all
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(base) irvshapiro@DrVax-iMac ~ % conda create --name fcenv --channel conda-forge freecad
WARNING: A conda environment already exists at '/Users/irvshapiro/opt/miniconda3/envs/fcenv'
Remove existing environment (y/[n])? y
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /Users/irvshapiro/opt/miniconda3/envs/fcenv
added / updated specs:
- freecad
The following NEW packages will be INSTALLED:
boost-cpp          conda-forge/osx-64::boost-cpp-1.72.0-hdf9ef73_0
bzip2              conda-forge/osx-64::bzip2-1.0.8-haf1e3a3_3
. . .
yaml               conda-forge/osx-64::yaml-0.2.5-haf1e3a3_0
zlib               conda-forge/osx-64::zlib-1.2.11-h7795811_1010
zstd               conda-forge/osx-64::zstd-1.4.5-h289c70a_2
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate fcenv
#
# To deactivate an active environment, use
#
#     $ conda deactivate
(base) irvshapiro@DrVax-iMac ~ %

Then to run the version of FreeCAD you just installed from a terminal window, enter:

conda activate fcenv
freecad

If freecad still hangs do the following.

MacOS Big Sur changed how programs "link" with some of the "c" compatibility libraries.  Apple recommended a new procedure for linking programs a number of years ago and Big Sur finally broke the legacy approach. Without going into details this  change is what is breaking current versions of FreeCAD.  You can learn more about the details here:

https://developer.apple.com/forums/thread/669094

You can correct this problem by installing an earlier version of libclang with the following Conda commands.

conda activate fcenv
conda install libclang=9.0.1

Here is the information for the release I installed on my system:

OS: macOS 10.16
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20909 (Git)
Build type: Release
Branch: (HEAD detached at 0.19.alpha2)
Hash: 8be2c08141f0275e9da005bd143771953e982a59
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)

I also tried installing from the freecad/label/dev channel with the following commands:

(base) irvshapiro@DrVax-iMac ~ %conda config --add channels conda-forge
(base) irvshapiro@DrVax-iMac ~ % conda config --add channels freecad/label/dev
(base) irvshapiro@DrVax-iMac ~ % conda create -n freecad-dev freecad

Then to run freecad:

(base) irvshapiro@DrVax-iMac ~ % conda activate freecad-dev(freecad-dev) irvshapiro@DrVax-iMac ~ % freecad

FreeCAD began to load and in the following message you can see it is running release 23074 — unfortunately this release hung.

FreeCAD 0.19, Libs: 0.19R23074 (Git)

Updating to a Later Version

The version installed from conda forge does not provide a working Addon Manager. Unfortunately as indicated above installing completely from the dev repository also does not work.   Fortunately with the help of a number of folks in "https://forum.freecadweb.org/viewtopic.php?t=51345" the following procedure was discovered.

  1. Install as indicated above from conda-forge without the freecad/label/dev channel.  Just follow the section in this document "Installing FreeCAD .19".  
  2. Then do the following to update the version of Freecad.  I am not an expert on Conda but it may be that this procedure leaves the conda forge versions of the underlying components while updating freecad.  

    % conda activate fcenv
    % conda update --all
    % conda config --add channels freecad/label/dev
    % conda update freecad -c=freecad/label/dev

    *** PLEASE NOTE: the correct command above is -c=free... not --c=free ...
  3. Finally you need to make sure you have gitpython in your environment:

    % conda install gitpython

Then run FreeCAD with the command "freecad".  I ended up with the following version using this procedure.

OS: macOS 10.16
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23546 (Git)
Build type: Release
Branch: master
Hash: 6b017f9a16b15b0e628c8d874c4058442dee5548
Python version: 3.8.6
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)

Creating a macOS Application from a Conda Installation

If you want to create a traditional macOS app from this installation, you can use the macOS Automator application.   Automator includes support for creating an APP that runs a shell script.

In order to test your commands before you use them in Automator, you need to create a script.  Create a file using a text editor with the following content:

source $HOME/opt/miniconda3/bin/activate
conda activate fcenv
freecad

*** PLEASE NOTE: If you are new to creating/editing shell files I recommend you open the Terminal APP, and then use the Nano text editor.  The command you would enter is:

nano freecad_conda.sh

All of the Nano commands are prefixed with the control key.  For example: "control o" will write out your file and "control x" will edit the text editor. ***

In my case, I named the file freecad_conda.sh.   Make sure the file is in your macOS home directory.  That is the directory that the terminal app open in.  Then open Terminal application and make the file executable with the following command:

chmod u+x freecad_conda.sh

You can then try running the script you just created by typing:

./freecad_conda.sh

If this works, it is time to create the Automator script.  First start Automator:

  1. select New Document
  2. select Application and Choose
  3. scroll down and double click on "Run Shell Script"
  4. enter the script you tested above into the action window

Here is how it should look:

Now select file and save as freecad.19.app in the applications directory.

*** PLEASE NOTE: Automator will by default save your file to icloud.  To save somewhere else your use the export option.  If you get an error message about signing the app you need to reinstall the Xcode command line tools.  Here are the steps.

Install Xcode from the app store if you have not already done this. Then open the terminal app and enter:

xcode-select --print-path
sudo rm -r <the path listed above>

( In my case, the full command is:
sudo rm -r /Library/Developer/CommandLineTools )

Then type the following to install the command lines tools (CLT).

xcode-select --install ***

When you look in the Application directory, you will notice the file has an Automator icon.   If you right-click on the freecad.19.app you can drag another icon to the icon indicator in the top left of the file info screen.  The following screen capture shows the FreeCAD.19.app info window and a FreeCAD icon on my desktop that I drag over the Automator icon on the top left.

I obtained the freecad.icns file (icon file) from a previous freecad installation.   Just install any other version of freecad, even a copy that does not work.   Right-click on the freecad.app file and select "show package content."  Then navigate to the contents/resource and copy the freecad.icns file, which you use to replace the Automator icon.

I hope this is helpful.

Please leave comments and suggestions at https://forum.drvax.com

Let's continue to learn together.

Irv

Author