Xcode 4 unit testing linker error

后端 未结 9 867
小鲜肉
小鲜肉 2021-02-05 09:19

NOTE: \"Use GHUnit\" is not an acceptable answer to this question. I know most think GHUnit is better than the Xcode4 OCUnit, but that\'s not what I\'m asking about. I\'ll evalu

9条回答
  •  忘了有多久
    2021-02-05 09:45

    I've run into this after several merges lately where a coworker and I have both added files to the project, and not all of the implementation files are a member of the unit testing target.

    The solution:

    1. Select a small range of your .m files (use "Filter in Navigator" (cmd-opt-j) to search for .m)
    2. Show File Inspector (cmd-opt-1) to view the files' target memberships
    3. Make sure the appropriate files are a member of your test target.

    Note: if the test target checkbox shows - instead of + or being unchecked, it means that some, but not all, of the selected files are a member of the target.

    I've tried doing more intelligent things at merge time with the .xcodeproj's project.pbxproj file, but I've given up out of frustration with its inscrutability every time and fallen back on this method.

    (Another note: I only select a few files at a time for two reasons:

    • Xcode's performance for the file inspector when selecting more than 7–10 files is poor
    • Some files aren't and shouldn't be a member of the test target, and it's easier to do a process of elimination when the selected range is small)

提交回复
热议问题