This seems to defeat the purpose of a developer forum, if no one can respond to posts except for Apple. Some of my posts are less than 1 month old? Even I don't check the forums that often, but it would be nice to respond to people's questions that have accumulated.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I would like to see examples of how to do this. Apple states that explicit clang modules don't work with C++ interop. ObjC++ has simple interop with C++. Swift does not. And so I'd like to know how to setup my C++ projects to build them as clang modules.
Since this api requires &__dso_handle instead of the standard file/line/func, I had to modify my entire log system to pass this down from the macro call sites.
I have many callbacks that typically just forward data from other C++ libraries that never supply a dso_handle. so it's great how this logging system breaks most logger systems and doesn't have a warning level to match fault/error. I have the forwarded threadName, timestamp, etc and no where to store that in os_log. syslog was more powerful and clear than os_log, but I'm sure it's now too late to head down a more reasonable path..
So I pass the &__dso_handle all the way to the log command and hand it into the macro
#define my_os_log_with_type(dso, log, type, format, ...) __extension__({ \
os_log_t _log_tmp = (log); \
os_log_type_t _type_tmp = (type); \
if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
OS_LOG_CALL_WITH_FORMAT(_os_log_impl, \
((void*)dso, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
} \
})
Logger.mm
// This doesn't work, logging the dso from the callsite. No file/line.
my_os_log_with_type(entry.dso, os_log_create( "com.foo", entry.tag), logLevel(entry.level)), "%{public}s", text );
// This does work, but who wants to jump to the forwarding log implementation?
os_log_with_type(os_log_create( "com.foo", entry.tag), logLevel(entry.level)), "%{public}s", text );
To minimize uptime, I am currently using two command buffers. One holds offscreen commands and is then committed. Then the second waits 20-30ms under heavy gpu use on nextDrawable, does a little work, and calls presentDrawable(which is drawable.present in addScheduledHandler).
This whole setup seems less than ideal. On Android, Vulkan stalls very little on vkImageAquire, and mostly on vkQueuePresent, but that is after the command buffer is ended and submitted. Doing that present call on a thread is often suggested, but the command buffer is already complete and submitted to the gpu before that call.
Metal stalls the commit of the command buffer from this fundamental architecture limitation. I would prefer to have a single command buffer here. The nextDrawable especially with frontBufferOnly set is really just a reference to a drawable, and shouldn't lead to such a long stall. This also makes using double buffering nearly impossible.
I see region support in MTLBuffer to MTLTexture upload calls, but I’d like to upload an entire level of same-sized mips in 1 call. Calling these routines once for every image x 2048 layers x every mip is a lot of commands. If I could do this once for each mip size, that seems more efficient, though a longer command for Metal to complete.
I have MSL .metal files generated by a parser that go into a blue reference folder. Xcode barely highlights "half" and "return" in purple and nothing else. .metal files that are included in project have blue and other highlights.
It's also quite limiting that VSCode has hlsl and a metal plugin, but Xcode doesn't syntax highlight my source HLSL files that I generate the .metal files from. This is quite common to go from HLSL or spirv back to MSL, since there is no path from MSL to spriv.
So I'm trying to maintain free open-source macOS tools. These two tools are sandboxed and hardened runtime. One is an image viewer that writes out a perftrace file into the sandbox folder (in Containers). Then another app tries to open that perftrace file (json).
When the perftrace file is opened in Xcode (signed and notarized), the file opens fine the first and all subsequent times.
When the opening app is kram-profile (signed not notaraized), the file opens once and then nothing can ever open it again. The app has attribute com.apple.quarantine set on it.
The only workaround to then open this file is to remove the attribute
xattr -d com.apple.quarantine <filename>
This is my tool build in Xcode, and having to sign let alone notarize an app is a large amount of complexity. Also this app is available on github.
Topic:
Code Signing
SubTopic:
Notarization
I typically read an extended gamepad capture() and get all state. But PSVR2 controllers seem to report nothing. So the stick and other buttons don't do anything in a built app. They register as left/right controllers. This on vOS 26, Xcode 26, etc.
They work correctly in the main icon view, although they don't honor inverted vertical and horiztonal scrolling. Both of the default scrolls just feel wrong. When I move left I'm want to scroll level not right. Same for up/down.
I'm getting "Bad Message 431" trying to access the forums from Chrome, so I'm using Safari instead. This is a thread with a ton of people hitting this problem.
https://developer.apple.com/forums/thread/123657
I tracked it down to a bug in the validation layer. This happens with Apple's own sample code. RG16Unorm and other formats shouldn't be flagged as unsupported on a RDNA1 chip in the 16" MBP.
Please also make are R16Unorm isn't flagged either. The Metal texture loader used in the sample seems to always pick the wrong format for loaded images (RG for a height map png?), with no way to control the format.
This is the feedback assistant post on it.
https://feedbackassistant.apple.com/feedback/9540775
I'm trying to update all my projects to C++20. The C++ only projects work fine. All the Objective-C++ files, though, suddenly stop compiling. Is this supposed to work. I can't imagine [NSString stringWithUTF8String:foo] should be failing. Setting the project back to C++17 works.
I do have -fmodules and -fcxx-modules for clang modules in some projects. Do those all need to be removed for C++20 modules?
For as long as I've used Xcode, the Issue navigator shows stale errors and warnings even after the build is completely building and executing. It would be nice to have a way to retain file warnings without having to set "warnings as errors", but here the problems have already been fixed.
Also need a "Reveal in Report Navigator" since half the time these errors/warnings lack 90% of the info needed to actually fix them. There's already a "Reveal in Project Navigator" that is almost never needed.
Does this setup seem correct to get precompiled headers? When I look at the file compile times they're way too long, like it's not using the pch.
App.pch file, I set
#include "MyConfig.h"
Then in Build Settings:
GCC_PREFIX_HEADER = pathto/App.pch
GCC_PRECOMPILE_PREFIX_HEADER = YES
Force include of a header. This avoids needing to include the header first in every file.
-include MyConfig.h
or should it be?
-include App.pch
I was working on a macOS ObjC++ tool that allocated and then replaced a single MTLTexture, and noted that all of the textures were leaked. This project was built with CMake, and I found out the Xcode defaults ARC to off.
ARC has been around long enough that I can't think of many ObjC or Swift projects that would work without it. This default should probably be changed.
The workaround for now, is in all CMakeLists.txt files, to set the following:
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
When you use the simd classes like float3/matrix3x3 on Swift they are great. I can write and run code like this from existing math routines that are readily found on the web.
let value = m[0][0] * v[0]
When you try to do this in C++/ObjC, the code becomes this. This is not code readily found on the web, and is a big pain to convert.
float value = m.columns[0][0] * v[0];
Can the float3x3 and other wrappers to simd_float3x3 provide an operator[] to the column and other operations like splatting since v[0] above pulls the data out of simd registers.
We currently have to derive off the matrix classes, but it seems like functionality that should be provided in the C/C++ simd classes. A vector math library should promote better code readability than this. We seem to not be able to derive off the vector types which is an issue below.
I also have code based on classes that takes 3 elements that suddenly has to convert to this less readble form.
float3 v(x,y,z) - float3 v(simd_make_float3(x,y,z))
And then there's this code that should fill all values like init repeating in Swift. This is error prone in converting existing simd code to Accelerate simd. So then we try to wrap the float3, can't derive off them, and then lose all swizzling support, operators, etc. Then have to roll our own ops on that struct that holds a float3. What's the recommended way to make this more C++ like without more compiler support
float3 v = {3} - 3,0,0 wasn't expecting that
float3 v(3) doesn't compile
v = {3,0,0} is completely different syntax, and doesn't line up with MSL and most simd libraries
struct myfloat3 : float3 doesn't work
struct myfloat3
{
float3 v; - works, but loses swizzles, operators, etc
explicit myfloat3(float value)
myfloat3(float x, float y, float z)
...
}
How do you get a macOS 10.15 QuickLook extension to work? I added the provider from the Xcode template. The .appex file is in the app bundle under Contents/Plugins/foo-thumb.appex
Can these Quicklook thumbnail providers override the system. So if macOS doesn't handle thumbnails for most types of ktx or any ktx2 files, can I override that with my own Quicklook plugin?
I tried using qlmanage with -m, and all I see are qlgenerators in there. I don't see any .appex files registered or listed. So when I try this on ktx (org.krhonos.ktx) and ktx2 files (public.ktx2) a thumbnail isn't generated.
qlmanager just seems to hang without the -x argument. And on the one file that worked, it pops up a thumbnail but I don't think it was generated by my appex.
sudo qlmanage -t /Users/Foo/tests/Toof-a.ktx -c org.khronos.ktx -x
Testing Quick Look thumbnails with files using server:
/Users/Foo/tests/Toof-a.kt
- force using content type UTI: org.khronos.ktx
2021-05-28 10:04:52.471 qlmanage[23522:4229132] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x984b, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2021-05-28 10:04:52.477 qlmanage[23522:4229132] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x6607, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
* No thumbnail created for /Users/Foo/tests/Toof-a.ktx
Done producing thumbnails