5

I'd like to experiment a bit in a Swift Playground, and in my experiment I want to use parts of my app. Specifically I'd like to instantiate some views and view controllers.

In this example, my app is called NJSTest. I add a playground, and write "import NJSTest". But Xcode says "No such module 'NJSTest'".

How can I include my app as a module in a playground?

(note, I don't want to break out the app parts as a framework by itself that I then import in my app and playground because I would like my app to be compatible with iOS 7)

Cheers

Nik

Abizern
  • 146,289
  • 39
  • 203
  • 257
niklassaers
  • 8,480
  • 20
  • 99
  • 146
  • It is not possible in my opinion. You can drag files into XCode playground, but you cant open your project in playground. – Alvin Varghese Oct 06 '15 at 09:10
  • Oh well, time to file a Radar, then. Thanks. – niklassaers Oct 06 '15 at 09:21
  • 1
    Sorry to dupe this Nick, but it is possible. The trouble you will have is that your app doesn't build a framework so you can't import that into your playground. But for what you want to do, which is to break your app into frameworks, you can use them. The tricks are 1) don't name your playground with the same name as the workspace. The frameworks have to be built. – Abizern Oct 06 '15 at 09:44
  • Hey Abizern, like I wrote I would prefer not to go down the route of putting my app code and resources into a framework. (which is why I didn't consider it a duplicate :-) ) – niklassaers Oct 06 '15 at 11:25
  • @Abizern I've added into the description my motivation for not going the framework route - to preserve iOS 7 compability. Would you mind un-duplicating it unless there is a specific question you think it is a duplicate of? :-) – niklassaers Oct 06 '15 at 14:54
  • Reopened, but I don't think Xcode let's you do what you want to do. I'll be happy to be proved wrong. – Abizern Oct 06 '15 at 14:57

1 Answers1

1

Unfortunately, Playground comes with below limitations:

  1. Playground cannot be used for performance testing.
  2. Does not support User Interaction.
  3. Does not support On-device execution.
  4. Does not support custom entitlements.

Personally, I would want to see 2 in action at least :)!

So, to answer your question, its not possible (at least at this point in time).

Abhinav
  • 37,684
  • 43
  • 191
  • 309
  • 1
    Point 4 is incorrect. You can add custom frameworks to Playgrounds. To be more precise, you can have a workspace that contains frameworks and playgrounds in that workspace that can import those frameworks. – Abizern Oct 06 '15 at 15:27
  • O wow. I saw [this link](https://developer.apple.com/library/prerelease/tvos/recipes/Playground_Help/Chapters/ImportFramework.html). Thanks @Abizern. Corrected my post now :)! – Abhinav Oct 06 '15 at 15:30