C++ in Xcode

I am trying to make a command line tool with C++ inside of Xcode and at the top I need to have: "<includeWinuser.h>", and "<includewindow.h>", but Xcode keeps telling me that they don't exist?!?! The other 2 that I am including are: "<includefstream>", and "<includeiostream>" [and those 2 are in the Xcode library and they work fine]?!?! So, is it because I am not using windows, or do I need to use another template instead of Command Line tool.

Hope I wasnt confusing here, but that is the problem. How can I fix it? I really could use getting this fixed so I can get started in my project.

The header files don't exist in Xcode because you're not using Windows. Winuser.h and window.h are Windows header files. Xcode doesn't support Windows header files.


If you want to write command-line C++ programs in Xcode, stick with the C++ standard library, its header files, and its functions. If you need to use winuser.h and window.h, install Windows on a virtual machine and write your programs in the virtual machine.

Hey thanks. I figured that that was the problem, but i wanted to be sure. So, are there libraries that do the same thing as those 2, but are in Xcode??

Winuser.h and windows.h are used to write Windows GUI apps, not command-line programs. The Mac equivalent of those libraries is Cocoa. But you use Objective-C and/or Swift with Cocoa, not C++.

ok, so what are the names of the cocoa libraries that have that same function?

If your app is a command-line app, you typically don't use any Cocoa libraries. Assuming this a port of a Windows-platform command line app, you may have been including winuser.h and windows.h for some utility functions that have nothing to do with UI, or it's even possible you didn't need to include them at all.


Try removing the includes of winuser.h and windows.h, and see what compilation errors you get. That way you'll find out what functions you need (if any), and someone can help you find a macOS alternative.

Cocoa is the library. I've never written Win32 apps before so I don't know the Cocoa class equivalents of the Windows libraries you mentioned. As I mentioned in my first response, you may want to stick with command-line programs using the C++ standard library. Cocoa has a steep learning curve.


If you want to know more Cocoa, choose Help > Documentation and API Reference in Xcode to open Xcode's documentation window. Read the Mac App Programming Guide. You can find it by typing Mac App Programming Guide in the search field at the top of the documentation window. At the top left of the window are four toolbar buttons. Click the rightmost button to show the table of contents to make reading the Mac App Programming Guide easier. You can also browse the classes by clicking the disclosure triangle next to the Swift or Objective-C listings on the left side of the window. The AppKit section will be the most useful one for you.

The things i am wanting to make right now, will access the keys pressed, the screen display, files, file sharing, probably Bluetooth, and the sort.

What template should i use for that, and would i be able to use Swift? Also, where would i be able to learn the language, or at least the basics for that type of thing; i already have a small yet good knowledge of Swift.

The things i am wanting to make right now, will access the keys pressed, the screen display

AppKit

files

Foundation (but you can also use standard C, standard C++ and POSIX APIs for this)

file sharing

I’m not sure what you mean by this. Please elaborate.

probably Bluetooth,

Core Bluetooth for Bluetooth LE; IOBluetooth for ‘classic’ Bluetooth

and the sort.

Well, that’s a pretty wide range (-:

What template should i use for that

If you’re building a GUI application for the Mac, start with the macOS > Cocoa Application template.

and would i be able to use Swift?

That’s largely up to you. To offer you any advice on that front we’d need to know more about your requirements. Firstly, do you have any cross platform code you want to share with your Windows apps?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

WWDC runs Mon, 5 Jun through to Fri, 9 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/

C&#43;&#43; in Xcode
 
 
Q