With XCode 11 and macOS 10.15 (Catalina), you can now build iPad apps to run on a Mac by checking Mac in the General settings of the target. I have an iPhone/iPad app that uses ffmpeg. When I try to build it for the Mac I get this linker error:
Building for Mac Catalyst, but the linked library 'libavformat.a' was built for iOS + iOS Simulator. You may need to restrict the platforms for which this library should be linked in the target editor, or replace it with an XCFramework that supports both platforms.
So my question is, how do you build a static library for Mac Catalyst or create an XCFramework for ffmpeg? I am using build-ffmpeg.sh from FFmpeg-iOS-build-script on GitHub to bulild the ffmpeg static libraries for iOS.
Related
I am using Xcode Version 14.0.1 (14A400) & Mac OS Monterey 12.6 &
pod 'Firebase/MLVision'
pod 'Firebase/MLVisionTextModel'
When I run the app on the real device it works fine. When I run on the simulator it shows the below error:
error build: In../Pods/FirebaseMLCommon/Frameworks/FirebaseMLCommon.framework/FirebaseMLCommon(aligned_new_bca0ac320467a2457b3e306bfed17856.o), building for iOS Simulator, but linking in object file built for iOS, file '/Volumes/Mydocument/Workspace/IOS/Runnig/bcbl-ios-app/Pods/FirebaseMLCommon/Frameworks/FirebaseMLCommon.framework/FirebaseMLCommon' for architecture arm64
Please help to solve the problem
First, is your mac apple silicon CPU type or intel CPU type?
Not all 3rd party dependencies work on iOS simulators. You have to understand the architecture for a real iOS device is usually arm64. However, the simulator's architecture is Simulator-x86_64 on an intel mac and Simulator-arm64 on an apple silicon mac. So unless google provides you with a fat universal version of it, you cannot build it for simulators.
So, you can try to exclude the Simulator-arm64 arch in Xcode as suggested in this thread.
BTW, if it does not work, another thread points out that the MLVisionTextModel is deprecated. Consider migrating to the new pod.
Cause in the new pod GoogleMLKit/TextRecognition, I have seen the below code in its podfile. So I guess it supports x86_64 simulators.
"pod_target_xcconfig": {
"EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
},
Simulator builds fail in Xcode where a 3rd party framework is being used and that framework is only provided in compiled form.
Device builds are successful, but simulator builds on M1 Macs give an error:
Module compiled with Swift 5.4.2 cannot be imported by the Swift 5.5.1 compiler
The error regarding Swift versions is misleading; as noted in the question, device builds work. It is only simulator builds that fail.
The actual cause is that the framework was built without an M1 simulator slice and so Xcode cannot complete the simulator build.
The framework supplier needs to supply an updated build that includes both x86 and M1 simulator slices.
A work-around is to get Xcode to create X86 simulator builds.
In the Build Settings for your project, specify the x86_64 architecture for iOS simulator builds:
I am building an iOS App using a personal C++ library mylib.a , With the current Xcode version (13.1) When I include this library in my Frameworks and try to run on physical iOS device I have the following issue :
building for iOS, but linking in object file built for iOS Simulator, for architecture arm64
When I include my library built with a previous XCode version (I think it was Xcode 11) the app builds and runs on the device.
The issue appears both on Mac intel and M1.
You can try and exlude architectures or add a user defined setting called "VALID_ARCHS" in targets build settings[enter image description here][1]
look at image
[1]: https://i.stack.imgur.com/EAkWm.png
building for iOS Simulator, but linking in object file built for iOS, file '/Users/wahab/Documents/Github/ios-code/Pods/GoogleMaps/Maps/Frameworks/GoogleMaps.framework/GoogleMaps' for architecture arm64
I found this error while compiling my swift code in macbook pro M1. Please help me on this regards Thanks
Please Follow These steps:
Close Xcode
Go to Finder
Then Click Application
Then Right-click on the "Xcode"
Then You will see "Get Info"
Then Check marked the "Open using Rosetta"
The Maps SDK for iOS does not yet contain the architecture necessary to run on the new Arm-based Mac Simulators. For now, if you are using the new Arm-based Macs, you will need to develop using a physical device.
I had the same issue in my Mac Book as well. I updated my Mac OS to latest version which is Monterey version 12.4. After updating my Mac OS, the first time when I opened my Xcode, a pop up to install the debugging tools appeared. After the installing the debugging tools in the Xcode, I was able to run the iOS application with google maps framework in my simulator. Hope it helps.
Note:
I did try changing the architectures but it's of no use.
Build your app in iOS 13.0 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?
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:
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).