Follow these steps to use SAM's code generator for iOS with Xcode and Swift:
- 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.
- Unzip libssc.zip in the opened code generation folder.
- Create an Xcode "Single View Application" iOS project.
- Copy all files in code generation folder to Xcode project folder (check "Copy items if needed" for adding files).
- Click on "Build Settings" tab for the Xcode project.
- Search for "c++" and change "C++ Language Dialect" from "GNU++11" to "C++11".
- Click on "Build Phases" tab and expand "Link Binary With Libraries" section".
- Click "+" and search for "c++".
- Click "libc++.tbd" and then "Add" button.
- Right click on project folder in Xcode and select "New File...".
- Select "Objective-C File" and click "Next".
- Name the file "bridge" and click "Next".
- Click "Create".
- Click "Create Bridging Header" in popup window.
- Click "[Xcode project name]-Bridging-Header.h" and add "#include "sscapi.h"" and save.
- Click the "ViewController.swift" file and add "print(run_[SAM case name]())" to the "viewDidLoad()" event.
- Run and view results in debug window.
- Optional - add a TextView control, named "tv", to the "Main.storyboard".
- Connect the "tv" control to the "ViewController".
- Set the text property to the "run_[SAM case name]()" function.
- Run the app on an emulator or any iOS device with iOS 10 or later.
- Send questions and comments to This email address is being protected from spambots. You need JavaScript enabled to view it..