Using Alamofire within a Playground

后端 未结 4 641
说谎
说谎 2020-12-15 23:17

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 proo

相关标签:
4条回答
  • 2020-12-15 23:41

    Apple provides excellent step-by-step instruction to do so here: Importing Custom Frameworks Into a Playground

    0 讨论(0)
  • 2020-12-15 23:45

    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
    0 讨论(0)
  • 2020-12-15 23:52

    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

    0 讨论(0)
  • 2020-12-16 00:01

    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
    0 讨论(0)
提交回复
热议问题