Exclude Pod When Porting to MAC with Catalyst

Exclude pod when porting to mac with catalyst

For the best approach of handling unsupported framweorks for Catalyst, you guys should read the solution of Fernando Moya de Rivas, he has a github with a solution here with more up to date information.

He basically said you just need to define an array of all of the libs you don't want to install on mac osx, like this: ['Fabric', 'Crashlytics', 'Firebase/Core', ...].

Then, your pod file can look simple as this:

# Podfile
load 'remove_unsupported_libraries.rb'

target 'My target' do
use_frameworks!
# Install your pods
pod ...
end

# define unsupported pods
def catalyst_unsupported_pods
['Fabric', 'Crashlytics', 'Firebase/Core', ...]
end

# Remove unsupported pods from your project
post_install do |installer|
installer.configure_support_catalyst
end

How to exclude XCFramework from Catalyst?

I didn't find the exact answer regarding Swift PM. But I was able to fix my issue, just switched to good old (and much more flexible) cocoapods. I used cocoapods-catalyst-support to restrict Amplify to iOS only. My podfile:

require 'cocoapods-catalyst-support'

platform :ios, '14.1'
use_frameworks!

target 'MyApp' do
pod 'Amplify'
pod 'AmplifyPlugins/AWSPinpointAnalyticsPlugin'
pod 'AmplifyPlugins/AWSCognitoAuthPlugin'

target 'MyAppTests' do
inherit! :search_paths
pod 'Amplify'
pod 'AmplifyPlugins/AWSPinpointAnalyticsPlugin'
pod 'AmplifyPlugins/AWSCognitoAuthPlugin'
end
end

catalyst_configuration do
ios 'Amplify'
ios 'AmplifyPlugins/AWSPinpointAnalyticsPlugin'
ios 'AmplifyPlugins/AWSCognitoAuthPlugin'
end

post_install do |installer|
installer.configure_catalyst
end

I basically did the same thing, @PaulBeusterien recommended in comments, but the framework is generated by cocoapods instead of Firebase ReleaseTooling.

Swift Package Manager do not support platform filters, as for Feb 2022. I contacted swift forums and Amazon support and also did my own research.

Mac Catalyst build fails with building for Mac Catalyst-x86_64 but attempting to link with file built for Mac Catalyst-arm64

I consulted Apple for this one, and their engineer recommended some things:

  1. Turn any Swift sub-projects into Swift packages, not embedded Xcode projects. So, I deleted one library's Xcode project from the parent project, and dragged its top-level directory into the parent project to include it as a Swift package. Now... this particular sub-project (SQLite.swift) already had a Swift package defined. I haven't generated a Swift package myself before, so I can't help with that. Also, don’t forget to add it to the Frameworks, Libraries, and Embedded Content list on the app’s target.

  2. Go into your project's build settings and delete the "Supported platforms" setting. If you click on the "levels" button above the build-settings list, you can see where each setting is coming from. "Supported platforms" should be non-bold. Highlight the line and press Delete if it's bold. Then go into your target and do the same thing: delete "Supported platforms."

  3. Set the Base SDK at your project (top) level to iOS; this is a must. Delete it from the target level, so it inherits from the project; I don't know if this holds true for multiple kinds of targets or all projects, but it's working for me.

  4. Remove the VALID_ARCHS build setting from all targets, if it's present. That setting is deprecated.

The "build active architecture" setting doesn't make any difference after these changes in my case. The project now builds and runs under Catalyst just fine.



Related Topics



Leave a reply



Submit