Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

ios - Exclude pod when porting to mac with catalyst

Porting apps to mac is finally possible thanks to Catalyst, problem is, numerous pods don't support AppKit. Most common one would be Crashlytics / Firebase.

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

Since it's a recent topic, I couldn't find doc on how to remove a pod from my build for macOS but keep it for iOS and iPadOS.

It is possible to use in code:

#if !targetEnvironment(macCatalyst) 
// Code to exclude for your macOS app
#endif

But that one part of the problem, the other part is to link the pod only for iOS...

What would be the easiest/best course of action when the library is not vital for macOS but still wanted on iOS?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...