Google MLKit and Mac Catalyst - ios

I would like to provide a desktop (Catalyst/MacOS) version of a successful iOS App. My App uses MLKit Translate. I installed the current version of MLKit via cocoa pods in the usual way (pod file):
target 'myApp' do
use_frameworks!
pod 'GoogleMLKit/Translate', '3.2.0'
end
which works fine for iOS targets, but for a Mac target, the linker spews:
ld: building for Mac Catalyst, but linking in object file built for iOS Simulator,
file '/Users/myApp-1.04/Pods/MLKitTranslate/Frameworks/MLKitTranslate.framework/MLKitTranslate'
for architecture x86_64
It looked like Google was porting MLKit to Mac back in 2019. Did they stop, or is there some conditional code for the pod file to make it link?

Related

Run the 'CouchbaseLiteSwift' pod lib on mac os?

Was anyone able to run the 'CouchbaseLiteSwift' pod lib on mac os? I am getting:
building for Mac Catalyst, but linking in dylib built for iOS Simulator, file '.../Pods/CouchbaseLite-Swift/iOS/CouchbaseLiteSwift.framework/CouchbaseLiteSwift' for architecture x86_64
I also found no application that runs CouchbaseLite on macOS except: https://github.com/couchbaselabs/CouchbaseLiteViewer that uses objC libraries.
I also faced the same issue by using Cocoapod. But you can do it another way.
First download Couchbase Lite
Then, unzip the file and drag CouchbaseLiteSwift.framework from your Finder to the Xcode navigator.
Click on Project > General > Embedded Binary and add CouchbaseLiteSwift.framework to this section.
Import the framework and start using it in your project.

Library not loaded: #rpath/FBLPromises.framework/FBLPromises iOS 13.3.1 [duplicate]

This question already has answers here:
After updating iOS, all applications using the framework stopped running on the device, but they run on the simulator
(7 answers)
Closed 2 years ago.
My app crashes on lunch and getting this error:
dyld: Library not loaded: #rpath/FBLPromises.framework/FBLPromises
Referenced from: /private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Zeta
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises: code signature invalid for '/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises'
/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises: stat() failed with errno=25
/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises: code signature invalid for '/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises'
/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises: stat() failed with errno=1
/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises: code signature invalid for '/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises'
/private/var/containers/Bundle/Application/11X3EC15-5A16-4E27-AC4A-FB0503E6F1E2/Zeta.app/Frameworks/FBLPromises.framework/FBLPromises: stat() failed with errno=1
(lldb)
I used it on my own device (iPhone 11 pro) iOS 13.3.1.
It was working perfectly fine before I update my device to iOS 13.3.1 .
My app also works perfectly fine on the simulator (iPhone 11 - iOS 13.3).
Using Xcode 11.3.1.
Removing the profile from my device and trusting again didn't work.
UPDATE: Tried to build it using Xcode Beta 11.4 and didn't work.
UPDATE II:
The only pods that I'm using are Firebase/Auth, Firebase/Core, Firebase/Firestore.
Commenting use_frameworks! and using use_modular_headers! gave me these errors: Showing Recent Issues The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the range of supported deployment target versions is 8.0 to 13.2.99. (For all the pods in the project)
You are probably using free developer account. Apple blocked utilizing external frameworks on free accounts with 13.3.1 upgrade. Try downgrading to 13.3 if still possible or buy Apple Developer License.
UPDATE 04/2020: Upgrading to iOS 13.4 and XCode 11.4 currently solves this issue.
I had the same problem after updating my iPhone to iOS 13.3.1.
The fix that has worked for me:
In the Podfile remove use_frameworks! and add ,:modular_headers => true after each pod.
Close xcode, update pods and rebuild.
My full Podfile looks like this:
target 'HeatingClient' do
# use_frameworks!
pod 'RxSwift',:modular_headers => true
pod 'RxCocoa',:modular_headers => true
end
This issue is specific to iOS 13.3.1 devices with free dev account, i was struggling with it for 4 days and got the solution.
Uninstall Pods from your project folder, use terminal:
sudo gem install cocoapods-deintegrate cocoapods-clean
pod deintegrate
pod clean
rm Podfile
Initialize pods again in project, terminal:
pod init
In Podfile change this line:
target 'exampleproject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
to this lines:
target 'exampleproject' do
# Comment the next line if you don't want to use dynamic frameworks
# use_frameworks!
use_modular_headers!
Install Pods again in terminal:
pod install
Open project by file .xcworkspace and do Product > Clean Build Folder
(Command+Shift+K)
Run and build with free developer account on your iOS 13.3.1 device.
As was mentioned above:
Apple blocked utilizing external frameworks on free accounts with
13.3.1 upgrade.
So use developer account with active subscription or use static libraries.
Solution for Cocoapods - use use_modular_headers!
I was using apple free account, switched to apple paid account and it worked in iOS 13.3.1
Are you using a non-developer Apple ID to install the app on your phone? It looks like iOS 13.3.1 has broken apps installed with free Apple IDs, but only if they contain embedded frameworks. If it's possible to link all your dependencies as static libraries rather than frameworks (for example, if you're using Cocoapods you can remove use_frameworks! from your Podfile), that should fix the issue for now.
the issue is with iOS 13.3.1 and free developer accounts . the issue is fixed on latest iOS 13.4 beta I confirm it.
for now you can use
use_modular_headers!
instead of
use_frameworks!
in project Podfile
Looks like whe only way to avoid error on free account is use ios 13.3, because even in iOS 13.4 beta apple didn't fix it.
Using use_modular_headers! is not working for Firebase.
Probably the problem on the Xcode or the framework itself, I was got the same error on Xcode 11.4 beta and iOS 13.4 beta 1. Use the Xcode 11.3.1 for running on real devices until the next beta of Xcode will be released.
Open the file extension and make sure it's in the library.
Open Xcode -> Products -> YourApp.app -> "Show in Finder"
And you see
"YourApp.app" -> This file "right click" and click -> "Show package
contents"
If libraries are missing here, you need to check their framework connections.
I tried commenting out the line # use_frameworks! in the pod file and it worked
I faced same problem. power of use_modular_headers! to avoid the crash and below code working for me.
# Uncomment the next line to define a global platform for your project
#platform :ios, '10.0'
target 'YourApp' do
use_modular_headers!
# Pods for YourApp
pod 'Kingfisher', '~> 5.0'
pod 'GoogleMaps'
pod 'GooglePlaces'
pod 'Firebase/Analytics'
end

FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture x86_64 building for Mac Catalyst

I run my project for mac with catalyst, I got a below error. for Firebase
Please see below link for pod file.
/Users/ios/Desktop/xxxxxx/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRConnectorUtils_d79571aba36a7d46e5c6ca87a6fec1c1.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file '/Users/ios/Desktop/xxxxxx/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture x86_64
Remove pod Firebase/Analytics from the Podfile.
Firebase Analytics does not currently support Catalyst. Full details about Firebase support for Catalyst at https://github.com/firebase/firebase-ios-sdk#development-for-catalyst.
Add a thumbs-up to https://github.com/firebase/firebase-ios-sdk/issues/4563 to indicate interest in Analytics support.
In the meantime, a workaround to conditionally add Analytics only for iOS, see https://stackoverflow.com/a/58768815/556617
While Cocoapods is not yet supported, I've been able to install and run Firebase Analytics & Crashlytics in a Mac Catalyst app using Swift Package Manager (documentation here)
In Xcode, install the Firebase libraries by navigating to File > Swift Packages > Add Package Dependency…
In the prompt that appears, select the Firebase GitHub repository:
https://github.com/firebase/firebase-ios-sdk.git
Select the desired Frameworks (Analytics, Crashlytics...)
Make sure to add the same frameworks in Build Phases / Link Binary with Libraries of your target.

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?
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).

Custom framework not loaded dyld: Library not loaded: #rpath/Custom.framework/

I have an app with several custom dynamic frameworks which means I am using iOS 8 as the SDK on Xcode 6.2. My Mac is on Yosemite. The frameworks have Swift sources and resources.
The app is distributed enterprise so I just create an IPA and distribute internally via a webpage where the user can download and install the app.
The app installs and runs on iPhone 5(iOS 8.1.2), iPod Touch(iOS 8.2) and simulators BUT NOT on iPhone 6(iOS 8.1.2). The error is always dyld: Library not loaded: #rpath/Custom.framework/. Whenever I remove and add the frameworks back to try to fix it another framework pops up as not loaded on the iPhone 6. (Why!!!)
The following were set:
#executable_path/Frameworks
Embedded Content Contains Swift code - Yes
Frameworks in embedded binaries
Embedded Frameworks
Link Binary With Libraries
What is causing these issues and what can I do to make sure that the app runs consistently on all devices and iOS 8 versions.
Most of the solutions I find are trial and error suggestions.
I didn't stop figuring out the cause of the issue until I read about architectures. So it prompted me to build the frameworks while an iPhone 6 is connected. I created a project with all the defaults. Added a couple of frameworks including Alamofire. Built them while iPhone 6 connected. Generated an archive and deployed and installed OTA. When the app was installed it ran without issues.
I tried to confirm it by building against my iPod(MD717ZP/A). I'm not sure if this was 5th Gen. First I emptied the derived data folder, Cleaned all projects including the frameworks. Built and deployed the app. Installed it on the iPod it was running. I installed it on the iPhone 6 and it crashed instantly.
I tried the same process over and over again. Built against iPhone 6 then iPod then installed on both. The results just confirmed that I need to have it built on iPhone 6 so the app would run on that device and lower.
Remember I ONLY did add the frameworks to "Embedded Binaries" (Target > General > Embedded Binaries) then built on iPhone 6 to make it work. This could mean you need to have the latest device if you want it running on all devices due to some architecture requirements.
Update:
In addition to the knowledge above you may want to check the "Build Active Architecture Only" section in the Build Settings tab. It means it will build based on the connected hardware if set to YES else it will build for the architectures you support like Valid Architectures.
Check the Linking section in the Build Settings tab, following item may not been set:
Runpath Search Paths = #executable_path/Frameworks
This fixed an error for me:
dyld: library not loaded: #rpath/CorePlot.framework/CorePlot
reason: image not found
I had same issue with xcode 10 with Mojave & I am using Cocoa pods, here are my solution :
Make sure your target->build settings->iOS Deployment Target is set to the latest IOS.
In Pod file, remove "inherit! :search_paths" for the test UI target. For Eg.
Existing pod file :
target 'MyApp' do
pod 'oAuthorize'
target 'MyUITest1' do
inherit! :search_paths
end
target 'MyFunctionalTest' do
inherit! :search_paths
end
end
Remove "inherit! :search_paths" for all sub-targets.
target 'MyApplication' do
pod 'oAuthorize'
target 'MyUITest1' do
end
target 'MyFunctionalTest' do
end
end

Resources