“无法导入桥接头” iOS单元测试

时间:2018-12-17 08:49:52

标签: ios xcode unit-testing cocoapods objective-c-swift-bridge

我有一个带有2个开发目标和1个单元测试目标的iOS项目。开发目标是混合的(同时使用Objective-c和Swift),因此我必须在项目中使用Bridging-Header.h

问题是当我想使用以下代码将模块导入到我的单元测试类中时:

@testable import <Module>

通过添加以上行,单元测试将停止构建并输出以下错误:

/Users/admin/Projects/<Project>/Tests/<TestClass>.swift:10:18: Failed to import bridging header '/Users/admin/Projects/<Project>/Core_Services_Interfaces/<Module>-Bridging-Header.h'

似乎对于导入的Objective-c容器有一些问题。 感谢您为解决该问题提供的任何帮助。

P.S:我的Podfile

target '<TARGET_1>' do
platform :ios, '8.0'
    inhibit_all_warnings!

    pod 'GoogleAnalytics'
    pod 'GoogleIDFASupport'
    pod 'GoogleAPIClient/Calendar', '~> 1.0.2'
    pod 'GTMOAuth2', '~> 1.1.0'
    pod 'GoogleMaps'
    pod 'MARKRangeSlider'
    pod 'MGSwipeTableCell'
    pod 'KVNProgress'
    pod 'Adjust', '~> 4.11.0'
    pod 'HCSStarRatingView', '~> 1.5'
    pod 'SDWebImage', '~>3.8'
    pod 'MMPopupView'
    pod "MXPagerView"
    pod 'AppAnalytics'
    pod 'MXSegmentedPager'
    pod 'MBProgressHUD', '~> 1.1.0'
    pod 'PKHUD', '~> 4.0'
    pod 'DeviceGuru'

    use_frameworks!
    pod 'Alamofire', '~> 4.7'
    pod 'ObjectMapper', '~> 3.3.0'
    pod 'RealmSwift'
    pod 'netfox'
    pod 'KeychainSwift', '~> 11.0'
    pod 'NVActivityIndicatorView'
    pod "PullToRefreshKit" , "~> 0.6.0"
    pod 'MaterialShowcase'
    pod 'Segmentio', '~> 3.2'

    target '<TARGET_2>' do
        inherit! :complete
    end

    target '<TEST_TARGET>' do
        inherit! :complete
    end

    post_install do |installer|
        installer.pods_project.targets.each do |target|
            if target.name.include?('MaterialShowcase')
                target.build_configurations.each do |config|
                    config.build_settings['SWIFT_VERSION'] = '3.2'
                end
            end
        end
    end
end

0 个答案:

没有答案