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!
General
RSS for tagDive into the world of programming languages used for app development.
Post
Replies
Boosts
Views
Activity
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
Crash Log
We have a issue with our watch app. When we do a release build with xcode 16 the watch app will not launch and crashes on watchOS 10 and below devices.
It does not do this on debug builds...and it does not do this on xcode 15 release/debug builds.
Anybody running into watch crashes on xcode 16?
Thanks
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 ?
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
Hello,
I have a problem with Xcode, in C++ language. When I create a new project, I put my program in a file and click Build. It works correctly and without any problems, but when I enter a second file in the same project and click build, it says build failed. In the log it says, duplicate symbols appear.
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.
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
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.
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 ?
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++?
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)
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
So I found out clang can do multiarch compiles (-arch arm64 -arch x86_64). But Apple seems to have left precompiled header support out. So I built the pch separately for each arch. That all works.
The next problem is that one needs to specify -include-pch foo.x64.pch and -include-pch foo.arm64.pch on the command line. This doesn't work on the compile line, since it tries to prepend arm64 AST to a x64 .o file, and vice versa.
So there is -Xarch_arm64 and -Xarch_x86_64 . But that option is limited to one argument. But "-include-pch foo.x64.pch" is two arguments.
More details of failed attempts here:
https://github.com/llvm/llvm-project/issues/114626
And no splitting out the builds isn't the same, because then -valid_arch I don't think skips the other build. This are all libraries being built by Make, and then the universal app built using an Xcode project from the libraries.
When Xcode is connected to the mobile phone for debugging, the app that contains the logic of executing machine code runs normally, but if Xcode is disconnected and the app is run alone, it will crash.
First use the xcode-run execution function to start the app
The machine code logic executes normally
Disconnect the phone from xcode
Start the app
5.Crash
Here is the test code:https://gitee.com/FanChiang_admin/demo.git
I have a relatively unique project layered with file types (top to bottom) SwiftUI, Swift, Objective C, and C. The purpose of this layering is that I have a C language firmware application framework for development of firmware on custom electronic boards.
Specifically, I use the standard C preprocessor in specific ways to make data driven structures, not code. There are header files shared between the firmware project and the Xcode iPhone app to set things like the BLE protocol and communication command/reply protocols, etc. The app is forced to adhere to that defined by the firmware, rather than rely a design to get it right.
The Objective C code is mainly to utilize the Bluetooth stack provided by iOS. I specifically use this approach to allow C files to be compiled. Normally, everything has worked perfectly, but a serious and obtuse problem just surfaced a couple days ago.
My important project was created long ago. More recently, I started a new project using most of the same technology, but its project is newer. Ironically, it continues to work perfectly, but ironically the older project stopped working. (Talking about the Xcode iOS side.)
Essentially, the Objective C handling of the C preprocessor is not fully adhering to the standard C preprocessing in one project. It's very confusing because there is no code change. It seems Xcode was updated, but looks like the project was not updated, accordingly? I'm guessing there is some setting that forces Objective C to adhere to the standard C preprocessor rules.
I did see a gnu compiler version that did not get updated compared to the newer project, but updating that in the Build Settings did not fix the problem.
The error is in the title:
Token is not a valid binary operator in a preprocessor subexpression.
The offending macro appears in a header file, included in several implementation files. Compiling a single implementation files isolates the issue somewhat. An implementation with no Objective C objects compiles just fine. If there are Objective C objects then I get the errors. Both cases include the same header.
It seems like the Objective C compiler, being invoked, uses a different C preprocessor parser, rather than the standard. I guess I should mention the bridging header file where these headers exist, as well. The offending header with the problem macro appears as an error in the bridging header if a full build is initiated.
Is there an option somewhere, that forces the Objective C compiler to honor the standard C processor? Note, one project seems to.
#define BLE_SERVICE_BLANK( enumTag, uuid, serviceType )
#define BLE_CHARACTERISTIC_BLANK( enumTag, uuid, properties, readPerm, writePerm, value)
#define BLE_SERVICE_ENUM_COUNTER( enumTag, uuid, serviceType) +1
#define BLE_CHARACTERISTIC_ENUM_COUNTER( enumTag, uuid, properties, readPerm, writePerm, value) +1
#if 0 BLE_SERVICE_LIST(BLE_SERVICE_ENUM_COUNTER, BLE_CHARACTERISTIC_BLANK) > 0
#define USING_BLE_SERVICE
...
#if 0 BLE_SERVICE_LIST(BLE_SERVICE_BLANK, BLE_CHARACTERISTIC_ENUM_COUNTER) > 0
#define USING_BLE_CHARACTERISTIC
...
token is not a valid binary operator in a preprocessor subexpression
refers to the comparison. BLE_SERVICE_LIST() does a +1 for each item in the list. There is no further expansion. One counts services. The other counts characteristics. The errors are associated with the comparisons.
We are seeing a crash on Big Sur 11.7.10 after switching the build system to use Xcode 15
Excerpt from crash
Time Awake Since Boot: 1700 seconds
System Integrity Protection: enabled
Crashed Thread: 0
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: DYLD, [0x4] Symbol missing
Application Specific Information:
dyld: launch, loading dependent libraries
Dyld Error Message:
Symbol not found: __ZNSt3__17codecvtIDiDu11__mbstate_tE2idE
Referenced from: /Applications/SecureworksTaegis.app/Contents/MacOS/com.secureworks.agent.daemon.app/Contents/MacOS/com.secureworks.agent.daemon
Expected in: /usr/lib/libc++.1.dylib
in /Applications/SecureworksTaegis.app/Contents/MacOS/com.secureworks.agent.daemon.app/Contents/MacOS/com.secureworks.agent.daemon
Build system has the following specs :
ProductName: macOS
ProductVersion: 14.3.1
BuildVersion: 23D60
Xcode 15.2
Build version 15C500b
CMAKE PROPS
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
I wonder if this is correct behavior. I was surprised to get this result when compiling and running the following C code with Apple clang version 14.0.0 (clang-1400.0.29.102) target arm64-apple-darwin21.6.0 on a M1 Pro 12.7.6 with cc -O2 file.c:
#include <stdio.h>
#include <stdlib.h>
unsigned long long factorial(int n)
{
unsigned long long fac = 1;
while (n > 0)
fac *= n;
return fac;
}
int main()
{
return factorial(1);
}
Compiling with -O2 and running this code gives "Trace/BPT trap".
Checking with LLDB:
$ lldb ./a.out
(lldb) target create "./a.out"
Current executable set to '/Users/engelen/Projects/Euler/a.out' (arm64).
(lldb) run
Process 79580 launched: '/Users/engelen/Projects/Euler/a.out' (arm64)
Process 79580 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x100003fb4)
frame #0: 0x0000000100003fb4 a.out`main at 20.c:9:3 [opt]
6 unsigned long long fac = 1;
7 while (n > 0)
8 fac *= n;
-> 9 return fac;
10 }
11
12 int main()
The loop is non-terminating. But a breakpoint trap is triggered at the return statement. The code should just hang in the loop IMO, not trap, because it never updates variable n (a correct factorial function should decrement n). Never seen this before (not since I started wiring C code in the 80s.)
If I change the update *= into += then there is no trap.
hi
i want create a commande line tool for arm64 et intel x86-64
Xcode 16 macbook pro M3
my setting :
and
but my application compile only for arm64
who can explain to me ?
I want to be able to write a cross-platform screensaver that works on both Windows and macOS using the Pygame 2D graphics library in Python. On Windows, this is super easy - you just write your program with three possible command line arguments: /p for preview mode, /c for the configuration dialog mode, and /s for the actual full-screen screensaver mode. Then you just use pyinstaller to build an .exe file and rename the extension to .scr, and you're good to go. However, it seems that making a screensaver on macOS is a pretty convoluted process, and there was stuff about specific Objective-C functions that you had to write, and I didn't really understand the documentation. Could you please tell me if there is any way to simply get my Python Pygame program to build as a proper .saver file? Thanks!