使用 Xcode 15 beta 4/5/6 和
Cocoapods
作为 xcode 工作区,当我使用 Apple Vision Pro SDK
(不是为 iPad 设计的,但成功了)编译项目时,出现一些错误,第一个一个是这样的:
Module 'xxx' not found
cocoapods
尚未支持Apple Vision Pro SDK
,但尚未得到证实。
我开发了一种将 VisionOS 支持集成到 iOS 项目中的方法,并亲自测试过。这种方法有助于克服两个关键限制:
在 Xcode 项目中手动添加 VisionOS 作为目标。
将
platform :ios
保留在 Podfile 中,但添加 post_install
脚本以为所有 Pod 启用 VisionOS:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Activate VisionOS support for all Pods
config.build_settings['SUPPORTED_PLATFORMS'] = 'iphoneos iphonesimulator xros xrsimulator' # Include VisionOS (xros) and its simulator (xrsimulator)
config.build_settings['TARGETED_DEVICE_FAMILY'] = '1,2,7' # Add the 7 device family
end
end
end
尝试构建您的项目并记下任何失败的 Pod。对于失败的 Pod,您可能需要:
#if !os(visionOS)
或#if os(iOS)
)。if #available(iOS 10, visionOS 1, *)
)。UIScreen
用法,例如使用 1
代替 UIScreen.main.scale
,或使用 UIApplication.shared.connectedScenes.compactMap { ($0 as? UIWindowScene)?.keyWindow }.last?.bounds.size
代替 UIScreen.main.bounds.size
。将更改发送回原始项目,同时指向 Podfile 中修改后的分支:
pod 'Toast-Swift', git: 'https://github.com/codelathe/Toast-Swift.git', branch: 'initial_visionOS_support' # VisionOS-compatible fork of Toast-Swift
这些步骤应该使您能够将 VisionOS 支持集成到您的项目中。有关 CocoaPods VisionOS 支持的更多详细信息和正在进行的讨论,您可以参考 CocoaPods GitHub 问题。