Subprojects in Xcode with Static Libs
Static libraries produce .a files. The catch is: static libraries cannot contain Swift files. But anyway...
Workspaces and Projects
- You can add projects to projects (subprojects) or to workspaces
- Projects can be saved as workspaces
- Add a project to another project -- or a workspaces -- by adding the .xcodeproj file.
Add GBDevice as a submodule
git submodule add https://github.com/lmirosevic/GBDeviceInfo.git GBDeviceInfo
Set It Up
- Create a new, Single View Application for iOS
- Add the .xcodeproj for an Xcode project that produces a .a file
In this example we're using GBDevice.
- Set up the primary project like this
Import Objective-C to Swift
- Create a new header file called BridgingHeader.h
- Add it to the Build Settings for the Single Window App
- Utilize it in a Swift file
let version = GBDeviceInfo.init().modelString
- That's it.
The kicker is: you cannot use Swift in a static library, so there's that. Hence this other article I wrote (longer, and uses Cocoapods)