Follow these steps to use SAM's code generator for iOS with Xcode and Swift:

  1. Download the library archive for armv7s, arm64, x86_64. This is based on SAM 2017.9.5 so is out of date. You can try building an up-to-date library from the makefiles in https://github.com/NREL/ssc/tree/develop/build_ios.
  2. Unzip libssc.zip in the opened code generation folder.
  3. Create an Xcode "Single View Application" iOS project.
  4. Copy all files in code generation folder to Xcode project folder (check "Copy items if needed" for adding files).
  5. Click on "Build Settings" tab for the Xcode project.
  6. Search for "c++" and change "C++ Language Dialect" from "GNU++11" to "C++11".
  7. Click on "Build Phases" tab and expand "Link Binary With Libraries" section".
  8. Click "+" and search for "c++".
  9. Click "libc++.tbd" and then "Add" button.
  10. Right click on project folder in Xcode and select "New File...".
  11. Select "Objective-C File" and click "Next".
  12. Name the file "bridge" and click "Next".
  13. Click "Create".
  14. Click "Create Bridging Header" in popup window.
  15. Click "[Xcode project name]-Bridging-Header.h" and add "#include "sscapi.h"" and save.
  16. Click the "ViewController.swift" file and add "print(run_[SAM case name]())" to the "viewDidLoad()" event.
  17. Run and view results in debug window.
  18. Optional - add a TextView control, named "tv", to the "Main.storyboard".
  19. Connect the "tv" control to the "ViewController".
  20. Set the text property to the "run_[SAM case name]()" function.
  21. Run the app on an emulator or any iOS device with iOS 10 or later.
  22. Send questions and comments to This email address is being protected from spambots. You need JavaScript enabled to view it..