Skip to content

MacOS Create and Debug Model using Xcode

amc1999 edited this page Jan 12, 2024 · 2 revisions

What do you need

Prerequisites

  • Tested on: latest MacOS, may work starting from Big Sur >= 11.1.
  • Install Xcode and command line developer tools, if not installed already by Xcode: xcode-select --install.
  • Check if clang, make and sqlite3 are installed on your computer:
g++ --version
....
Apple clang version 11.0.0 (clang-1100.0.33.12)

make --version
....
GNU Make 3.81

sqlite3 --version
....
3.28.0 2019-04-15 14:49:49
  • Download and unpack latest openM++ release using Safari or curl:
curl -L -o om.tar.gz https://github.com/openmpp/main/releases/download/v1.6.0/openmpp_mac_20200621.tar.gz
tar xzf om.tar.gz

Create Xcode project for new Model

Copy model Xcode project files into your new "MyModel" directory, for example:

cd ~/openmpp_mac_20200621
cp -pr Xcode/Model.* models/MyModel/

Start Xcode and open ~/openmpp_mac_20200621/models/MyModel/Model.xcworkspace:

Open model workspace

Rename model Project -> Targets -> click twice on target name -> and rename to MyModel

Rename model target to actual model name

Rename model scheme using menu: Product -> Scheme -> Manage Schemes... -> click twice on "Model" scheme -> and rename to MyModel

Rename model product scheme to actual model name

Add your model source code from MyModel/code folder:

Add model source code to Xcode project

Add model source code to Xcode project

Make sure your model scheme selected by using menu: Product -> Scheme -> MyModel:

Select model scheme

Build your model:

Build model by Xcode

(Optional) Build the model with multiple scenarios:

  • edit Xcode-src/Model.xcconfig and to specify additional scenario names and input directories, separated by comma. For example:
  • SCENARIO_NAME = Default,Other
  • OMC_SCENARIO_PARAM_DIR = $(SRCROOT)/parameters/Default,$(SRCROOT)/parameters/SomeOther

Build model with multiple scenarios

Debug openM++ Model using Xcode

Start Xcode and open your model workspace, for example: ~/openmpp_mac_20200621/models/MyModel/Model.xcworkspace

Open model workspace using Xcode

Use menu to select your model scheme: Product -> Scheme -> MyModel:

Known issue: Xcode UI may not update check mark on selected scheme. To fix it go to Product -> Scheme -> Manage Schemes... and use mouse to drag any scheme to move it up or down.

Select model scheme

(Optional) If you want to set breakpoints in any*.mpp or *.ompp files then tell to Xcode it is "C++ Source" file(s):

Set model source files type as c++

Run and debug your openM++ model:

Debug model using Xcode

To inspect model parameters go to Debug Area and Add Expression:

View RiskPaths model parameters in Xcode

Start model UI on MacOS from Xcode

To start model UI after build completed please change Model.xcconfig variable START_OMPP_UI to "1" or "true" or "yes" (case-sensitive)

Change model config to start UI from XCode

Run RiskPaths model UI from Xcode

Home

Getting Started

Model development in OpenM++

Using OpenM++

Model Development Topics

OpenM++ web-service: API and cloud setup

Using OpenM++ from Python and R

Docker

OpenM++ Development

OpenM++ Design, Roadmap and Status

OpenM++ web-service API

GET Model Metadata

GET Model Extras

GET Model Run results metadata

GET Model Workset metadata: set of input parameters

Read Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata as CSV

GET Modeling Task metadata and task run history

Update Model Profile: set of key-value options

Update Model Workset: set of input parameters

Update Model Runs

Update Modeling Tasks

Run Models: run models and monitor progress

Download model, model run results or input parameters

Upload model runs or worksets (input scenarios)

Download and upload user files

User: manage user settings

Model run jobs and service state

Administrative: manage web-service state

Clone this wiki locally