Dive into the world of programming languages used for app development.

All subtopics
Posts under Programming Languages topic

Post

Replies

Boosts

Views

Activity

Calling a Objc method directly from C
I would like to avoid the middle man and call Objective C directly from C Currently I do this This is called from a dispatch table in a pure C file _ctx->mt_render_funcs.mtlEnd(_ctx); Which calls this routine in a obj c file .m void mtlEnd(MTRenderContext mt_ctx) { // Call the Objective-C method using Objective-C syntax [(__bridge id) mt_ctx->mt_render_funcs.mtlObj mtlEnd]; } Which ends up here... in ObjC #pragma mark mtlEnd (void)mtlEnd { // vertex buffer size_t size; size = sizeof(Vertex4ColorNormalTex) * _ctx->vert_eng.current_vertex; [_currentRenderEncoder setVertexBytes:_ctx->vert_eng.vertices length: size atIndex: VertexInputIndexVertices]; [_currentRenderEncoder drawPrimitives:(MTLPrimitiveType)_ctx->vert_eng.prim_type vertexStart:0 vertexCount:_ctx->vert_eng.current_vertex]; } It would simplify this to get rid of one call and call ObjC directly. The other idea is I want to use GCD and put a lock / unlock on the call from C to ensure thread safety so I can use GCD to dispatch a thread to do the ObjC routines. I want to stick with C as the foundation so it can be used directly from C or a FFI interface from other languages. But Metal works well in ObjC and I would prefer to use that. Thanks ahead of time.
3
0
1.4k
Mar ’26
Bridging Header doesn't seem to include my Swift class
I think have done everything by the book. I added a small Swift file to my Objective-C project. This is code in the project, not in a framework, so I did not use the public keyword: import Foundation @objc TestClass: NSObject { @objc init(){} } Adding this file prompted creating a bridging header and it should have added TestClass into it. I added the import to the Objective-C .m file. This didn't produce an error so the file must be there: #import "SoftServePro-Bridging-Header.h" I made a property for an instance of the class in the .h file: @property(nonatomic,strong) TestClass *test; I cleaned the project and did one compile for the precompiler to populate the bridging header. I have set Defines Module to Yes in Build Settings -> Packaging. I added a line in the .m code to create a TestClass: self.test=[[TestClass alloc]init]; And for my trouble I get the error message Now, this looks to me like TestClass is not in my bridging header because if it were it should know exactly what TestClass is, not just consider it a forward declaration. I haven't figured out any way to look at the actual contents of the bridging header after precompile, so I don't know if TestClass is there or not. The ONLY thing that I have not followed is that the documentation I have read says to put the bridging header in the same folder as the .xcodeproj file, but Xcode put it in with all the source code files (one folder down) and who am I to argue with Xcode??
3
0
1.3k
Mar ’26
Data Disappeared
Hi, writing a database app for storing equipment details. Spent the day doing minor changes and tidying with many backups made, and always re-building to check its all working. Everything ok but then next build looses all data, what's the best thing to check to see if the data is still there, any help would be fantastic.
1
0
1.2k
Mar ’26
Apple Silicon calling printf
What is the proper way to pass arguments to printf with multiple variables using ARM64 Apple Silicon? Example: fOutputStr: .asciz "Element[%d] = %d\n" // formated output string for an output of: Element[4] = 9 This code (see below) works on Raspberry Pi 5, on my Mac Studio, I am getting this output, Element[9] = 1871655168 What do I need to do to use printf from an assembly language call with multiple variables? I am using the following code. ` .align 2 // memory alignment model for 64-bit ARMc #if defined(APPLE) .global _main // Provide program starting address to linker Mac OS _main: #else .global main // Raspian and Linux main: #endif // stack frame work setup START stp x29, x30, [sp, -16]! str x20, [sp, -16]! mov x29, sp // stack frame work setup END // setup printf call #if defined(APPLE) adrp x0, fOutputStr@PAGE add x0, x0, fOutputStr@PAGEOFF #else ldr x0, =fOutputStr #endif mov w1, #4 mov w2, #9 print_brk: #if defined(APPLE) stp X0, X1, [SP, #-16]! stp X2, X3, [SP, #-16]! bl _printf ldp X2, X3, [SP], #16 ldp X0, X1, [SP], #16 #else bl printf #endif done: // closing stack frame work ldr x20, [sp],16 ldp x29, x30, [sp],16 // exit mov w0, wzr ret .data .align 4 // intArrayPtr: .word 3,7,5,2,4,8 // word, each value is offset by 4 fOutputStr: .asciz "Element[%d] = %d\n" // formated output string
6
1
806
Mar ’26
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
3
0
334
Mar ’26
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
2
0
1.9k
Mar ’26
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
2
0
1.6k
1w
Undefined symbol
Is anyone have this problem on xcode 26 ? Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility50 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility51 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility56 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityConcurrency Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityDynamicReplacements
2
1
1.7k
1d
Error in running ROOT analysis software after the recent update of MacOs and Xcode
I am facing errors in running ROOT on my M4 Air below is the terminal output can you please help me akshatsharma@akshats-MacBook-Air ~ % root /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' ------------------------------------------------------------------ | Welcome to ROOT 6.36.06 https://root.cern | | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers | | Built for macosxarm64 on Dec 27 2025, 07:23:39 | | From tags/6-36-06@6-36-06 | | With Apple clang version 17.0.0 (clang-1700.6.3.2) | | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' | ------------------------------------------------------------------ root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root [1] .q akshatsharma@akshats-MacBook-Air ~ % xcode-select --install xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates akshatsharma@akshats-MacBook-Air ~ % xcode-select -p /Library/Developer/CommandLineTools akshatsharma@akshats-MacBook-Air ~ % sudo xcode-select --reset akshatsharma@akshats-MacBook-Air ~ % sudo xcodebuild -license accept xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance akshatsharma@akshats-MacBook-Air ~ % unset DYLD_LIBRARY_PATH unset LD_LIBRARY_PATH source /Users/akshatsharma/applications/ROOT_v6.36.06/bin/thisroot.sh root -l /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root
1
0
175
1d
macOS main.swift and Main actor-isolated conformance cannot be used in nonisolated context
For a simple, resourceless cocoa apps I used to manually setup the application lifecycle (mimicking what's documented here: https://developer.apple.com/documentation/appkit/nsapplication), so my main.swift would look like: import Cocoa let delegate = SomeDelegate() _ = NSApplication.shared NSApp.delegate = delegate NSApp.run() This triggers a warning in Xcode 26.2: "Main actor-isolated conformance of SomeDelegate cannot be used in nonisolated context; this is an error in Swift 6 language mode". so what is the recommended way to refactor above so that it is Swift 6 compliant?
1
0
172
1d
Using .mp3 files in Swift Playgrounds project
Hello, I have an issue with importing some .mp3 files into a swift playground project (in Xcode, not in the Playground app). They worked fine in the Xcode project, but for some reason playgrounds isn't able to find them. I imported them the exact same way as I did in the Xcode project.
Replies
4
Boosts
0
Views
1.5k
Activity
Feb ’26
Calling a Objc method directly from C
I would like to avoid the middle man and call Objective C directly from C Currently I do this This is called from a dispatch table in a pure C file _ctx->mt_render_funcs.mtlEnd(_ctx); Which calls this routine in a obj c file .m void mtlEnd(MTRenderContext mt_ctx) { // Call the Objective-C method using Objective-C syntax [(__bridge id) mt_ctx->mt_render_funcs.mtlObj mtlEnd]; } Which ends up here... in ObjC #pragma mark mtlEnd (void)mtlEnd { // vertex buffer size_t size; size = sizeof(Vertex4ColorNormalTex) * _ctx->vert_eng.current_vertex; [_currentRenderEncoder setVertexBytes:_ctx->vert_eng.vertices length: size atIndex: VertexInputIndexVertices]; [_currentRenderEncoder drawPrimitives:(MTLPrimitiveType)_ctx->vert_eng.prim_type vertexStart:0 vertexCount:_ctx->vert_eng.current_vertex]; } It would simplify this to get rid of one call and call ObjC directly. The other idea is I want to use GCD and put a lock / unlock on the call from C to ensure thread safety so I can use GCD to dispatch a thread to do the ObjC routines. I want to stick with C as the foundation so it can be used directly from C or a FFI interface from other languages. But Metal works well in ObjC and I would prefer to use that. Thanks ahead of time.
Replies
3
Boosts
0
Views
1.4k
Activity
Mar ’26
Bridging Header doesn't seem to include my Swift class
I think have done everything by the book. I added a small Swift file to my Objective-C project. This is code in the project, not in a framework, so I did not use the public keyword: import Foundation @objc TestClass: NSObject { @objc init(){} } Adding this file prompted creating a bridging header and it should have added TestClass into it. I added the import to the Objective-C .m file. This didn't produce an error so the file must be there: #import "SoftServePro-Bridging-Header.h" I made a property for an instance of the class in the .h file: @property(nonatomic,strong) TestClass *test; I cleaned the project and did one compile for the precompiler to populate the bridging header. I have set Defines Module to Yes in Build Settings -> Packaging. I added a line in the .m code to create a TestClass: self.test=[[TestClass alloc]init]; And for my trouble I get the error message Now, this looks to me like TestClass is not in my bridging header because if it were it should know exactly what TestClass is, not just consider it a forward declaration. I haven't figured out any way to look at the actual contents of the bridging header after precompile, so I don't know if TestClass is there or not. The ONLY thing that I have not followed is that the documentation I have read says to put the bridging header in the same folder as the .xcodeproj file, but Xcode put it in with all the source code files (one folder down) and who am I to argue with Xcode??
Replies
3
Boosts
0
Views
1.3k
Activity
Mar ’26
Data Disappeared
Hi, writing a database app for storing equipment details. Spent the day doing minor changes and tidying with many backups made, and always re-building to check its all working. Everything ok but then next build looses all data, what's the best thing to check to see if the data is still there, any help would be fantastic.
Replies
1
Boosts
0
Views
1.2k
Activity
Mar ’26
Apple Silicon calling printf
What is the proper way to pass arguments to printf with multiple variables using ARM64 Apple Silicon? Example: fOutputStr: .asciz "Element[%d] = %d\n" // formated output string for an output of: Element[4] = 9 This code (see below) works on Raspberry Pi 5, on my Mac Studio, I am getting this output, Element[9] = 1871655168 What do I need to do to use printf from an assembly language call with multiple variables? I am using the following code. ` .align 2 // memory alignment model for 64-bit ARMc #if defined(APPLE) .global _main // Provide program starting address to linker Mac OS _main: #else .global main // Raspian and Linux main: #endif // stack frame work setup START stp x29, x30, [sp, -16]! str x20, [sp, -16]! mov x29, sp // stack frame work setup END // setup printf call #if defined(APPLE) adrp x0, fOutputStr@PAGE add x0, x0, fOutputStr@PAGEOFF #else ldr x0, =fOutputStr #endif mov w1, #4 mov w2, #9 print_brk: #if defined(APPLE) stp X0, X1, [SP, #-16]! stp X2, X3, [SP, #-16]! bl _printf ldp X2, X3, [SP], #16 ldp X0, X1, [SP], #16 #else bl printf #endif done: // closing stack frame work ldr x20, [sp],16 ldp x29, x30, [sp],16 // exit mov w0, wzr ret .data .align 4 // intArrayPtr: .word 3,7,5,2,4,8 // word, each value is offset by 4 fOutputStr: .asciz "Element[%d] = %d\n" // formated output string
Replies
6
Boosts
1
Views
806
Activity
Mar ’26
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
Replies
3
Boosts
0
Views
334
Activity
Mar ’26
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
Replies
2
Boosts
0
Views
1.9k
Activity
Mar ’26
How works Experiment (Documentation) in Swift Playground?
Experiment Create a constant with an explicit type of Float and a value of 4. https://docs.swift.org/swift-book/documentation/the-swift-programming-language/guidedtour
Replies
3
Boosts
0
Views
2.1k
Activity
4w
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
Replies
2
Boosts
0
Views
1.6k
Activity
1w
The Swift Programming Language Book
Does anyone know if there will be a Swift 6 version of "The Swift Programming Language" book and if so, when it will be released for Apple Books?
Replies
5
Boosts
0
Views
1.3k
Activity
1w
Undefined symbol
Is anyone have this problem on xcode 26 ? Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility50 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility51 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility56 Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityConcurrency Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityDynamicReplacements
Replies
2
Boosts
1
Views
1.7k
Activity
1d
Error in running ROOT analysis software after the recent update of MacOs and Xcode
I am facing errors in running ROOT on my M4 Air below is the terminal output can you please help me akshatsharma@akshats-MacBook-Air ~ % root /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' ------------------------------------------------------------------ | Welcome to ROOT 6.36.06 https://root.cern | | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers | | Built for macosxarm64 on Dec 27 2025, 07:23:39 | | From tags/6-36-06@6-36-06 | | With Apple clang version 17.0.0 (clang-1700.6.3.2) | | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' | ------------------------------------------------------------------ root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root [1] .q akshatsharma@akshats-MacBook-Air ~ % xcode-select --install xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates akshatsharma@akshats-MacBook-Air ~ % xcode-select -p /Library/Developer/CommandLineTools akshatsharma@akshats-MacBook-Air ~ % sudo xcode-select --reset akshatsharma@akshats-MacBook-Air ~ % sudo xcodebuild -license accept xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance akshatsharma@akshats-MacBook-Air ~ % unset DYLD_LIBRARY_PATH unset LD_LIBRARY_PATH source /Users/akshatsharma/applications/ROOT_v6.36.06/bin/thisroot.sh root -l /Users/akshatsharma/Applications/ROOT_v6.36.06/etc/cling/std_darwin.modulemap:73:64: error: header '__type_traits/add_lvalue_reference.h' not found module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" } ^ input_line_1:1:10: note: submodule of top-level module 'std' implicitly imported here #include <new> ^ Warning in cling::IncrementalParser::CheckABICompatibility(): Failed to extract C++ standard library version. Warning in cling::IncrementalParser::CheckABICompatibility(): Possible C++ standard library mismatch, compiled with _LIBCPP_ABI_VERSION '1' Extraction of runtime standard library version was: '' root [0] new TBrowser IncrementalExecutor::executeFunction: symbol '_ZN5cling7runtime6gClingE' unresolved while linking [cling interface function]! You are probably missing the definition of cling::runtime::gCling Maybe you need to load the corresponding shared library? root
Replies
1
Boosts
0
Views
175
Activity
1d
macOS main.swift and Main actor-isolated conformance cannot be used in nonisolated context
For a simple, resourceless cocoa apps I used to manually setup the application lifecycle (mimicking what's documented here: https://developer.apple.com/documentation/appkit/nsapplication), so my main.swift would look like: import Cocoa let delegate = SomeDelegate() _ = NSApplication.shared NSApp.delegate = delegate NSApp.run() This triggers a warning in Xcode 26.2: "Main actor-isolated conformance of SomeDelegate cannot be used in nonisolated context; this is an error in Swift 6 language mode". so what is the recommended way to refactor above so that it is Swift 6 compliant?
Replies
1
Boosts
0
Views
172
Activity
1d