Apple M1 xcode build fails

I’m sorry if this question is a super simple fix that I’m missing, but I can’t figure it out unfortunately. I bought an Apple M1 Macbook pro, and I’ve been trying to build a project in xcode, but it keeps failing with 100 errors. I’ve tried switching the active architecture, and the build architecture, but I haven’t been able to get it to work. It works just fine in visual studio with no problem. It also occurs on new projects as well. The build is for mac not ios. This is a screenshot of some of the errors.

It’s probably that the pre-built 3rd-party libraries are not yet M1-compatible. While M1 is ARM I have little doubt that a flag needs to be changed/toggled on pre-built libraries, or possibly slightly more work done?

You could try changing your project to build as a “Catalyst” app, which should make it more of an iPad app running on MacOS?

Otherwise I would just test out running as iOS for now, in the simulator (or on device if you have one), unless you’re willing to dive into the 3rd party source or otherwise debug yourself :smiley:

I just got my M1 a few days ago, so I will try building cocos2d_lib and cocos2d_test project when I get a chance.

Awesome thanks for your response. I will try that that, and I look forward to your results!

Ok so I wasn’t able to get it to build for iOS, it was throwing some errors I couldn’t really figure out. I got the build for Mac to work by excluding architecture arm64 and running under rosetta. Let me know if you were able to make it work natively.

Has anyone been able to run natively on Apple m1 yet?

Disclaimer: someone may post an easy solution and void this reply.

If there’s not a ton of activity on this topic there may not be a ton of work on this from the community and cocos2d team. I plan to mess around with it a little over the next few weeks, but I’m not going to spend too much effort on it.

You’re free to work on it, asking more specific questions here.

Personally, I’m planning to just convert iPad games to Mac using Catalyst, and the couple other iPhone-only games I’m just going to allow in the Mac App Store (in the semi-hidden iPhone & iPad section).

The 3rd-party libraries need to be re-built, tested, and any errors/issues fixed and resolved. On the one hand iOS is arm64, so technically this should not be too much work to just re-compile, fix any bugs, and build for a macOS 11 arm64 distribution. You could attempt to use the iOS versions, but I’d be surprised if you can just drop the iOS .a lib files into the mac build?

However, no guarantees when or even if anyone is going to update the project. The cocos2d team is focused on CocosCreator now and the project’s been relatively inactive as of late, so … ??

At a high-level this is sort of straight-forward and fairly “simple”, but as with any software endeavor it’s likely that it’ll be a bit more work than expected for cocos2d-x in part because it relies on many low-level 3rd-party libraries. The one reason it might not be a lot of work is that iOS and Android both have been built and tested for arm64 architecture for a few years already.

I’m collecting issues to pass along to the team for things we need to include in a next build. This is on the list.

Awesome thanks so much for both of your information guys!

We are supporting M1 in Creator, and may move it back to cocos2d-x after releasing Creator 3.0.

Good to hear that. It must be supported in C++ as well along with cmake changes for xcode/iOS-14.
Thanks.

Sorry, i am busy on Creator native these days. What’s the problem?

Pls check forum post, there is lot of issues because of Apple changes everytime while giving new OS updates.

I agree it must be supported in C++ for a lot of us to move forward.

Ok, i will take a look. Sorry about that.

@smitpatel88
@vkreal2
I think this pull request resoled the issue. And i also updated the cmake readme doc in this commit.

1 Like

I tried building the required frameworks for arm64 Macs today, but had quite bit of trouble getting it working with the build pipeline from cocos2d-x-3rd-party-libs-src. Previously I’ve only used the precompiled binaries, so much of the tools to automate the builds and why they’re breaking is new to me. I tried to hack in support in the mac.ini file and edit the rules.mak files, but couldn’t get any of the libs building.

Fortunately I think all the libs have been updated to work with Apple Silicon, so next I’ll try to download and build each separately. More cumbersome, but should help me to understand the dependencies a bit more.

Has anyone else made any progress on this?

Now that Creator 3.0 launched, hopefully the Cocos team can take a look at Cocos2d-x again. :crossed_fingers: