2

What I'm trying to do is test a Swift file frequently after making tiny changes to the file. The file may contain one or more structs and classes.

I don't care about a concept of an "app" because this is purely an academic exercise to practice some new concepts I've learned. I just want to test the file and don't care about the app and anything related to the app.

You may be asking why? Speed. I want it to be really fast to test, right now it takes a few seconds for the most trivial example. I see it does a lot of work to build the targets:

enter image description here

abc123
  • 8,043
  • 7
  • 49
  • 80
  • You could always try and use a playground. Not sure if that is what you are looking to do though. However, I don't think there is a way to build with only a couple files but I could be wrong. – Kendel Jan 24 '15 at 18:14

1 Answers1

-2

You should try a Swift Playground.

Here is the description at developer.apple.com/swift:

Interactive Playgrounds

Playgrounds make writing Swift code incredibly simple and fun. Type a line of code and the result appears immediately. If your code runs over time, for instance through a loop, you can watch its progress in the timeline assistant. The timeline displays variables in a graph, draws each step when composing a view, and can play an animated SpriteKit scene. When you’ve perfected your code in the playground, simply move that code into your project. Some uses for playgrounds include:

  • Design a new algorithm, watching its results every step of the way

  • Create new tests, verifying they work before promoting into your test suite

  • Experiment with new APIs to hone your Swift coding skills

Community
  • 1
  • 1
sameer-s
  • 415
  • 3
  • 12
  • Why does he need a playground? Why does the app get built when running test cases that don't call it? I want to test code without added stuff like playground. I don't want behind the scenes things, like calls to the application or simulator, going on when I click 'run' or 'test' I simply want to run what the test file says to run. – Timothy Swan Aug 17 '15 at 22:18
  • Also, since I need to use a playground for now, how in the world do I get it to have access to sister file classes for testing? – Timothy Swan Aug 17 '15 at 22:23
  • Wow, apparently not. Your answer really isn't solving my problem, even though I have the some question as the asker. http://stackoverflow.com/questions/24029090/can-swift-playgrounds-see-other-source-files-in-the-same-project – Timothy Swan Aug 17 '15 at 22:57