Issue testing and using Cocoapods in a Swift project

后端 未结 3 991
陌清茗
陌清茗 2020-12-28 13:15

I\'m writing an app in Swift, using XCode 6 Beta-6. I\'m using Cocoapods and I\'m creating some unit tests.

The issue is this one: apparently is not possible to hav

相关标签:
3条回答
  • 2020-12-28 13:45

    If you take a look at your main target Build Settings, you will see that there are a bunch of directories listed for the "Header Search Paths" settings.

    You either need to copy those values under the test target, or you can try and modify your Podfile to include both your main and test targets and re-run install:

    platform :ios, '7.0' 
    link_with 'mainapp', 'mainappTests'
    ...
    

    Also take care of any other header paths that could be needed and are not related to CocoaPods.

    And don't forget that your classes shall have public methods wherever you want to unit-test them.

    Hope this helps.

    0 讨论(0)
  • 2020-12-28 13:45

    Maybe you have configured the "Objective-C Bridging Header" setting at Project level, so the "Test" target inherits that value and maybe this "Test" target is not linked with Cocoapods.

    Use link_with as @sergio suggests or set the "Pods*.debug/release" configuration for the "Test" target at "Project->Info->Configuration".

    0 讨论(0)
  • 2020-12-28 13:55

    In addition to the link_with command in my Podfile i had to import my main project module in the test file. This way classes and methods don't have to public.

    Note the special @testable annotation

    @testable import my_tutorial_app

    Also my main project name had non-alphanumerical characters in it, I had to replace them with underscores _

    0 讨论(0)
提交回复
热议问题