Filestructure

Build System

Directory / File Use
/configs/ Xcode configuration files
/fastlane/ Fastlane set up
/hooks/ Hooks to be integrated via husky
/Podfiles/ Cocoapods setup
/.bitrise.secrets.yml Bitrise secrets
/.gitattributes Set up for correct lfs usage, we upload one demo ad video with the demo app
/.BuildScripts Custom scripts for build system
/.BuildScripts/xcodePreGenScript.sh This scripts launch before xcodegen start generate project
/.BuildScripts/xcodePostGenScript.sh This scripts launch after xcodegen finish generate project
/.releaserc.json Semantic-release configuration
/.bitrise Bitrise configuration (it is used remotely on CI as well)
/.fugen.yml Configurations for Fugen
/Cartfile.project Selective build for carthage build --no-skip-current included only in nsoperations/carthage
/Cartfile@5.0.1 Carthage config for Swift 5.0.1
/Cartfile@5.1.3 Carthage config for Swift 5.1.3
/Cartfile.resolved@5.0.1 Carthage config resolved for Swift 5.0.1
/Cartfile.resolved@5.1.3 Carthage config resolved for Swift 5.1.3
/Gemfile Set of tools for local development
/jazzy.yml Settings for jazzy - external documentation generator
/package.json Node.js toolset used for project bootstrap settings (used by yarn command)
/project.base.yml XcodeGen config, used to project file generation. Work with this file instead of directly editing of .xcodeproj.
/project.yml XcodeGen config, used to project file generation. Work with this file instead of directly editing of .xcodeproj.

Application Code

Directory / File Use
/Example iOS/ Sample iOS host app on top of which the SDK being developed and tested
/Example tvOS/ Sample tvOS host app on top of which the SDK being developed and tested
/signal-webrtc-ios-artifacts/ Submodule, webrtc-ios library being copied during the build process
/Vendor/ Third party libraries which are compiled and packed with the SDK
/StreamLayer/ StreamLayer SDK source code

Support Files

Directory / File Use
/docs/ Documentation
/RFC/ Requests for comments
/DevResources/PaintCode.pcvd Source for generated vector graphic
/Templates/ Reswift viper templates
/.commitlintrc.js Setup for commitlint
/.editorconfig Universal IDE configuration
/.swiftlint.autocorrect.yml More info on how to run autocorrect
/.swiftlint.yml Swiftlint configuration
CHANGELOG.md Change log, autogenerated
Rambafile Generamba config, used for generation of some UI modules

Local Development

Prepare Local Environment

Prerequisites

Xcode11.3.1
Swift 5.1.3

Toolset

Installing Toolset

Xcode

Download and install xcode 11.3.1. Then

$ sudo xcode-select -s /Applications/Xcode.app

Homebrew

In the instruction above we use brew for most packages we install. It is not mandatory from any sense though.

# Fetch the newest versions of formulas 
$ brew update

Ruby

# Check ruby version
$ ruby --version
# > ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]

# If the command is not found - install ruby via brew
$ brew install ruby

Alternatively, you can install Ruby via RVM
In this case it will look something like this (for details follow the official instructions)

$ curl -sSL https://get.rvm.io | bash -s stable

# Check list of available rubies
$ rvm list known

# Install something like that - it will be listed in the available rubies
$ rvm install ruby-2.5.5

# Create gemset, which is a standalone bucket of gems
$ rvm gemset create core
$ rvm --default use ruby-2.5.5@core

Ruby bundler

$ gem install bundler
$ bundle install # Install the dependencies according to Gemfile.lock

To update Gemfile follow the recommended workflow

Bitrise

$ brew install bitrise

Node.js, yarn (package manager for Node)

# Install nvm - Node version manager
$ brew install nvm
# Install latest long time support version of Node.js
$ nvm install --lts
# Install yarn, without node
$ curl -o- -L https://yarnpkg.com/instalcdl.sh | bash 

Xcodegen

Used to generate project from a project.yml file. That’s why you do not see the *.xcodeproj file in the repository.

$ brew install xcodegen

SwiftLint

$ brew install swiftlint

Weaver

For DI, we use a Weaver framework

$ brew install weaver

Fugen

Generation execution for make stylekit on figma board based.

$ brew install almazrafi/tap/fugen

Carthage

Actually we need to use custom carthage:

$ brew tap nsoperations/formulas && brew install nsoperations/formulas/carthage

Yarn

$ brew install yarn

Bootstrap the Project

Bootstrap

Check Swift 5.1.3 toolset version via

$ carthage swift-version

Output should be 5.1.3+d6c4ba50e84722a815542bda2b6e8a42

Once all is installed, issue

yarn

This should bootstrap everything you need for local development. In the end StreamLayer.xcworkspace file should appear in the root project folder. You can open it with Xcode and compile.

Besides, yarn:prepare script should run on checkout and merge, this hooks are initialised via husky, this config you can find in package.json file.

Certificates for local development

Going further you’d want to run tests & add certs, here are the commands:

  • fastlane add_device udid:urUDID6a9df9dc440a14e54de1f0b655b0b2404b name:'Bimawa iPhone 5s' - this for add developer device to Developer account (replace udid and device name with yours)
  • fastlane dev_certs - fetch certificates for local development.

By default fastlane fetch’s certificates from github. If you need to regenerate the certificates, use export RECREATE_CERTS=true

Since February 2021 Apple requires all the accounts to have 2fa, please follow the instructions here to get authorised on behalf of our service account
https://www.dropbox.com/scl/fi/ecqgmq76uctp5ia74r5fv/iOS-CI_CD.paper

Optional: More details on the bootsrapping process

yarn runs prepare script, which initiates webrtc submodule, and then run’s xcodegen script to bootstrap the project. The details you can check in the ./package.json file.
Important note: xcodegen has following hooks to bootstrap the project:

preGenCommand: bitrise run bootstrap
postGenCommand: cd Podfiles && pod install

If you need more details on building process, check the following files:

./project.yml and ./project.base.yml for xcodegen configs
./bitrise.yml for bitrise scripts (which runc remotely on bitries CI as well)

Optional: More on Bitrise

  • bitrise setup - makes sure local machine is able to run bitrise commands
  • bitrise --help - shows available commands
  • bitrise run test - runs test workflow
  • bitrise run deploy - runs deploy workflow which push the build to the App Store Connect. You do not need to run it locally usually, since the app is deployed via CI system on bitrise.

Put MATCH_KEYCHAIN_PASSWORD=passwrod into fastlane/.env.beta.local so that certificates may be installed into your local keychain when calling fastlane certs or fastlane dev_certs

Changing xcodeproject, and dependencies

Changing the Xcode project

  1. Do changes in project.**.yml
  2. Run yarn

Updating Carthage dependencies

  1. Open Cartfile
  2. Add dependencies
  3. Go to project.base.yml and add carthage: FrameworkName to a target it needs to link to
  4. Call yarn update, it will resolve dependencies, regenerate project

Updating Pods

  1. Update dependencies in ./Podfiles/shared.rb file. It is read by ./Podfiles/Podfile during pods installation.
  2. Run cd Podfiles; pod update

Using code generators

Write new UI modules

Use Generamba

  1. generamba gen {moduleName} streamlayer_viper

  2. Open Podfiles/shared.rb - add pod to appropriate section, there are several:

    • common -> will install to all targets
    • sdk_common -> ios and tvos sdk
    • app_common -> ios and tvos app
    • ios/sdk app/framework specific
  3. Run yarn update

Distributing Framework

Manual distribution

(to be automised)

Prerequisites

xcodegen version >= 2.13.1
It is important, since xcodegen supports pregen and postgen commands

# from project.base.yml
  preGenCommand: bitrise run bootstrap
  postGenCommand: cd Podfiles && pod install

Xcodegen, in turn, runs by husky hook, described in package.json

Build the framework and creating the releases

After that, run the following commands
bitrise run sdk
Create a release, upload the build (https://github.com/StreamLayer/sdk-ios/releases)
bitrise run sdk_501
Create a release, upload the build (https://github.com/StreamLayer/sdk-ios/releases)
Update a list of releases:
https://github.com/StreamLayer/sdk-ios/blob/master/StreamLayer.json

CI Information

Platform

www.bitrise.io

Frequent CI Operations

  • Custom CI build for custom branch
    Click on ‘Start/Schedule a Build’ on the project page, there you select Branch, and workflow, and click ‘Start Build’.

External Documentation

Sources and toolset

The documentation is generated via jazzy. You can find the configs in ./jazzy.yml
Except the codebase analysys and public interfaces documentation, jazzy icludes additional guides and descriptions. It parses the files from the following directories:

  • ./docs/guides - Guides.
  • ./docs/sections - We do not add files here in general. There is only one section and it is core Documentation description. ## Add a new Guide Create a file in the ./docs/guides folder. Add a child to th custom_categories section to the ./jazzy.yml file.

Publishing

  • $ yarn docs:generate - Generate the documentation and put it to ./docs/swift_output.
  • $ yarn docs:gh-pages - Publish the documentation to the public gh-pages The documentation is being published to gh-pages branch of the sdk-ios repository. Except the documentation you can find there published releases of the SDK and sample apps (to check them out switch to the branch sample-apps)

Additional information

Code Signing

Framework Distribution