Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

CocoaPods Integration

Zhang edited this page Apr 20, 2019 · 1 revision

CocoaPods Integration

If you are using CocoaPods in your project, the following CocoaPods script by @chenxk-j solves the aforementioned issues once and for all. For any queries regarding this script please contact him instead.

clang_rt_search_path = '/Library/Developer/Toolchains/Hikari.xctoolchain/usr/lib/clang/10.0.0/lib/darwin/'
# This path is different depending on how you are installing Hikari
# The 10.0.0 part depends on Xcode version and will change to 11.0.0 when Xcode enters 11.0.0 era
# Below is the alternative path if you are not using the pkg installer and are building and installing from source
# 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
        clang_rt_reference = files_references_hash[target.platform_name.to_s]
        if clang_rt_reference == nil
            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|
            origin_build_config = config.base_configuration_reference
            origin_build_config_parser = Xcodeproj::Config.new(origin_build_config.real_path)
            lib_search_path = origin_build_config_parser.attributes()['LIBRARY_SEARCH_PATHS']
            if lib_search_path != nil
                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