How to add a CocoaPod framework to Xcode 8 Playground
UPDATE
As of:
Xcode 8.2
You no longer need to add your pod folder into resources, simply use it as you would in the project.
Example:
Pre Xcode 8.1
Thanks to Eric Aya
, I have found a solution based on his first suggestion.
In order to add a CocoPods framework to Playground
, follow these steps:
- Add pods to your pod file and hit
pod install
- Add a new Playground file
- Click on the
Sources
folder in your playground - Click on the + for
Add Files to Sources
- Add you pod folder, in our case
HanakeSwift
- Import your project pods framework
import Pods_PodsPlayground
- Build and access your framework!
Step 3
Step 4
Step 5
Step 6, 7
How to expose your project code to a Xcode playground when using cocoapods?
It is doable. In your Podfile
, you need to declare targets for both your app and your framework, so that CocoaPods can add pods to both. Here is an example. You can check the tutorial Using Playground, demo and Medium post https://medium.com/flawless-app-stories/playground-driven-development-in-swift-cf167489fe7b
platform :ios, '9.0'
use_frameworks!
pod 'Cheers'
target 'UsingPlayground'
target 'AppFramework'
Using pods with Playgrounds in Xcode 9 (beta)
I upgraded to 9 yesterday and this morning found that I could no longer add playgrounds to my workspace with a right click/New File. The template isn't there.
The solution is to create the new playground. Open in Finder. Drag it onto the workspace. It now belongs to the workspace and has access to the podfile.
How to import RxSwift in Playground of xcode?
- You should clone the RxSwift repository on your computer
- Open
Rx.xcworkspace
- Build the
RxSwift-macOS
scheme - Open
Rx.playground
in theRx.xcworkspace
tree view and add a new page import RxSwift
in the new page.- Choose
View > Debug Area > Show Debug Area
How to import Swift Package in Playground?
In Xcode 12, you can use Swift Packages with Xcode Playgrounds.
- Open Xcode
- Create a new Workspace (
File > New > Workspace...
) - Add the desired Swift package via
File > Add Files to "Workspace Name"...
selecting the package directory. - Create a new Playground via
File > New > Playground...
. Ensure that you select the Workspace we just created as the "Add to" and "Group" option during Playground creation (in the assistant where you select the Playground's location on disk). - You can now import the Package target into your Playground and starting exploring the Package's functionality.
You can find additional details and a sample project in this WWDC20 session: Explore Packages and Projects with Xcode Playgrounds
Ensure to check the new "Build active scheme" checkbox in the inspector for your existing Playgrounds.
Related Topics
How to Make a Call Which Begin with * in Iphone
Update a Label Through Button from Different View
How to Parse This JSON in Swift
How to Pretty Print Swift Dictionaries to the Console
Nslayoutconstraint Crashes Viewcontroller
Afnetworking: Handle Error Globally and Repeat Request
Apply Gradient Color to Arc Created with Uibezierpath
iOS Certificate Pinning with Swift and Nsurlsession
How to Write Init Methods of a Uiviewcontroller in Swift
Xcode 7 Uitests with Localized Ui
Custom Cell Reorder Behavior in Collectionview
Custom Pin Image in Annotationview in iOS
Detect If a Point Is Inside a Mkpolygon Overlay
Memory-Mapped Files and Low-Memory Scenarios
iOS Facebook Sdk 4.0 Login Error Code 304
How to Make Sure API Requests Come from Our Mobile (Ios/Android) App