Android library details and usage notes are here..
To add the Source Swift Package to your project, follow these steps:
-
Open your project in Xcode.
-
Go to
File>Swift Packages>Add Package Dependency.... -
In the search bar, enter the URL
https://github.com/guardian/source-apps.gitclickNext. -
Select the version rule that suits your needs, then click
Next. -
Choose the
Sourcelibrary and clickFinish.
Now, the Source Swift Package should be added to your project and you can import it wherever you need it.
If you're developing a Swift Package and want to use Source, you can add it as a dependency in your Package.swift file.
Here's how you can do it:
-
Open your
Package.swiftfile. -
Add
Sourceto the dependencies array:
dependencies: [
.package(url: "https://github.com/guardian/source-apps.git", branch: "main")
]- Add
Sourceas a dependency for your target:
targets: [
.target(
name: "YourPackageName",
dependencies: [
.product(name: "Source", package: "source-apps")
]),
]- Now, you can import
Sourcein any Swift file in your package.
If you are using in this package that doesn't already use the GuardianFonts package you will need to ensure you have registered the custom fonts.
You can skip this step if your project already includes the GuardianFonts package.
If you are using in this package that doesn't already use the GuardianFonts package you will need to ensure you
Custom fonts are registered differently in Swift Packages due to the lack of an info.plist.
You should use GuardianFonts.registerFonts() function to register the fonts contained in this swift package to use in your application.
If using this from within another module, you can do the registration within the module's init() function.
Otherwise, from within a project this can be done within the App Delegate application(_:willFinishLaunchingWithOptions:) function.
The Typography fonts provided by this library are of type GuardianFont. GuardianFont is a type provided by the GuardianFonts app which encapsulates all required font properties, eg. style, size & lineHeight.
-
Import framework -
import Source -
Use font modifier from
GuardianFontspackage -.font(Typography.headlineBld14)
This defines the brand colours from Source documentation.
- Import framework -
import Source - Access colours like so -
ColorPalette.brand400
