Ken*_*ner 4 xcode ios cocoapods xcode-project xcodeproj
我有一个 Podfile,在构建 Pods.xcodeProj 时最终会包含一个包含的 xcframework,它是一个 Pods.xcodeproj 文件引用,我需要将其添加为对 pod 构建目标之一的目标引用。
我认为在 Podfile 阶段可以做这样的事情post_install,但我无法弄清楚xcodeproj(A)找到我需要添加到目标的 Nami.xcframework 引用所需的 gem 语法,然后(B)将该文件引用添加到所需的目标(请参阅下图,了解我希望调整目标成员资格的框架,我基本上只是想自动检查该目标成员资格框)。
我的 Podfile 脚本的开头如下所示:
post_install do |installer|
nami_target = installer.pods_project.targets { |f| f.name == "react-native-nami-sdk" }
#Pseudocode begins here, this is what I cannot figure out
nami_xcframework_fileref = ??
nami_target.addBuildReference(nami_xcframework)
end
Run Code Online (Sandbox Code Playgroud)
感谢您对此的任何帮助,我找到了许多示例 pod 文件脚本,但似乎没有一个能完全完成我想要做的事情。
我设法找出了我需要的完整脚本,下面的 Podfile post_install 脚本正是我想要的。
请注意,关键是虽然您可以使用该.name属性检查目标,但仅对于文件引用.path始终包含您可以检查的内容,.name通常是空白的。另一个关键项目是您需要将文件引用添加到frameworks_build_phase目标的方面。
最终脚本(添加到 Podfile 的末尾):
post_install do |installer|
puts("Attempting to add Nami.xcframework reference to react-native-nami-sdk project.")
installer.pods_project.targets.each do |target|
if target.name == "react-native-nami-sdk"
puts("Found react-native-nami-sdk target.")
all_filerefs = installer.pods_project.files
all_filerefs.each do |fileref|
if fileref.path.end_with? "Nami.xcframework"
puts("Found Nami.xcframework fileref.")
build_phase = target.frameworks_build_phase
puts("Determining if react-native-nami-sdk build phase needs correction.")
unless build_phase.files_references.include?(fileref)
puts("Adding Nami.xcframework to react-native-nami-sdk target")
build_phase.add_file_reference(fileref)
end
end
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8176 次 |
| 最近记录: |