修改Podfile适配Hikari
Closed this issue · 1 comments
gocse commented
当前平台版本
- Xcode Version 10.1 (10B61)
- macOS Mojave 10.14.1
- Hikari LLVM7.0@20190101
- CocoaPods 1.5.3
说明
因为在使用Hikari
可能需要修改工程配置,如果工程是使用CocoaPods
管理依赖库的话,每个target
修改起来将是非常麻烦的,而且每次install
或者update
就要重新配置一遍,所以写了这个配置,减少重复劳动。该配置主要解决Pods
工程在使用Hikari
可能出现的以下问题:
- Undefined symbols ___isOSVersionAtLeast when use #ifdef __IPHONE_11_0 #56
-index-store-path
cannot specify -o when generating multiple output files
- ld: loaded libLTO doesn't support
-bitcode_hide_symbols
: LLVM version 7.0.0 for architecture armv7
使用
在Podfile
中整合以下内容就行了
#暂时没找到获取Hikari.xctoolchain路径的方法,因此这个路径根据自己本地安装路径来决定
clang_rt_search_path = '/Library/Developer/Toolchains/Hikari.xctoolchain/usr/lib/clang/10.0.0/lib/darwin/'
post_install do |installer|
generator_group = installer.pods_project.main_group.find_subpath("Frameworks", true)
files_references_hash = Hash.new
installer.pods_project.targets.each do |target|
#Issues:Undefined symbols ___isOSVersionAtLeast when use #ifdef __IPHONE_11_0 #56
clang_rt_reference = files_references_hash[target.platform_name.to_s]
#防止重复添加
if clang_rt_reference == nil
#根据target的platform值获取libclang_rt.(ios|tvos|watchos|osx).a
clang_rt_path = clang_rt_search_path + 'libclang_rt.'+target.platform_name.to_s+'.a'
clang_rt_reference = generator_group.new_reference(clang_rt_path)
files_references_hash[target.platform_name.to_s] = clang_rt_reference
end
target.add_file_references([clang_rt_reference])
target.frameworks_build_phase.add_file_reference(clang_rt_reference, true)
target.build_configurations.each do |config|
#获取原编译配置文件 PBXFileReference
origin_build_config = config.base_configuration_reference
origin_build_config_parser = Xcodeproj::Config.new(origin_build_config.real_path)
#获取原编译配置文件中的 'LIBRARY_SEARCH_PATHS'
lib_search_path = origin_build_config_parser.attributes()['LIBRARY_SEARCH_PATHS']
if lib_search_path != nil
#merge 'LIBRARY_SEARCH_PATHS'
config.build_settings['LIBRARY_SEARCH_PATHS'] = lib_search_path + ' ' + clang_rt_search_path
else
config.build_settings['LIBRARY_SEARCH_PATHS'] = clang_rt_search_path
end
#ld: loaded libLTO doesn't support -bitcode_hide_symbols: LLVM version 7.0.0 for architecture armv7
config.build_settings['HIDE_BITCODE_SYMBOLS'] = 'NO'
#Issues:-index-store-path cannot specify -o when generating multiple output files
config.build_settings['COMPILER_INDEX_STORE_ENABLE'] = 'NO'
end
end
end
HANSAFUNC commented
遇到参数错误?是版本问题?