Using Alamofire within a Playground

那年仲夏 提交于 2019-11-29 01:41:20
Canucklesandwich

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.

  1. 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
  2. Command-N (create file) -> {Platform} -> Source -> Playground
  3. If not already in a Workspace file, File -> Save as Workspace. To be paranoid, I close the project / workspace and (re)open the workspace.
  4. Click on the playground file created in #2, and add the import import Alamofire

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

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!