`
42087743
  • 浏览: 237770 次
  • 性别: Icon_minigender_1
  • 来自: 合肥&上海
社区版块
存档分类
最新评论

Adding Unit Tests to an existing iOS project with Xcode 4

阅读更多
        When you build a new iPhone or iPad app from scratch, you can generate a new project with tests using Xcode’s project templates, and the test dependency is set up correctly.

        However, if you add a unit test target to an existing iOS project, there are some manual steps required to set up the target correctly. Following these steps will get you up and running quickly:
  • Project MyExistingApp -> + Add Target -> iOS -> Other -> Cocoa Unit Testing Bundle
  • Name the new target something like “Unit Tests” or “MyAppTests”
  • Select your new “Unit Tests” target and click the Build Phases tab, expand Target 4
  • Dependencies and add MyExistingApp as as a Target Dependency
  • Click the Build Settings tab and set the Bundle Loader setting to $(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp
  • Set the Test Host build setting to $(BUNDLE_LOADER)
  • Go back to your app target (not the test target), set the Symbols Hidden by Default build setting to NO

        That should take care of it, and you can now start adding tests for your app. With this configuration, you continue to add application classes only to your app target, and add test classes only to your test target. Since the tests run in the app running in the simulator, the code under test can safely instantiate views and fonts, which would otherwise cause OCunit to crash when running without the Test Host setting.

引用
分享到:
评论

相关推荐

    Xcode.5.Start.to.Finish.iOS.and.OS.X.Development

    Title: Xcode 5 Start to Finish: iOS and OS X Development Author: Fritz Anderson Length: 624 pages Edition: 1 Language: English Publisher: Addison-Wesley Professional Publication Date: 2014-05-16 ISBN-...

    Learning Xcode 8(PACKT,2016)

    Over the course of the book, you will continue to explore the many facets of iOS development in Xcode by adding new features to your app, integrating gestures and sensors, and even creating an Apple ...

    Learning Xcode 8

    Over the course of the book, you will continue to explore the many facets of iOS development in Xcode by adding new features to your app, integrating gestures and sensors, and even creating an Apple ...

    Learning.Xcode.8.1785885723

    Over the course of the book, you will continue to explore the many facets of iOS development in Xcode by adding new features to your app, integrating gestures and sensors, and even creating an Apple ...

    iOS_Test_Driven_Development_by_Tutorials_v1.0.0.zip (iOS13 & Swift5.1 & Xcode11)

    The book that teaches you to write maintainable and sustainable apps by building them with testing in mind or adding tests to already-written apps. Currently updated to: Platform: iOS13; Language: ...

    Troubleshooting.Xcode.1484215613

    iOS and OS X developers who need to troubleshoot problems and limitations with Xcode. Developers with all levels of experience will find helpful information in Troubleshooting Xcode. Table of ...

    Ray Wenderlich - iOS 11 Tutorials

    The "Ray Wenderlich - iOS 11 Tutorials" is an invaluable resource for developers looking to explore and utilize the new features introduced in iOS 11. From the latest advancements in Swift to the ...

    BLE_Brigde

    This page details a Serial-to-BLE bridge sample application which can be used as a basis for adding serial communication to an existing project, creating a simple serial packet parser, and achieving ...

    IOS5 Programming Cookbook

    - **Creating a New Project**: To create a new iOS project in Xcode, you need to choose a template (such as a single view application) and provide project details like the product name, organization ...

    Learn Swift by Building Applications Explore Swift programming_Code.zip

    This practical guide will help you to begin your journey with Swift programming through learning how to build iOS apps. You will learn all about basic variables, if clauses, functions, loops, and ...

    Intermediate.iOS.Programming.with.Swift.iOS.11.and.Swift.4

    本书名为"Intermediate.iOS.Programming.with.Swift.iOS.11.and.Swift.4",是由AppCoda出品的一本中级iOS编程教材,针对iOS 11和Swift 4版本进行了专门的编写。本书旨在帮助已经掌握iOS基础开发的读者进一步提高,...

    The Core iOS Developer's Cookbook, 5th Edition

    Using Xcode modules to easily integrate system frameworks and headers Assembling views and animation, organizing view hierarchies, and understanding how views work together Supporting multiple screen ...

    iOS.Game.Programming.Cookbook.178439825X

    Adding Music to iOS Games and an Introduction to iCloud Chapter 6. Physics Simulation Chapter 7. Adding Reality to Games Chapter 8. Introduction to Game Math and Physics Chapter 9. Autonomous Moving ...

    React Cookbook: Create dynamic web apps

    You’ll find recipes on implementing server-side rendering, adding unit tests, and debugging. We also cover best practices to deploy a React application to production. Finally, you’ll learn how to ...

    Mastering.IOS.Game.Development

    The author, Miguel, has 11 years of iOS game development using xcode and has released over 10 games to the Apple AppStoreMaster player movement using touch controls as well as discuss motion controls ...

Global site tag (gtag.js) - Google Analytics