使用催化剂移植到 mac 时排除 pod [英] Exclude pod when porting to mac with catalyst

查看:18
本文介绍了使用催化剂移植到 mac 时排除 pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多亏了 Catalyst,终于可以将应用程序移植到 mac,问题是,许多 Pod 不支持 AppKit.最常见的是 Crashlytics/Firebase.

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

由于这是最近的主题,我无法找到有关如何从我的 macOS 构建中删除 Pod 而将其保留用于 iOS 和 iPadO 的文档.

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.

可以在代码中使用:

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

但问题的一部分,另一部分是仅针对iOS链接pod...

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

当库对 macOS 并不重要但在 iOS 上仍然需要时,最简单/最好的做法是什么?

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

推荐答案

有关处理 Catalyst 不支持框架的最佳方法,你们应该阅读 Fernando Moya de Rivas,他有一个带有解决方案的github 此处 提供更多最新信息.

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.

他基本上说你只需要定义一个你不想在 mac osx 上安装的所有库的数组,像这样:['Fabric', 'Crashlytics', 'Firebase/Core',...].

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', ...].

然后,您的 pod 文件可以看起来很简单:

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

这篇关于使用催化剂移植到 mac 时排除 pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆