Open onmyway133 opened 7 years ago
Great tutorial @onmyway133, very detailed, thank you very much. π
I tried your solution and it works all good π
My playground wont recognise the appframework any clue?
I recently had a discovery about this:
when adding importing a custom framework to a playground, it wonβt recognize the module until you build the framework towards a simulator, not an actual device (air development in this case) π€―
@fespinoza @festrs I think I will write a proper article for this on Medium
Hmm, can't add a framework in Xcode 9.2, there is no such a menu item.
However, I can import CocoaPods without creating a custom framework for the app, which is enough to prototype edge-cases.
@richardtop Hi, don't know what happen to you, but I can see that option in both Xcode 9.2 and 9.3. Maybe you can try force closing Xcode and start again
@onmyway133 I was creating a file, not a new project.
@fespinoza @richardtop @festrs as promised, here is the article https://medium.com/flawless-app-stories/playground-driven-development-in-swift-cf167489fe7b .Hope you find it useful β€οΈ
@onmyway133 thanks, but I think, I'm going for ReactNative for data-driven apps... The developer experience is so much faster than π
Hi, @onmyway133! I have made an example with Carthage https://github.com/artemnovichkov/UsingPlayground
Nice post @onmyway133! very detailed
i liked the iron man example. Iron man + playgrounds = β€οΈ
I am creating this repo where i put playground specific tips https://github.com/fespinoza/HowToPlayground
I feel like a step was skipped when adding the CocoaTouch Framework - do I need to select the workspace or project under the "Add to:" option? After following the instructions my compiler is still mad and can't see the frameworks correctly.
@twhitt14 Hi without seeing your project it's hard to say what's wrong. Mind making a minimal project that shows what's is not working for you?
I recently had a discovery about this:
when adding importing a custom framework to a playground, it wonβt recognize the module until you build the framework towards a simulator, not an actual device (air development in this case) π€―
@fespinoza THANK YOU THANKYOU THANKYOU SO MUCH!!!! I spent 8 hours reading every tutorial on the web and trying every Scheme combination across 3 trial projects - one of which worked then mysteriously stopped, until I saw your quote and was able to make the all work in under 3 minutes!!!
Just out of curosity. It works for the above steps, I was ambiguous at one of steps when creating a framework.
You have to specify this check: "Embed in Application"
If you set it as none. Playground will throw you error no such module.
And even cocoapods will say:
The Podfile contains framework or static library targets (AppFramework), for which the Podfile does not contain host targets (targets which embed the framework). If this project is for doing framework development, you can ignore this message. Otherwise, add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target).
So what does embed in application means here. Are we embedding this in our application? .ipa file.
This is a follow up from my post Learning from Open Source: Using Playground on how to actually add a playground to your production project.
The idea is simple: create a framework so that Playground can access the code. This demo an iOS project with CocoaPods. See the demo https://github.com/onmyway133/UsingPlayground
This is also my question to this question https://stackoverflow.com/questions/47589855/how-to-expose-your-project-code-to-a-xcode-playground-when-using-cocoapods/47595120#47595120
1. Add a pod
Create a new project called
UsingPlayground
. Create aPodfile
with a pod Cheers because we want something fun π2. Use the pod in your project
This is very straightforward. Just to make sure the pod work
Build and run the project to enjoy a very fascinating confetti π
3. Add a CocoaTouch framework
In your workspace, select the
UsingPlayground
project, add new CocoaTouch framework. Let's call itAppFramework
.Then add source files to this framework. For now, just check file
ViewController.swift
add add it to theAppFramework
target too.4. Public
Swift types and methods are internal by default. So in order for them to be visible in the Playground, we need to declare them as public.
5. Add pod to AppFramework
In order for AppFramework to use our pods, we need to add those pods into framework target as well. Add
target 'AppFramework'
to your PodfileNow run
pod install
again. In some rare cases, you need to runpod deintegrate
andpod install
to start from a clean slate6. Add a Playground
Add a Playground and drag that to our workspace. Let's call it
MyPlayground
6. Enjoy
Now edit our
MyPlayground
. You can import frameworks from pod and ourAppFramework
Remember to toggle Editor Mode so you can see Playground result