Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building an iOS XCFramework for oneTBB #1252

Closed
wtholliday opened this issue Nov 11, 2023 · 4 comments · Fixed by #1319
Closed

building an iOS XCFramework for oneTBB #1252

wtholliday opened this issue Nov 11, 2023 · 4 comments · Fixed by #1319

Comments

@wtholliday
Copy link

wtholliday commented Nov 11, 2023

I'm trying to build an xcframework (and Swift Package) for oneTBB. I'm aware that tbb shouldn't be built as a static library due to singletons. (this iOS port builds tbb as a static library)

I've got this script: https://github.com/audulus/tbb-spm/blob/main/xcframework.sh

The script generates an xcframework out of dylibs, but alas Apple says:

Avoid using dynamic library files (.dylib files) for dynamic linking. An XCFramework can include dynamic library files, but only macOS supports these libraries for dynamic linking. Dynamic linking on iOS, watchOS, and tvOS requires the XCFramework to contain .framework bundles.

So I need to create frameworks for both macOS and iOS (because I can't mix dylibs and frameworks in an XCFramework).

How should I approach that? When I generate Xcode projects with cmake, it requires code signing. Also seems like the target is still a dylib, not a framework.

So I suppose I simply have to assemble the frameworks according to apple's format with a bunch of shell commands (making the appropriate directories, copying in plists, setting up symlinks). I haven't found a tool that will assemble a framework from a dylib.

Thanks for any help!

@isaevil
Copy link
Contributor

isaevil commented Nov 13, 2023

Unfortunately, I am not a XCode bundling savvy, but isn't it what you need to generate a framework bundle for Mac and iOS https://cmake.org/cmake/help/latest/prop_tgt/FRAMEWORK.html#prop_tgt:FRAMEWORK? I believe it can be controlled via -DCMAKE_FRAMEWORK=ON/OFF passed to command line.

@wtholliday
Copy link
Author

wtholliday commented Nov 13, 2023

Thanks @isaevil ! With -DCMAKE_FRAMEWORK=ON I get:

CMake Error at cmake/utils.cmake:26 (install):
  install TARGETS given no FRAMEWORK DESTINATION for shared library FRAMEWORK
  target "tbb".
Call Stack (most recent call first):
  src/tbb/CMakeLists.txt:124 (tbb_install_target)

I suspect I need to update utils.cmake to handle frameworks.

I'm not very good with CMake.

@isaevil
Copy link
Contributor

isaevil commented Nov 14, 2023

Thanks @isaevil ! With -DCMAKE_FRAMEWORK=ON I get:

CMake Error at cmake/utils.cmake:26 (install):
  install TARGETS given no FRAMEWORK DESTINATION for shared library FRAMEWORK
  target "tbb".
Call Stack (most recent call first):
  src/tbb/CMakeLists.txt:124 (tbb_install_target)

I suspect I need to update utils.cmake to handle frameworks.

I'm not very good with CMake.

You can try following:

--- a/cmake/utils.cmake
+++ b/cmake/utils.cmake
@@ -35,8 +35,11 @@ macro(tbb_install_target target)
                 COMPONENT runtime
             ARCHIVE
                 DESTINATION ${CMAKE_INSTALL_LIBDIR}
-                COMPONENT devel)
-
+                COMPONENT devel
+            FRAMEWORK
+                DESTINATION ${CMAKE_INSTALL_LIBDIR}
+                COMPONENT runtime
+                OPTIONAL)
         if (BUILD_SHARED_LIBS)
             install(TARGETS ${target}
                 LIBRARY

@geertbleyen
Copy link
Contributor

I'm running into similar issues, where we integrate oneTBB via Conan.
There is no official way to build OneTBB as an Apple Framework and consequently also no way to tell Conan to build oneTBB as an Apple Framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants