diff --git a/release/darwin/Blender.app/Contents/Info.plist b/release/darwin/Blender.app/Contents/Info.plist
index 263bd8cbba1..3484738fcba 100644
--- a/release/darwin/Blender.app/Contents/Info.plist
+++ b/release/darwin/Blender.app/Contents/Info.plist
@@ -11,8 +11,6 @@
blend
- CFBundleTypeIconFile
- Blender_Legacy_Document_Icon.icns
CFBundleTypeName
Blender File
CFBundleTypeOSTypes
diff --git a/source/blender/blendthumb/CMakeLists.txt b/source/blender/blendthumb/CMakeLists.txt
index feec85d9056..b9821647c74 100644
--- a/source/blender/blendthumb/CMakeLists.txt
+++ b/source/blender/blendthumb/CMakeLists.txt
@@ -21,6 +21,10 @@ set(SRC
src/blendthumb_png.cc
)
+set(LIB
+ bf_blenlib
+)
+
if(WIN32)
# -----------------------------------------------------------------------------
# Build `BlendThumb.dll`
@@ -36,10 +40,14 @@ if(WIN32)
add_library(BlendThumb SHARED ${SRC} ${SRC_WIN32})
- target_link_libraries(BlendThumb bf_blenlib dbghelp.lib Version.lib)
+ list(APPEND LIB
+ dbghelp.lib
+ Version.lib
+ )
+ target_link_libraries(BlendThumb ${LIB})
set_target_properties(BlendThumb PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrt")
-
-else()
+endif()
+if(UNIX AND NOT APPLE)
# -----------------------------------------------------------------------------
# Build `blender-thumbnailer` executable
@@ -49,7 +57,42 @@ else()
add_executable(blender-thumbnailer ${SRC} ${SRC_CMD})
setup_platform_linker_flags(blender-thumbnailer)
- target_link_libraries(blender-thumbnailer bf_blenlib)
+ target_link_libraries(blender-thumbnailer ${LIB})
+ if(DEFINED PTHREADS_LIBRARIES)
+ target_link_libraries(blender-thumbnailer ${PTHREADS_LIBRARIES})
+ endif()
+endif()
+if(APPLE)
+ # -----------------------------------------------------------------------------
+ # Build `blender-thumbnailer` appex
+
+ set(SRC_CMD
+ src/ThumbnailProvider.mm
+ src/ThumbnailProvider.hh
+ src/Info.plist
+ )
+
+ add_executable(blender-thumbnailer MACOSX_BUNDLE ${SRC} ${SRC_CMD})
+ set_target_properties(blender-thumbnailer PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/src/Info.plist
+ MACOSX_FRAMEWORK_IDENTIFIER org.blenderfoundation.blender.thumbnailer)
+ # set_target_properties(blender-thumbnailer PROPERTIES
+ # XIB_RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/Base.lproj")
+ # Doesn't affect other generators. So need to specify extension for others.
+ set_target_properties(blender-thumbnailer PROPERTIES
+ XCODE_PRODUCT_TYPE com.apple.product-type.app-extension)
+ set_target_properties(blender-thumbnailer PROPERTIES
+ BUNDLE_EXTENSION appex
+ BL_CODESIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ThumbnailExtensionMacOS.entitlements)
+ setup_platform_linker_flags(blender-thumbnailer)
+ set_target_properties(blender-thumbnailer PROPERTIES BUILD_WITH_INSTALL_RPATH true)
+ list(APPEND LIB
+ "-framework QuickLookThumbnailing"
+ "-fobjc-link-runtime"
+ "-fapplication-extension"
+ "-e _NSExtensionMain"
+ )
+ target_link_libraries(blender-thumbnailer ${LIB})
if(DEFINED PTHREADS_LIBRARIES)
target_link_libraries(blender-thumbnailer ${PTHREADS_LIBRARIES})
endif()
diff --git a/source/blender/blendthumb/src/Base.lproj/PreviewViewController.xib b/source/blender/blendthumb/src/Base.lproj/PreviewViewController.xib
new file mode 100644
index 00000000000..cb883fcbb35
--- /dev/null
+++ b/source/blender/blendthumb/src/Base.lproj/PreviewViewController.xib
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/blender/blendthumb/src/Info.plist b/source/blender/blendthumb/src/Info.plist
new file mode 100644
index 00000000000..7f6143c0e03
--- /dev/null
+++ b/source/blender/blendthumb/src/Info.plist
@@ -0,0 +1,48 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleDisplayName
+ blender_thumbnailer
+ CFBundleExecutable
+ blender-thumbnailer
+ CFBundleIdentifier
+ org.blenderfoundation.blender.thumbnailer
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ blender-thumbnailer
+ CFBundlePackageType
+ XPC!
+ CFBundleShortVersionString
+ 3.6.0
+ CFBundleSupportedPlatforms
+
+ MacOSX
+
+ CFBundleVersion
+ 3.6.0 2023-04-18
+ LSMinimumSystemVersion
+ 11.3
+ NSExtension
+
+ NSExtensionAttributes
+
+ QLSupportedContentTypes
+
+ org.blenderfoundation.blender.file
+
+ QLThumbnailMinimumDimension
+ 0
+
+ NSExtensionPointIdentifier
+ com.apple.quicklook.thumbnail
+ NSExtensionPrincipalClass
+ ThumbnailProvider
+ com.apple.showsInExtensionsManager
+
+
+
+
\ No newline at end of file
diff --git a/source/blender/blendthumb/src/README.md b/source/blender/blendthumb/src/README.md
new file mode 100644
index 00000000000..e2b9d3d6eb4
--- /dev/null
+++ b/source/blender/blendthumb/src/README.md
@@ -0,0 +1,42 @@
+lsregister and its listing and detection
+
+more logs in lldb
+
+more logs in console: look for anything qlmanage
+
+must sign the appex bundle with sandbox
+
+must launch the app
+
+appex cannot write at all : inferred from
+
+error 17:53:57.863578+0530 kernel Sandbox: qlmanage(37213) deny(1) file-write-data /dev/dtracehelper
+error 17:53:58.033957+0530 kernel Sandbox: qlmanage(37213) deny(1) mach-register com.apple.axserver (per-pid)
+error 17:53:58.071424+0530 kernel Sandbox: qlmanage(37213) deny(1) mach-register com.apple.tsm.portname (per-pid)
+error 17:53:58.164827+0530 kernel Sandbox: qlmanage(37213) deny(1) user-preference-read com.apple.HIToolbox
+error 17:54:00.837220+0530 kernel Sandbox: qlmanage(37213) deny(1) file-write-data /dev/dtracehelper
+error 17:54:00.904484+0530 kernel Sandbox: qlmanage(37213) deny(1) file-write-create /Users/ankitkumar/Library/Saved Application State/com.apple.quicklook.qlmanage.savedState
+
+https://eclecticlight.co/2018/04/05/inside-quicklook-previews-with-qlmanage/
+
+in info.plist, add NSExtensionPrincipalClass, add QLThumbnailMinimumDimension
+
+Try removing blend file thumbnail specificaion from blender.app info.plist
+
+Expect
+
+lender-thumbnailer __extensionPrincipalClass != nil - /AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/ExtensionFoundation/ExtensionFoundation/Source/NSExtension/NSExtensionSupport/EXConcreteExtensionContextVendor.m:108: Unable to find NSExtensionPrincipalClass () in extension bundle! Please verify that the extension links the required frameworks and that the value for NSExtensionPrincipalClass is prefixed with '$(PRODUCT_MODULE_NAME).' if the class is implemented in Swift.
+fault 00:55:16.449383+0530 blender-thumbnailer [__extensionPrincipalClass conformsToProtocol:@protocol(NSExtensionRequestHandling)] - /AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/ExtensionFoundation/ExtensionFoundation/Source/NSExtension/NSExtensionSupport/EXConcreteExtensionContextVendor.m:109: NSExtensionPrincipalClass does not conform to NSExtensionRequestHandling protocol!
+
+
+Signing blender.app
+
+move blender.app to /Applications or launch it at least once
+
+Don't access files outside sandbox or kernel denies:
+
+default 03:07:03.525360+0530 blender-thumbnailer hello world from blender
+error 03:07:03.527837+0530 blender-thumbnailer Couldn't issue file extension for url:
+error 03:07:03.531152+0530 kernel Sandbox: com.apple.quickl(476) deny(1) file-read-data /Users/ankitkumar/Pictures/IMG_3158.JPG
+
+restart ?
diff --git a/source/blender/blendthumb/src/ThumbnailExtensionMacOS.entitlements b/source/blender/blendthumb/src/ThumbnailExtensionMacOS.entitlements
new file mode 100644
index 00000000000..0aa4c41dd33
--- /dev/null
+++ b/source/blender/blendthumb/src/ThumbnailExtensionMacOS.entitlements
@@ -0,0 +1,12 @@
+
+
+
+
+ com.apple.security.app-sandbox
+
+ com.apple.security.files.user-selected.read-only
+
+ com.apple.security.get-task-allow
+
+
+
diff --git a/source/blender/blendthumb/src/ThumbnailProvider.hh b/source/blender/blendthumb/src/ThumbnailProvider.hh
new file mode 100644
index 00000000000..d07c9d3cf4d
--- /dev/null
+++ b/source/blender/blendthumb/src/ThumbnailProvider.hh
@@ -0,0 +1,12 @@
+#pragma once
+
+#import
+#import
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ThumbnailProvider : QLThumbnailProvider
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/source/blender/blendthumb/src/ThumbnailProvider.mm b/source/blender/blendthumb/src/ThumbnailProvider.mm
new file mode 100644
index 00000000000..b170faaba66
--- /dev/null
+++ b/source/blender/blendthumb/src/ThumbnailProvider.mm
@@ -0,0 +1,85 @@
+#include
+#include
+#include
+
+#import
+#import
+#import
+
+#import "ThumbnailProvider.hh"
+
+#include "BLI_fileops.h"
+#include "BLI_filereader.h"
+#include "blendthumb.hh"
+
+class FileReaderRAII {
+ int src_file_ = -1;
+
+ public:
+ explicit FileReaderRAII(int src_file) : src_file_(src_file) {}
+ ~FileReaderRAII()
+ {
+ if (src_file_ != -1) {
+ close(src_file_);
+ }
+ }
+
+ bool good()
+ {
+ return src_file_ != -1;
+ }
+
+ int get()
+ {
+ return src_file_;
+ }
+};
+
+static eThumbStatus creator_impl(const char *src_blend_path)
+{
+ eThumbStatus err;
+
+ /* Open source file `src_blend`. */
+ FileReaderRAII src_file_fd = FileReaderRAII(BLI_open(src_blend_path, O_BINARY | O_RDONLY, 0));
+ if (!src_file_fd.good()) {
+ return BT_FILE_ERR;
+ }
+
+ /* Thumbnail reading is responsible for freeing `file` and closing `src_file`. */
+ FileReader *file_content = BLI_filereader_new_file(src_file_fd.get());
+ if (file_content == nullptr) {
+ return BT_FILE_ERR;
+ }
+
+ /* Extract thumbnail from file. */
+ Thumbnail thumb;
+ err = blendthumb_create_thumb_from_file(file_content, &thumb);
+ if (err != BT_OK) {
+ return err;
+ }
+
+ return err;
+}
+
+@implementation ThumbnailProvider
+
+- (void)provideThumbnailForFileRequest:(QLFileThumbnailRequest *)request
+ completionHandler:(void (^)(QLThumbnailReply *_Nullable reply,
+ NSError *_Nullable error))handler
+{
+ // Add the supported content types to the QLSupportedContentTypes array in
+ // the Info.plist of the
+ // extension.
+
+ NSLog(@"hello world from blender");
+ // NSLog(@"%s", request.fileURL.path.UTF8String);
+ NSURL *foo = [[NSURL alloc]
+ initFileURLWithFileSystemRepresentation:"/Users/ankitkumar/Pictures/IMG_3158.JPG"
+ isDirectory:NO
+ relativeToURL:nil];
+ QLThumbnailReply *reply = [QLThumbnailReply replyWithImageFileURL:foo];
+
+ handler(reply, nil);
+}
+
+@end
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 3462fcd5b99..4a9e990a192 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -1352,8 +1352,16 @@ elseif(APPLE)
if(WITH_BLENDER_THUMBNAILER)
install(
TARGETS blender-thumbnailer
- DESTINATION Blender.app/Contents/MacOS/
+ DESTINATION Blender.app/Contents/Plugins
)
+ get_target_property(BL_CODESIGN_ENTITLEMENTS blender-thumbnailer BL_CODESIGN_ENTITLEMENTS)
+ install(CODE
+ "execute_process(
+ COMMAND codesign
+ --entitlements \"${BL_CODESIGN_ENTITLEMENTS}\"
+ --force --deep --sign -
+ \"${EXECUTABLE_OUTPUT_PATH}/Blender.app/Contents/Plugins/blender-thumbnailer.appex\"
+ )")
endif()
if(PLATFORM_BUNDLED_LIBRARIES AND TARGETDIR_LIB)
diff --git a/tests/gtests/runner/CMakeLists.txt b/tests/gtests/runner/CMakeLists.txt
index f509c1df1b2..cbf82d42d30 100644
--- a/tests/gtests/runner/CMakeLists.txt
+++ b/tests/gtests/runner/CMakeLists.txt
@@ -34,7 +34,6 @@ endif()
blender_src_gtest_ex(
NAME blender
SRC "${SRC}"
- EXTRA_LIBS "${TEST_LIBS}"
SKIP_ADD_TEST
)
setup_platform_linker_libs(blender_test)