Missing C++ support in Xcode9.2 for MacOS app? Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
User avatar
xuboying
Experienced Solver
Experienced Solver
Posts: 55
Joined: Fri Apr 22, 2016 9:51 am

Missing C++ support in Xcode9.2 for MacOS app?

Post by xuboying »

I just fixed all installing issues of wxWidgets 3.1 on MacOS 10.12 and then found out an embarrass thing that xcode9.2 could not create native macOS app using C++ language, it's only supporting ObjectC or Swift.

Is it possible to make Xcode supporting C++ or I shall switch to any other IDEs
(unfortunatly visual studio for mac does not support C++ neigher)
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by ONEEYEMAN »

Hi,
Is this instructions work for you?

Thank you.
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by eranon »

I'm using Code::Blocks under OS X 10.9 Mavericks (should work in macOS too); just installed the Xcode's command line tools without the IDE.

--
EDIT: And in case the most recent Xcode doesn't provide any C++ compiler (don't know), you can install it by yourself.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
User avatar
xuboying
Experienced Solver
Experienced Solver
Posts: 55
Joined: Fri Apr 22, 2016 9:51 am

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by xuboying »

eranon wrote:I'm using Code::Blocks under OS X 10.9 Mavericks (should work in macOS too); just installed the Xcode's command line tools without the IDE.

--
EDIT: And in case the most recent Xcode doesn't provide any C++ compiler (don't know), you can install it by yourself.
Coud code::blocks generate the necessary bundle file to pack a application so it can be run in lancher?
My task is to write cross-platform C++ project, it's mainly develop in Windows(Visual Studio) with a little adaption in Mac
I can do compile in commandline with wx-config in mac, but no idea of packing to app, it was previously done by older version of Xcode.
User avatar
xuboying
Experienced Solver
Experienced Solver
Posts: 55
Joined: Fri Apr 22, 2016 9:51 am

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by xuboying »

ONEEYEMAN wrote:Hi,
Is this instructions work for you?

Thank you.
Looks like a guide of creating a commandline c++ project, this is still supported in Xcode9.
Thans you
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by eranon »

xuboying wrote:Coud code::blocks generate the necessary bundle file to pack a application so it can be run in lancher?
My task is to write cross-platform C++ project, it's mainly develop in Windows(Visual Studio) with a little adaption in Mac
I can do compile in commandline with wx-config in mac, but no idea of packing to app, it was previously done by older version of Xcode.
Code::Blocks doesn't generate anything for you, but an app bundle is nothing more than a special directory including a normalized tree. It's not so difficult to find some documentations about the structure of an app bundle (what I did when I wanted to produce mines) and you just have to create it at post-build stage from a shell script... And, in my opinion, it's far more instructive to master every step than relaying on an obscure black box like Xcode (freedom is often a matter of knowledge).

Well, here is one of my scripts (here called "OSX_post_build.sh") from one of my projects:

Code: Select all

#!/bin/sh

# Shopifight (c) FFh Lab - Post-build treatment
# (Eric Lequien - 2016/07/23)

if [ $# -lt 2 ]
then
	echo "Usage : $0 Debug|Release BundleName [BinName]"
	echo "NB1 : No BinName assumes use of lowered BundleName"
	echo "NB2 : Project must be in lowered BundleName directory"
	echo "EG. : $0 Debug Alify alify"
	echo "      to (re)create ./alify/bin/Debug/Alify.app"
	exit 1
fi

export APP_NAME="${2}"


if [ "${3}" = "" ]
then
    export EXE_NAME=$(echo ${2} | tr "[A-Z]" "[a-z]")
else
    export EXE_NAME="${3}"
fi

export PROJECT_NAME=$(echo ${2} | tr "[A-Z]" "[a-z]")
export WORKING_DIR="./${PROJECT_NAME}/bin/${1}"
export RESOURCES_DIR="./../compo"
#export DOCS_DIR="./help"

cd "`dirname "$0"`"
if [ ! -d ${WORKING_DIR} ]
then
	echo "Error : ${WORKING_DIR} does not exist"
	exit 1 
fi

echo "Reset eventual bundle"
if [ ! -f "${WORKING_DIR}/${EXE_NAME}" ]
then
	# Build options in Codeblocks have been configured to directly build the executable in bundle tree
	echo No '${WORKING_DIR}/${EXE_NAME}', so we assume binaries has been built directly in bundle tree 
	if [ ! -f "${WORKING_DIR}/${APP_NAME}.app/Contents/MacOS/${EXE_NAME}" ]
	then
		echo Neither ${WORKING_DIR}/${EXE_NAME} nor ${WORKING_DIR}/${APP_NAME}.app/Contents/MacOS/${EXE_NAME} found !
		exit 1
	fi
	
	# we preserve the executable before to entirely renew the bundle (avoid to keep any eventual orphan files inside it)
	cp ${WORKING_DIR}/${APP_NAME}.app/Contents/MacOS/${EXE_NAME} ${WORKING_DIR}/${EXE_NAME}
fi
rm -rf ${WORKING_DIR}/${APP_NAME}.app

echo "Generate Symbolic file"
if [[ $WORKING_DIR =~ "Release" ]]
then
    dsymutil ${WORKING_DIR}/${EXE_NAME} -o ${WORKING_DIR}/${EXE_NAME}.dSYM
fi

echo "Strip symbols in RELEASE only" 
if [[ $WORKING_DIR =~ "Release" ]]
then
    strip ${WORKING_DIR}/${EXE_NAME}
fi

echo "Build bundle tree"
mkdir ${WORKING_DIR}/${APP_NAME}.app    
mkdir ${WORKING_DIR}/${APP_NAME}.app/Contents
mkdir ${WORKING_DIR}/${APP_NAME}.app/Contents/MacOS
mkdir ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources

echo "Add resources"
cp "${RESOURCES_DIR}/icon/shopifight_icon.icns" ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/${EXE_NAME}.icns
cp "${RESOURCES_DIR}/EULA/eula_en.pdf" ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/
#cp "${RESOURCES_DIR}/eula_fr.pdf" ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/
#cp "${DOCS_DIR}/help_en.pdf" ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/
#cp "${DOCS_DIR}/help_fr.pdf" ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/

mkdir ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/en.lproj
mkdir ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/fr.lproj
cp ./${PROJECT_NAME}/lang/fr/wxstd.mo ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/fr.lproj/wxstd.mo
cp ./${PROJECT_NAME}/lang/fr/${PROJECT_NAME}.mo ${WORKING_DIR}/${APP_NAME}.app/Contents/Resources/fr.lproj/${PROJECT_NAME}.mo

echo "Set metadata"
echo 'APPL????' > ${WORKING_DIR}/${APP_NAME}.app/Contents/PkgInfo
cp ./${PROJECT_NAME}/OSX_Info.plist ${WORKING_DIR}/${APP_NAME}.app/Contents/Info.plist
# cp version.plist ${APP_NAME}.app/Contents/
# cp InfoPlist.strings ${APP_NAME}.app/Contents/Resources/English.lproj/

echo "Set executables"
cp ${WORKING_DIR}/${EXE_NAME} ${WORKING_DIR}/${APP_NAME}.app/Contents/MacOS/${EXE_NAME}
rm ${WORKING_DIR}/${EXE_NAME}

echo "Resolve dependencies"
#dylibbundler -of -b -x ./${APP_NAME}.app/Contents/MacOS/${APP_NAME} -x ./${APP_NAME}.app/Contents/MacOS/codesnippets -x ./${APP_NAME}.app/Contents/MacOS/cb_share_config -x ./${APP_NAME}.app/Contents/MacOS/cb_console_runner -x ./${APP_NAME}.app/Contents/MacOS/libcodeblocks.0.dylib -x ./${APP_NAME}.app/Contents/MacOS/libwxsmithlib.0.dylib -x ./${APP_NAME}.app/Contents/MacOS/libwx_macu-2.8.0.dylib -d ./${APP_NAME}.app/Contents/MacOS/

#for dotso in ./${APP_NAME}.app/Contents/MacOS/*.so
#do
#echo $dotso
#	install_name_tool -change ${WORKING_DIR}/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib $dotso
#	install_name_tool -change ${WORKING_DIR}/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib $dotso
#	install_name_tool -change ${WORKING_DIR}/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib $dotso
#done

echo Done !
echo ${APP_NAME}.app created in ${WORKING_DIR}
exit 0
I call it on post-build from C::B with this kind of command line (here it will build the app bundle "Alify.app" from the executable called "alify" found under "bin/OSX_LLVM-Clang_x64_Debug_wx30"):

Code: Select all

$(PROJECT_DIR)/../OSX_post_build.sh OSX_LLVM-Clang_x64_Debug_wx30 Alify alify
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
User avatar
xuboying
Experienced Solver
Experienced Solver
Posts: 55
Joined: Fri Apr 22, 2016 9:51 am

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by xuboying »

eranon wrote:
xuboying wrote:Coud code::blocks generate the necessary bundle file to pack a application so it can be run in lancher?
My task is to write cross-platform C++ project, it's mainly develop in Windows(Visual Studio) with a little adaption in Mac
I can do compile in commandline with wx-config in mac, but no idea of packing to app, it was previously done by older version of Xcode.
Code::Blocks doesn't generate anything for you, but an app bundle is nothing more than a special directory including a normalized tree. It's not so difficult to find some documentations about the structure of an app bundle (what I did when I wanted to produce mines) and you just have to create it at post-build stage from a shell script... And, in my opinion, it's far more instructive to master every step than relaying on an obscure black box like Xcode (freedom is often a matter of knowledge).

Well, here is one of my scripts (here called "OSX_post_build.sh") from one of my projects:
...

Exactly what I need! Thank you so much!!
Apple closes the door and you open it for me :)
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by eranon »

Enjoy, xuboying!
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by ONEEYEMAN »

Hi,
That was a tutorial on how to create a normal Cocoa C++ application inside Xcode.
And this is exactly what I followed when I was creating my application under OSX with the libraries.

Thank you.
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by eranon »

Do you have a link, ONEEYEMAN? I remember, I searched a little (and concatenated various infos from various sources) to achieve the final step for a complete working bundle...

--
EDIT: Oh! but maybe you anwered to "Looks like a guide of creating a commandline c++ project, this is still supported in Xcode9?"... Not sure.
Last edited by eranon on Fri Feb 02, 2018 8:05 pm, edited 1 time in total.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by ONEEYEMAN »

eranon,
Check the link I posted in the very first reply to this thread.

Thank you.
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by eranon »

OK, understood afterward, ONEEYEMAN (see EDIT I written at the same time you wrote your message above LOL).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
User avatar
xuboying
Experienced Solver
Experienced Solver
Posts: 55
Joined: Fri Apr 22, 2016 9:51 am

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by xuboying »

ONEEYEMAN wrote:Hi,
That was a tutorial on how to create a normal Cocoa C++ application inside Xcode.
And this is exactly what I followed when I was creating my application under OSX with the libraries.

Thank you.
Hi
I checked the guide. it was for Xcode is 7.2.1, so I did not read it carefully. The eranon's suggestion is more direct.
Thank your all the same!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by ONEEYEMAN »

Hi,
xuboying wrote:
ONEEYEMAN wrote: Hi,
That was a tutorial on how to create a normal Cocoa C++ application inside Xcode.
And this is exactly what I followed when I was creating my application under OSX with the libraries.

Thank you.
Hi
I checked the guide. it was for Xcode is 7.2.1, so I did not read it carefully. The eranon's suggestion is more direct.
Thank your all the same!

Are you saying that all those options are gone in the new Xcode?

Thank you.
User avatar
xuboying
Experienced Solver
Experienced Solver
Posts: 55
Joined: Fri Apr 22, 2016 9:51 am

Re: Missing C++ support in Xcode9.2 for MacOS app?

Post by xuboying »

ONEEYEMAN wrote:Hi,
xuboying wrote:
ONEEYEMAN wrote: Hi,
That was a tutorial on how to create a normal Cocoa C++ application inside Xcode.
And this is exactly what I followed when I was creating my application under OSX with the libraries.

Thank you.
Hi
I checked the guide. it was for Xcode is 7.2.1, so I did not read it carefully. The eranon's suggestion is more direct.
Thank your all the same!

Are you saying that all those options are gone in the new Xcode?

Thank you.

Hi
It has been a long time since my last working in Mac (EL capition). Now I doubt the options is not changed in Xcode 7 and Xcode 9. Maybe last time C++ had been removed from Xcode and I just create OC project and wipe OC code then add CPP files to it :)
However I could not confirm that :)
Sorry for the poor memory.
Post Reply