I'm new to iOS development and using Xcode and I'm having trouble getting Alamofire to work within a Playground. There's some functionality I'd like to test out for proof of concept but the library is not linked to the Playground and I've tried getting it to play nicely. I have Alamofire set up to work within an iOS (not in a Playground) project before the installation instructions in the Github Alamofire repo were recently updated.
Any suggestions on how to get Alamofire to import properly in the Playground?
Apple provides excellent step-by-step instruction to do so here: Importing Custom Frameworks Into a Playground
Here is what I consider to be the simplest straight line path:
Download and build Alamofire:
brew install carthage
echo "github \"Alamofire/Alamofire\"" > Cartfile
carthage update
Configure the workspace with a playground file and Alamofire.
- From the
Carthage/Build/{iOS / OSX}
directory, drag the Alamofire.framework file into your link library list: {Project Name} -> {Target Name} -> Build Phases -> Link Binary With Libraries
Command-N (create file) -> {Platform} -> Source -> Playground
- If not already in a Workspace file,
File -> Save as Workspace
. To be paranoid, I close the project / workspace and (re)open the workspace.
- Click on the playground file created in #2, and add the import
import Alamofire
You can create a playground within the project also like in this tutorial
Steps
- If the project is not in a workspace, save as workspace
- Create new Playground, by adding to workspace level in the project pane
- Ensure your project has a framework target. If it doesn't Edit the scheme to add a new
Cocoa Touch Framework
target (it doesn't need to have unit tests)
- Add the files that you want to use in the playground, to the new framework target
- Build the Framework by selecting the target in the build box at the top
- In the playground, import the Framework. If the classes you want to use are not public, you need to import like so:
@testable import ModuleFramework
You can try moving library to
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/
Then you can import and use it right in your playground