在 pod 文件中以编程方式将静态库添加到 pod 目标(链接框架和库)



我想自动将静态库文件 (.a( 添加到 xoce 中的目标 这个过程很容易手工完成:

https://www.youtube.com/watch?v=mbE3oku744c&feature=youtu.be

我认为最好的方法是在 pod 文件中。

但我不知道如何详细处理它。

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'Pods-EVORecording-EVORecording-Movesense'
# here I think could be the code for adding the .a file
end
end
end

创建它是为了获得一些提示来解决此任务。多谢。

我自己解决了这个问题。这是解决方案:

post_install do |installer|
lib_name = "libmds.a"
lib_path = "Movesense/IOS/Movesense/Release-iphoneos"
# get ref of lib file
path = File.dirname(__FILE__) + "/Pods/" + lib_path + "/" + lib_name
movesense_ref = installer.pods_project.reference_for_path(path)
installer.pods_project.targets.each do |target|
# find the right target
if target.name == 'EVORecording-iOS'
# add libmds.a file to build files
build_phase = target.frameworks_build_phase
build_phase.add_file_reference(movesense_ref)
target.build_configurations.each do |config|
# add library search paths
config.build_settings['LIBRARY_SEARCH_PATHS'] = ["$(inherited)", "$(PROJECT_DIR)/" + lib_path]
end
end
end
end