简体   繁体   English

如何在 Xcode 中使用 CMake 添加 Copy Bundle Resources 阶段?

[英]How to add the Copy Bundle Resources phase with CMake in Xcode?

I have a CMake (3.12.2) project that generates an iOS Xcode project.我有一个生成 iOS Xcode 项目的 CMake (3.12.2) 项目。 And I managed to configure almost everything I need via CMake, except one thing: the Copy Bundle Resources phase.我设法通过 CMake 配置了几乎所有我需要的东西,除了一件事:复制捆绑资源阶段。

I can't find any info on how to do this, though this is a common task.我找不到有关如何执行此操作的任何信息,尽管这是一项常见任务。 And I can't just leave it and add this phase manually every time I re-generate my project.而且我不能在每次重新生成我的项目时就离开它并手动添加这个阶段。

What to do?该怎么办? Did I miss something obvious?我错过了一些明显的东西吗?

set(png_path "${YOUR_PNG_DIR}/test.png")设置(png_path“${YOUR_PNG_DIR}/test.png”)

target_sources(${TARGET} PUBLIC ${png_path}) target_sources(${TARGET} PUBLIC ${png_path})

set_source_files_properties(${png_path} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(${png_path} PROPERTIES MACOSX_PACKAGE_LOCATION 资源)

YOUR_PNG_DIR can be a cmake macro YOUR_PNG_DIR 可以是一个 cmake 宏

keyword: RESOURCE关键词:资源

https://cmake.org/cmake/help/latest/prop_tgt/RESOURCE.html https://cmake.org/cmake/help/latest/prop_tgt/RESOURCE.html

add_executable(ExecutableTarget addDemo.c resourcefile.txt add_executable(ExecutableTarget addDemo.c resourcefile.txt
appresourcedir/appres.txt ) appresourcedir/appres.txt )

target_link_libraries(ExecutableTarget heymath mul) target_link_libraries(ExecutableTarget heymath mul)

set(RESOURCE_FILES resourcefile.txt appresourcedir/appres.txt )设置(RESOURCE_FILES resourcefile.txt appresourcedir/appres.txt)

set_target_properties(ExecutableTarget PROPERTIES MACOSX_BUNDLE TRUE MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget RESOURCE "${RESOURCE_FILES}" ) set_target_properties(ExecutableTarget PROPERTIES MACOSX_BUNDLE TRUE MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget RESOURCE "${RESOURCE_FILES}" )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Xcode4项目模板将文件添加到Copy Bundle Resources构建阶段 - How do I add files to the Copy Bundle Resources build phase with an Xcode4 Project Template 用于访问“副本捆绑资源” xcode构建阶段文件的变量? - Variables to access the “copy bundle resources” xcode build phase files? Copy Bundle Resources 构建阶段包含此目标的 Info.plist 文件 'Info.plist' in xcode 6? - The Copy Bundle Resources build phase contains this target's Info.plist file 'Info.plist' in xcode 6? XCode(4.6.3)在“复制资源”阶段调用TiffUtil - XCode (4.6.3) invokes TiffUtil in the Copy Resources Phase Xcode 不会添加捆绑资源 - Xcode won't add bundle resources 获取XCODE以将运行脚本转换后的文件复制到iOS资源包中? - Get XCODE to Copy run script converted files to iOS resources bundle? Xcode Copy Bundle Resources无法找到文件 - Xcode Copy Bundle Resources can't find files 警告:“复制捆绑包资源”构建阶段包含此目标的Info.plist文件 - Warning: The Copy Bundle Resources build phase contains this target's Info.plist file Xcode“添加复制文件”构建阶段在构建通用框架时无法复制头文件 - Xcode “Add Copy Files” build phase fails to copy header files when building universal framework CMake:如何将目录复制到ios应用程序捆绑包中 - CMake: How can I copy a directory into the ios application bundle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM