Hello everyone! I just get started to cocos2d-x but I have a problem. I’m following common steps to create a “Hello World” project. But I’m taking errors even if I try it on mac directory by “cmake …/… -GXcode” command or on ios directory by “cmake …/… -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos” command.
Cocos2dx (I use 3.17) works just fine on an M1 (my fat binary App is live in the Mac Appstore). No need for any adjustments, just make sure to link with M1 compiled dependencies (quite easy to find those online, compile yourself or use the ones from Cocos Builder). ARM libraries for iOS are not the ones to link to.
Hi @pinky2012
Can you please give detailed reply? Like what libraries need to reply and in which folder?
That will be great for lot of developers.
Thanks.
For any prebuilt library your app uses, you would need to find or create a “fat” library that contains both Intel and Apple silicon versions of the library (so the the libXXX.a files). There is nothing more to it really.
Which libraries and which folders depends heavily on your project and your cocos version. Most you can find in the Cocos2d/external folder. You’d have to replace all the Mac libraries (that you use and link against) with fat libraries also containing the Apple silicon build.
In my case I just started the build process (changed target to Intel + Apple Silicon) and I fixed (i.e. created or downloaded fat libraries) each error that I got. In some cases I just removed the dependency as I am not using it.
Most external libraries Cocos2d-x uses are also used by Cocos Creator. As Cocos Creator is Apple silicon compatible, most linker errors are solved by replacing your Cocos2d external dependencies for Mac with the ones from Cocos Creator (not just the lib files, also the header files. And if you do so , make sure you don’t mess up builds for other platforms).
I got my app to work within a few hours (and that was including making a version of the Nakama library for Apple Silicon that has tons of other dependencies as well).
It looks like you’re building for the iOS simulator, and in that case, do not build for ARM, but build for x86_64, since the simulators work for that architecture (even on the M1 Mac).
Hello @R101 thank you for your kind response… i added the x86_64. but still getting same error attaching ref. ss. please please do help me to get resolve this…! thank you
If it’s an iOS simulator build, then you cannot have arm64 and armv7 in the VALID_ARCHS list. It must only be x86_64.
If you’re using cmake to create your iOS simulator build, then add this in the root CMakeLists.txt of your project, which will set the correct architecture just for the simulator build: