Making Libraries

Universal libraries

How to make a static universal (i386, ARM) library: https://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial

2 Necessary Tricks For Making a Framework

Code reuse requires the power to build once and reuse. Cloning source code is the second lowest form of reuse (copying ideas is the lowest). Reusing the actual built code as a library is next to highest (maybe highest).

Trick 1

Make a workspace (*.xcworkspace). In Visual Studio terms this is a solution (*.sln). It collects multiple projects into an overarching scope, and makes a single framework product in /Users/YOURNAME/Library/Developer/Xcode/DerivedData/WORKSPACE-WEIRDCODE/Build/Products/Debug.

Playgrounds don’t seem to get built into the framework, but can reference it:

import LLLibrary

That provides a means of hand testing and learning how to use the code in the framework.

Trick 2

Implicit initializers are private. All classes that can be used to instantiate an object outside the library need a public initializer, even one that seems empty:

    public init() {}