Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Mac Catalyst - linking in object file built for iOS Simulator

I am trying to build my iOS/iPadOS project on my mac using the new Mac Catalyst. When I build it on the simulator for iPhone everything is fine but when I build it on my Mac, I get this error.

in /Users/nevin/Documents/[projectName]/Pods/Crashlytics/iOS/Crashlytics.framework/Crashlytics(CLSInternalReport.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file '/Users/nevin/Documents/[projectName]/Pods/Crashlytics/iOS/Crashlytics.framework/Crashlytics' for architecture x86_64

This happens for multiple pods so if I remove Crashlytics for example, I get a similar error for another pod. Does anybody know if this is something that Crashlytics needs to fix or is it something that I can fix within my project?

like image 899
Nevin Jethmalani Avatar asked Oct 30 '19 21:10

Nevin Jethmalani


1 Answers

Mac Catalyst uses x86_64 but compiled with a target for Mac Catalyst.

I have a project that compiles for Mac Catalyst, you need to add these flags: https://github.com/ezored/conan-darwin-toolchain/blob/stable/1.1.0/conanfile.py#L183-L188

If your frameworks are not compatible, don't link it in "General > Frameworks", but select "iOS" instead of "macOS + iOS". Example:

xcode

And in your swift code add IF code to check if your framework can be imported and used with this:

#if targetEnvironment(macCatalyst)
    print("UIKit running on macOS")
#else
    print("Your regular code")
#endif

With this, you can make apps compatible with Mac Catalyst. And when your frameworks (like Crashlytics) be compatible check "macOS + iOS" again and remove check on code.

Another option is to make another target for Mac Catalyst and put only things for Mac Catalyst, but with my first option, you can build without problems.

And if you want to make frameworks with Mac Catalyst support with C++ code you can check my framework (https://github.com/ezored/ezored).

like image 66
Paulo Coutinho Avatar answered Nov 16 '22 08:11

Paulo Coutinho