# iOS framework

**URL:** https://discourse.vtk.org/t/ios-framework/1607
**Category:** Support
**Created:** [August 19, 2019, 1:36am UTC](https://discourse.vtk.org/t/ios-framework/1607 "2019-08-19T01:36:37Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![leon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.vtk.org/u/leon)
#### Post date: [August 19, 2019, 1:36am UTC](https://discourse.vtk.org/t/ios-framework/1607/1 "2019-08-19T01:36:37Z")

</div>

I want to use VTK in ios. According to the instructions, I plan to Build the vtk.framework of ios, but it is prompted in make that VTK not installed. Build the source then Build the ‘install’ target。The vtk.framework generated after I manually created the corresponding directory is 0 bytes. Why is this? Thank you。

Before calling this, ensure that the following variables are set:

# VTK\_GLOB\_LIBS - a path containing a wildcard suitable for globbing

# VTK\_INSTALLED\_HEADERS - the path containing all headers for the framework

Can you elaborate on how to set these two

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 10, 2019, 7:30pm UTC](https://discourse.vtk.org/t/ios-framework/1607/2 "2019-10-10T19:30:39Z")

</div>

@ken-martin

---

<div class="post-metadata">

### Author: ![Maximilien\_Mayya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/maximilien_mayya/32/1416_2.png) [@Maximilien\_Mayya](https://discourse.vtk.org/u/Maximilien_Mayya)
#### Post date: [February 21, 2020, 11:26am UTC](https://discourse.vtk.org/t/ios-framework/1607/3 "2020-02-21T11:26:40Z")

</div>

Hi there Leon,  
Did you find a solution to this issue? I’m running into the same thing (compiling tag v8.2.0).  
Max

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [February 21, 2020, 6:30pm UTC](https://discourse.vtk.org/t/ios-framework/1607/4 "2020-02-21T18:30:58Z")

</div>

@agirault any advice?

---

<div class="post-metadata">

### Author: ![agirault](https://discourse.vtk.org/user_avatar/discourse.vtk.org/agirault/32/508_2.png) [@agirault](https://discourse.vtk.org/u/agirault)
#### Post date: [February 21, 2020, 7:56pm UTC](https://discourse.vtk.org/t/ios-framework/1607/5 "2020-02-21T19:56:48Z")

</div>

I haven’t tested since [8579c7f](https://gitlab.kitware.com/vtk/vtk/commits/8579c7f) which is a while back (March 2017) but it might still work: it relies on using the [vtkiOS.cmake](https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtkiOS.cmake) script which will leverage the toolchain files in the CMake folder (ios.device.toolchain.cmake.in and ios.simulator.toochain.cmake.in), as well as a script to merge the libraries into one using `lipo` ([MakeFramework.cmake.in](https://gitlab.kitware.com/vtk/vtk/blob/8579c7f/CMake/MakeFramework.cmake.in)).

To configure using those scripts and toolchains, you need to pass `-DVTK_IOS_BUILD=1` the first time you call cmake (can’t be from an existing cmake configured project), then set `IOS_DEPLOYMENT_TARGET `, `IOS_DEVICE_ARCHITECTURES `, `IOS_SIMULATOR_ARCHITECTURES ` and `IOS_EMBED_BITCODE `. On top of being ~2y old, it is very verbose since you need to explicitly pass all the modules you need to build, and they’re not all exposed at the moment (see [here](https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtkiOS.cmake#L100-179)).

If this doesn’t work out of the box, I would probably try to use the [native iOS cross-compilation support](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos) instead, which was added to CMake 3.14 [here](https://gitlab.kitware.com/cmake/cmake/merge_requests/2392) (fat libs only with XCode) and improved recently [here](https://gitlab.kitware.com/cmake/cmake/merge_requests/4125) (fat libs for ninja+makefile as well)… That would be new for VTK so you might hit some roadblocks as well, but it’s probably the best route to explore.

Edit: I only looked at `VTK_GLOB_LIBS` and `VTK_INSTALLED_HEADERS` afterwards and realized they were part of `vtkiOS.cmake`, which you’re clearly already using. The solutions are then either to fix that script which probably isn’t up to date (don’t we have nightly buidls that would have picked it up @ben.boeckel @ken-martin ?) or to look at the CMake native toolchains instead.

---

<div class="post-metadata">

### Author: ![Maximilien\_Mayya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/maximilien_mayya/32/1416_2.png) [@Maximilien\_Mayya](https://discourse.vtk.org/u/Maximilien_Mayya)
#### Post date: [March 6, 2020, 5:20pm UTC](https://discourse.vtk.org/t/ios-framework/1607/6 "2020-03-06T17:20:43Z")

</div>

Thanks Alex for the answer.  
Compilation and installation worked like a charm finally!  
I had to run ccmake with -DVTK\_IOS\_BUILD=ON (not sure if the problem came from running cmake-gui when I first posted my question).  
BTW, no need to call `make install`. After building the project, the vtk.framework is installed in `CMAKE_FRAMEWORK_INSTALL_PREFIX`.

---

<div class="post-metadata">

### Author: ![agirault](https://discourse.vtk.org/user_avatar/discourse.vtk.org/agirault/32/508_2.png) [@agirault](https://discourse.vtk.org/u/agirault)
#### Post date: [March 6, 2020, 10:02pm UTC](https://discourse.vtk.org/t/ios-framework/1607/7 "2020-03-06T22:02:16Z")

</div>

Great to hear that it still works!

> I had to run ccmake with -DVTK\_IOS\_BUILD=ON

Yes, when you cross-compile you need to use a different toolchain from the get-go, so you need to let CMake know before it really configures anything/runs at all. This is true for the current custom solution in VTK, as well as the [newer native CMake solution](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos) where you’d need to pass `-DCMAKE_SYSTEM_NAME=iOS` the first time you call CMake.

> Not sure if the problem came from running cmake-gui when I first posted my question

I actually don’t know how to set variables before running CMake with cmake-gui 🤷‍♂️.

> BTW, no need to call `make install` . After building the project, the vtk.framework is installed in `CMAKE_FRAMEWORK_INSTALL_PREFIX` .

Right, and just FYI that’s because of the custom CMake script, in VTK but you would need to if we used the iOS toolchain from CMake instead.

* * *

Have fun with it, and if you make any cool progress you can share with us please do so!

---

<div class="post-metadata">

### Author: ![Maximilien\_Mayya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/maximilien_mayya/32/1416_2.png) [@Maximilien\_Mayya](https://discourse.vtk.org/u/Maximilien_Mayya)
#### Post date: [March 9, 2020, 8:24am UTC](https://discourse.vtk.org/t/ios-framework/1607/8 "2020-03-09T08:24:21Z")

</div>

Thank you Alex for following up.  
If someone’s looking at this thread and trying to compile an iOS example from the Examples folder of VTK, here are the steps that worked for me (I’m currently using Xcode 10.3):

- `sudo cp -r` \<CMAKE\_FRAMEWORK\_INSTALL\_PREFIX\>/vtk.framework /Library/Frameworks/ (this is only necessary if the \<CMAKE\_FRAMEWORK\_INSTALL\_PREFIX\> is not a standard framework path otherwise you need to explicitly set is in Xcode)
- open \<source\_folder\_path\>/Examples/iOS/Surfaces (or any other VTK example in the iOS folder) #NOTE: some examples may need non-default specific VTK modules to be built in the framework building step.
- add the following 2 lines to the `.plist` file (this is because the VTK examples are not up-to-date?):
  - `<key>CFBundleShortVersionString</key>`
  - `<string>1.0.0</string>`

- because Xcode10 and higher does not support _libstd++_ anymore you need to do the following:
  - git clone [https://github.com/Kila2/libstdc-.6.0.9.tbd.git](https://github.com/Kila2/libstdc-.6.0.9.tbd.git) \<libstd\_path\>
  - `cp` \<libstd\_path\>/iPhoneOS/\* /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
  - `cp` \<libstd\_path\>/iPhoneSimulator/libstdc++.\*.dylib /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
  - `cp` \<libstd\_path\>/iPhoneSimulator/libstdc++\*.tbd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/

- open \<source\_folder\_path\>/Examples/IOS/Surfaces/Surfaces.xcodeproj in Xcode
- build and run  
Hope this will be useful!

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [March 26, 2020, 9:28pm UTC](https://discourse.vtk.org/t/ios-framework/1607/9 "2020-03-26T21:28:36Z")

</div>

> [@Maximilien\_Mayya](#):
>
> `cp` \<libstd\_path\>/iPhoneSimulator/libstdc++.\*.dylib /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/

This directory under /Applications/Xcode.app doesn’t seem to exist. I also find it odd you are placing stuff for the simulator in a non-simulator folder. Can you confirm that second step?

---

<div class="post-metadata">

### Author: ![Maximilien\_Mayya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/maximilien_mayya/32/1416_2.png) [@Maximilien\_Mayya](https://discourse.vtk.org/u/Maximilien_Mayya)
#### Post date: [March 30, 2020, 9:12am UTC](https://discourse.vtk.org/t/ios-framework/1607/10 "2020-03-30T09:12:13Z")

</div>

> [@Gilthalas](#):
>
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/

This path is for Xcode10, you may be using different version?  
To be honset I blindly applied the instruction given in the [github link](https://github.com/Kila2/libstdc-.6.0.9.tbd.git). However, others use the _iPhoneSimulator_ path [here](https://stackoverflow.com/questions/50694822/xcode-10-ios-12-does-not-contain-libstdc6-0-9) but I cannot confirm which works and which does not (so maybe that copy is not necessary at the end?)

---

<div class="post-metadata">

### Author: ![Gilthalas](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gilthalas/32/362_2.png) [@Gilthalas](https://discourse.vtk.org/u/Gilthalas)
#### Post date: [April 2, 2020, 12:05am UTC](https://discourse.vtk.org/t/ios-framework/1607/11 "2020-04-02T00:05:12Z")

</div>

I would absolutely love for someone to write up up-to-date instructions with the latest Xcode. I tried it (I tried both putting libstdc++ in Xcode as well as just referencing it in the project), but keeping getting a “‘locale’ file not found” error when compiling. Something in the vtk framework (specifically Headers/vtkdiy2/include/vtkdiy2/fmt/locale.h) is trying to `#include <locale>` and the system can’t find it.

According to what I’ve read, Xcode support for libstdc++ was deprecated years ago, and you should use libc++ instead. What are the odds of getting things update to use that library instead? I have no idea how different they are, but at least from Apple’s point of view, libstdc++ is past its prime.
