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

Post

Replies

Boosts

Views

Activity

CGSWindowShmemCreateWithPort log message
After ther Mac application is launched: Log error: CGSWindowShmemCreateWithPort failed on port 0 and when the application quit: No error handler for XPC error: Connection invalid Appear with Xcode 15.4 but not with 12.4 As repported by Steve4442 in "Can someone explain this message" https://Forums.Developer.Apple.com/Forums/Thread/727803 . The code don't use "windowNumbersWithOptions" Can I ignore this log message ?
10
0
206
5d
Confusion About Objective-C's Memory Management (Cocoa)
Hello everyone, There is one thing about Objective-C's memory management that confuses me, which is a returned object's lifetime from methods with names doesn't start with "alloc", "new", "copy", or "mutableCopy". Take this as an example, when using NSBitmapImageRep's representationUsingType:properties: method, it returns an NSData object (reference: https://developer.apple.com/documentation/appkit/nsbitmapimagerep/representation(using:properties:)?language=objc). While testing this out, the NSData seemed to be an owned object (it doesn't get released until the end of the program). From what I understand, this may be an auto-released object which is released at the end of an autorelease pool block. Could someone explain this in more detail? What if I want to release that NSData object before the end of the autorelease pool block? How can I know which object is autoreleased, borrowed, or owned?
3
0
310
3w
Apple Accelerate libSparse performance
I've created a Julia interface for Apple Accelerate's libSparse, via calling the library functions as if they were C (@ccall). I'm interested in using this in the context of power systems, where the sparse matrix is the Jacobian or the ABA matrix from a sparse grid network. However, I'm puzzled by the performance. I ran a sampling profiler on repeated in-place solves of Ax = b for a large sparse matrix A and random dense vectors b. (A is size 30k, positive definite so Cholesky factorization.) The 2 functions with the largest impact are _SparseConvertFromCoordinate_Double from libSparse.dylib, and BLASStateRelease from libBLAS.dylib. That strikes me as bizarre. This is an in-place solve: there should be minimal overheard from allocating/deallocating memory. Also, it seems strange that the library would repeatedly convert from coordinate form. Is this expected behavior? Thinking it might be an artifact of the Julia-C interface, I wrote up a similar program in C/Objective-C. I didn't profile it, but timing the same operation (repeated in-place solves of Ax = b for random vectors b, with the same matrix A as in the Julia) gave the same duration. I've attached the C/Objective-C below.profiling-comparison.m.txt If you're familiar with Julia, the following will give you the matrix I was working with: using PowerSystems, PowerNetworkMatrices sys = System("pglib_opf_case30000_goc.m") A = PowerNetworkMatrices.ABA_Matrix(sys).data where you can find the .m file here. (As a crude way to transfer A from Julia to C, I wrote the 3 arrays A.nzval, A.colptr, and A.rowval to .txt files as space-separated lists of numbers: the above C/objective-C reads in those files.) To duplicate my Julia profiling, do pkg> add AppleAccelerate#libSparse Profile--note the #libSparse part, these features aren't on the main branch--then run using AppleAccelerate, Profile # run previous code snippet to define A M, N = 10000, size(A)[1] bs = [rand(N) for _ in 1:M] aa_fact = AAFactorization(A) factor!(aa_fact) solve!(aa_fact, bs[1]) # pre-compile before we profile. Profile.init(n = 10^6, delay = 0.0003) @profile (for i in 1:M; solve!(aa_fact, bs[i]); end;) Profile.print(C = true, format = :flat, sortedby = :count)
2
0
260
3w
Issue Integrating C++ SDK
Hello Apple Team, I'm trying to import the Audodesk FBX SDK to my Objective-C iOS Project. The SDK is written in C++, but has support for iOS and the iOS simulator architectures. I've added the path to the include folder in the Header Search Path I've also added the paths to libfbxsdk.a in the Library Search Paths Finally, I've added the libfbxsdk.a file to the Link Binary with Libraries. However, when I build the project, I get the following error: building for 'iOS', but linking in object file (/Users/Lond/Documents/v2/Autodesk/iOS/2020.3.7/lib/ios/debug/libfbxsdk.a[28](fbxalloc.cxx.o)) built for 'macOS' In the terminal, if I type the command: 
lipo -info libfbxsdk.a I get the message Non-fat file: libfbxsdk.a is architecture: arm64 confirming that I'm using the library for the correct architecture.   Do I need to add any other confifuration option? (Like the other linker flag or something else) I'm quite new to C++, and integrating a C++ SDK into iOS is not easy.   I'm using Mac Os Sonoma 14.6.1 Tested on Xcode 15.4 and 16.2 Target Device: iPhone 13 Pro (iOS 17.6.1) iOS FBX SDK version: 2020.3.7 Link to the SDK if needed: https://aps.autodesk.com/developer/overview/fbx-sdk   Any help would be greatly appreciated Thank you
4
0
284
3w
Unexpected behavior of dispatch_main on macOS
Hi! We are seeing a bit surprising behavior of dispatch_main on macOS where it seems to spawn a different thread instead of preserving the one it gets called from. Managed to reproduce it in a completely empty command-line tool project in Xcode int main(int argc, const char * argv[]) { @autoreleasepool { dispatch_main(); return 0; } } I put a breakpoint on the line with dispatch_main and see that I am on Thread 1 and inside main function. That makes sense. I resume execution and pause again. Looking at Thread output in Xcode, I can only see Thread 2. Thread 1 is gone and the executable keeps on running. So dispatch_main did what was expected (prevented the process from termination) but throws out the thread it was called from and creates a new one? Is that behavior expected or am I missing something? Just a brain teaser at this point. But we could not make sense out of it. :)
4
1
270
3w
Odd Echo Output From Shell Script
I have a simple shell script as follows: #!/bin/bash OUTPUT="network.$(date +'%d-%m-%y').info.txt" SUPPORT_ID="email" echo "---------------------------------------------------" > $OUTPUT echo "Run date and time: $(date)" >> $OUTPUT echo "---------------------------------------------------" >> $OUTPUT ifconfig >> $OUTPUT echo "---------------------------------------------------" >> $OUTPUT echo "Network info written to file: $OUTPUT." echo "Please email this file to: $SUPPORT_ID." It just dumps the network config into a file. At some point I will have the file emailed out, but right now I'm just trying to figure out why the output looks like the following? bash ./test.sh .etwork info written to file: network.26-01-25.info.txt .lease email this file to: email Why in the world does the initial character of the last couple of "echo" commands get clipped and turned into periods? The echos for the output of the commands piped into the output file are fine. Strange... Any ideas?
2
0
280
3w
Odd Shell Echo Output...
I have a simple shell script as follows: #!/bin/bash OUTPUT="network.$(date +'%d-%m-%y').info.txt" SUPPORT_ID="emailaddress" echo "---------------------------------------------------" > $OUTPUT echo "Run date and time: $(date)" >> $OUTPUT echo "---------------------------------------------------" >> $OUTPUT ifconfig >> $OUTPUT echo "---------------------------------------------------" >> $OUTPUT echo "Network info written to file: $OUTPUT." echo "Please email this file to: $SUPPORT_ID." It just dumps the network config into a file. At some point I will have the file emailed out, but right now I'm just trying to figure out why the output looks like the following? bash ./test.sh .etwork info written to file: network.26-01-25.info.txt .lease email this file to: emailaddress Why in the world does the initial character of the last couple of "echo" commands get clipped and turned into periods? The echos for the output of the commands piped into the output file are fine. Strange... Any ideas?
3
0
274
3w
Can't access C/C++ basic libraries
Hello, I am a software engineer student and I have recently been getting problems on my Mac regarding the C/C++ libraries. I have used my macbook for uni work for months, but around 3 or 4 months ago my macbook could not compile my work since it couldnt find the basic libraries I was using. For example, iostream. I have been using VSCode, and what it exactly says is "cannot open source file "iostream". Please run the 'Select IntelliSense Configuration...' command to locate your system headers." I have tried researching, changing the include path, even using chatgpt, and nothing. Is anyone having this same problem, or is able to help me? If any other information is needed, please let me know!
1
0
413
Jan ’25
Manually calling the superclass's dealloc in the overridden dealloc method causes a crash
I have a class object created dynamically using Runtime, and I want to release some manually allocated memory resources when this object is deallocated. To achieve this, I added a custom implementation of the dealloc method using the following code: SEL aSel = NSSelectorFromString(@"dealloc"); class_addMethod(kvoClass, aSel, (IMP)custom_dealloc, method_getTypeEncoding(class_getInstanceMethod(kvoClass, aSel))); However, I encountered some issues. If I don't call the superclass's dealloc method in the cus_dealloc function, the superclass's dealloc implementation will not be executed. On the other hand, if I explicitly call the superclass's dealloc method, the program crashes. Here is the implementation of the cus_dealloc function: void custom_dealloc(id self, SEL _cmd) { // Release other memory ![]("https://developer.apple.com/forums/content/attachment/c7b0c16b-be23-4776-b8db-f22b661c5e7d" "title=iShot_2025-01-03_19.31.34.png;width=1080;height=1895") Class superClass = class_getSuperclass(object_getClass(self)); void (*originIMP)(struct objc_super *, SEL, ...) = (void *)objc_msgSendSuper; struct objc_super *objcSuper = &(struct objc_super){self, superClass}; originIMP(objcSuper, _cmd); } demo
3
0
444
Jan ’25
Is it possible to Add Reply of Push Notification from Airpod using Voice ?
We want to do below addition to iOS Mobile App. Airpod announces Push notification = which is workking now we want to use voice command that "Reply to this" and sending Reply to that notification but it is saying it is not supported in your app. So basically we need to use feature - Listen and respond to messages with AirPods Do we need to add any integration inside app for this or it will directly worked with Siri settings ? Is it possible to do in non messaging App? Is it possible to do without syncing contacts ?
0
0
267
Dec ’24
Problem with deleting SDP service (macOS, IOBluetooth)
Hello everyone. macOS, IOBluetooth framework. My goal is to create a temporary SDP service. According to the documentation, by default a temporary service is created (aka Persistent = NO), which is deleted after the application is closed. The documentation also mentions the IOBluetoothRemoveServiceWithRecordHandle function for forced removal of the service. This function is deprecated and is currently unavailable. I guesse that it has been replaced by the IOBluetoothSDPServiceRecord.removeServiceRecord method. The essence of the problem is that the server is not deleted either using removeServiceRecord or even after app closing. That is, if you create several services and try to delete them, they will remain alive. Only turning Bluetooth off and on in the OS helps. I tested all versions of macOS starting with Monteray. The same behavior. for (int i = 0; i < 10; i++) { service = [IOBluetoothSDPServiceRecord publishedServiceRecordWithDictionary:dictionary]; if (!service) { NSLog(@"Failed to create service"); } else { [service getRFCOMMChannelID:&channelID]; [service getServiceRecordHandle:&serverHandle]; NSLog(@"A new service has been created handle=%u, channelID=%hhu", serverHandle, channelID); if (service.removeServiceRecord != kIOReturnSuccess) { NSLog(@"Failed to delete service"); } //service.release; service = nil; } } Can someone confirm this behavior? And is there a solution? A minimal test example is available at the link
1
1
401
Dec ’24
Inquiry about WebRTC camera access when using Chrome browser and WKWebView API on iPadOS
We are Java application developers and we have a question regarding camera access via WebRTC on iPadOS. Specifically, on iPadOS 17.1, we are encountering an issue when trying to access the camera via the WKWebView API in the Chrome browser, where an error occurs and the camera capture fails. Our investigation suggests that device access through the navigator.mediaDevices property via the WKWebView API may not work in Chrome. However, it works as expected in the Safari browser, leading us to wonder if this is a Chrome-specific limitation, or if it's due to an iPadOS setting or specification. At this point, we are unsure if this issue is related to the WKWebView and WebRTC specifications on iPadOS 17.1, or if there are specific limitations in Chrome. We would appreciate any insights or solutions regarding camera access in iPadOS 17.1 with WKWebView and WebRTC, especially in relation to Chrome.
1
0
290
Dec ’24
Instance methods don't work on iOS18.2.
I am using CHCSVParser in objective-c to use the CSVString extension of the Array instance method. When I installed a new app on iOS18.1.1, the correct value (@"Application,"abc,def"") was returned for both the first and second turns, but when I installed a new app on iOS18.2, the correct value was returned for the first turn, but @"" was returned for the second turn. Even when I debug with step into, I can enter the CSVString for the first turn, but I cannot enter it for the second turn and after. It's as if the instance method is not being generated. There are in-app purchases between the first and second turns, but the view controllers that are called are also the same. Is there any change between iOS18.1.1 and iOS18.2? [Code] NSArray *application = [NSArray arrayWithObjects:KEY_APPLICATION, @"abc,def", nil]; NSString *applistring = [application CSVString]; NSString *appliStr = [application CSVString]; [Debug window 18.1.1 First] application __NSArrayI * @"2 elements" 0x0000000302118c00 [0] __NSCFConstantString * @"Application" 0x00000001005deab8 [1] __NSCFConstantString * @"abc,def" 0x00000001005deb78 applistring __NSCFString * @"Application,"abc,def"" 0x0000000302f7d050 appliStr __NSCFString * @"Application,"abc,def"" 0x0000000302f706f0 [18.1.1 Second] application __NSArrayI * @"2 elements" 0x00000003021b5200 [0] __NSCFConstantString * @"Application" 0x00000001005deab8 [1] __NSCFConstantString * @"abc,def" 0x00000001005deb78 applistring __NSCFString * @"Application,"abc,def"" 0x0000000302ff6dc0 appliStr __NSCFString * @"Application,"abc,def"" 0x0000000302fa4d20 [18.2 First] sapplication __NSArrayI * @"2 elements" 0x00000003019d7e80 [0] __NSCFConstantString * @"Application" 0x00000001041c6ab8 [1] __NSCFConstantString * @"abc,def" 0x00000001041c6b78 applistring __NSCFString * @"Application,"abc,def"" 0x000000030179e430 appliStr __NSCFString * @"Application,"abc,def"" 0x000000030179e5e0 [18.2 Second] application __NSArrayI * @"2 elements" 0x00000003019679a0 [0] __NSCFConstantString * @"Application" 0x00000001041c6ab8 [1] __NSCFConstantString * @"abc,def" 0x00000001041c6b78 applistring __NSCFConstantString * @"" 0x00000001efa04768 appliStr __NSCFConstantString * @"" 0x00000001efa04768
0
0
263
Dec ’24
Best way to convert HTML to PDF in a C# app on macOS?
I'm working on a cross-platform C# application that converts HTML content to PDF. The goal is to render dynamic HTML pages (including CSS and JavaScript) as high-quality, printable PDF files. Additionally, I need to support features like adding headers/footers, securing PDFs with passwords, and controlling user permissions. While everything works well on Windows, I need some help rendering consistency and handling permissions on MacOS.
4
0
469
Dec ’24
Xcode Arm vector assembly error
Every time a (valid) vector instruction is added to the .s file, xcode report an error (without vector instruction the .s file compile correctly) By example vand q8, q8, q10 found in https://developer.apple.com/forums/thread/104424 give an error What I am missing to tell xcode to accept vector instruction ?
9
0
488
Dec ’24
Is this right way to use NSString BytesNoCopy ?
In my project, i am initialising bytes with some character in cpp function, func CreateByteWithVal (), and passing to a function, func CreateNSStringFromCString(_ pPtr : UnsafeMutableRawPointer, _ pLength : Int), in swift using Swift-Cpp interop. CreateByteWithVal () allocates bytes on heap with value "AAAAAAAAAA", also calls swift function CreateNSStringFromCString. And func CreateNSStringFromCString (_ pPtr : UnsafeMutableRawPointer, _ pLength : Int) creates a NSString instance using NSString's BytesNoCopy initialiser using the bytes (pPtr) passed to it in parameter. Cpp code: void CppClass::CreateByteWithVal () { char * bytesForString = (char *) malloc (10); memset (bytesForString, 65, 10); Interop_Swift::CreateNSStringFromCString (bytesForString, 10); } Swift code: public func CreateNSStringFromCString (_ pPtr : UnsafeMutableRawPointer, _ pLength : Int) { let ns_string:NSString = NSString (bytesNoCopy: pPtr, length: pLength, encoding: String.Encoding.utf8.rawValue, freeWhenDone: false) } If we modify the byte values in memory from C++ directly, the NSString instance, which is supposed to be immutable by nature, reflects these changes. Is this approach appropriate, or is there something we're overlooking or need to address? In our project, we are mutating the byte values directly like this, and the changes are being reflected in the NSString instance : memset (bytesForString, 66, 5); Essentially, I want to confirm whether we can use this method to modify values through C++ without directly mutating the NSString instance. For the UI, we'll be reading the NSString instance by creating a native Swift String instance from it, like this: let str:String = ns_string as String Will the value of str remain consistent as long as we ensure that the correct bytes are provided by C++?
2
0
470
Dec ’24
Missing libclang_rt.osx.a library on OSX
I tried to install the flang-new compiler from Homebrew on Sequoia OSX. Complex division is broken because file divdc3 is missing. This file comes from libclang_rt.osx.a, a standard LLVM library. This library is missing on OSX. program test integer, parameter :: n=2 complex(kind=8), dimension(n,n) :: V complex(kind=8) :: PER V(1,1)=cmplx(4.0,2.0) V(2,2)=cmplx(5.0,3.0) V(1,2)=0.0 V(2,1)=0.5 PER=cmplx(1.2,1.2) V(:,:)=V(:,:)/PER end program test alainhebert@Alains-MacBook-Air-2 test_complex % flang-new test.f90 Undefined symbols for architecture arm64: “___divdc3”, referenced from: __QQmain in test-fc2bb3.o ld: symbol(s) not found for architecture arm64 flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
2
0
452
Nov ’24
using Swift Library from c++ code - calllbacks ?
Hello, Im developing an app entirely with C++, and I need to call various swift functions because it requires the Swift library. Ive seen several posts on forums about C++ callbacks and honestly I dont understand how its done exactly. I get the general idea but I am not able to understand it and make it work. I feel like people throw vague ideas and weird function names and everything gets confusing. Could anyone give me the smallest example that works please ? Just to make sure you know what I mean, here is an example of what I want to do, but you dont have to generate the code exactly for this, I want an example that I can understand please, but the swift code has to depend on a swift library. I dont want to simply call a swift function that returns x*2 ... {1} notif.swift file : coded in swift language include <UserNotifications/UserNotifications.h> function A that show notification in swift code. {2} mainwindow.cpp file : coded in C++ language import notif.swift ?? button connected to slot/function mybuttonclicked. MainWindow::mybuttonclicked(){ std::string my_result = call function A_from_swift_file(argument_1); } --The end --- I wrote the notif.swift with '?' because I dont know how you include the swift file from your cpp code and I could not find that anywhere. Maybe it is obvious, but I would really appreciate getting some help on this, Thank you everyone
5
0
619
Nov ’24