Skip to content

Latest commit

 

History

History
94 lines (78 loc) · 4.28 KB

README.md

File metadata and controls

94 lines (78 loc) · 4.28 KB

Cog for iOS

The iOS build shares Cog's sources. CogAudio and the projects under Frameworks/ build for macOS and iOS alike. The plugins, which macOS loads as bundles, are compiled on iOS into one framework, CogPlugins.

Getting started

git submodule update --init --recursive
iOS/prepare.sh

prepare.sh builds the iOS third-party libraries into ThirdParty/*/ios/, which are not committed, by running Scripts/build-ios-libraries.sh (a few minutes, needs brew install cmake ninja). CI builds them too: the ios-libraries artifact of the "Check if Cog builds for iOS" workflow unpacks into place.

Layout

  • MobileCog.xcodeproj: the iOS app (Cog scheme, sources in App/), the plugins as one framework (CogPlugins), and CogPluginsTests.
    • The project is generated by generate_plugins_project.py. To add or change a plugin, edit PLUGINS there and run the script again; don't edit the project in Xcode. Files added under App/ are picked up as they are.
    • PluginController finds the plugin classes at launch among those of the loaded images.
  • App/: the SwiftUI app: the playlist, Now Playing and settings, with Player driving CogAudio's AudioPlayer as PlaybackController does on macOS. Music picked in Files is copied into the app's Documents/Music, which Files and Finder show.
    • Localizable.xcstrings holds the app's strings in English and Spanish, which follows the macOS app's wording. The keys the macOS sources ask for with NSLocalizedString are kept by hand, because the Swift compiler does not extract them. EqualizerPresets.xcstrings translates the names of Cog.q1.json's presets.
  • generate_document_types.py: declares the files the app opens in CogApp-Info.plist, from the macOS app's document types in Info.plist.template. iOS goes by type rather than by extension, so each extension gets the system's type for it or one imported for Cog. Run it again after changing the macOS app's document types. A file opened in Cog is added to the playlist and played; one shared from another app is moved into Documents/Music.
  • genversion.sh: versions the app as Scripts/genversion.sh versions the macOS one, counting commits, but from the iOS app's first commit (700560d4f, version 1) rather than the k54 tag. A shallow clone has no history to count and builds version 0.
  • CogPlugins/: the plugins framework's prefix header and build settings.
  • CogPluginsTests/: tests that find, decode and play through the plugins on the iOS Simulator.

The playlist

CogPlaylist/ is the playlist without AppKit, a framework that builds for macOS and iOS. It contains:

  • PlaylistStore: Cog's Core Data stack, on the shared DataModel.xcdatamodeld.
  • PlaylistEntry extensions: tags, URL and setMetadata, ported from Playlist/PlaylistEntry.m.
  • PlaylistModel: order, current entry, queue, shuffle, repeat and stop-after, ported from Playlist/PlaylistController.m.
  • PlaylistLoader: folders and containers through the plugins, and metadata loaded in the background.

Its rules are ported from the macOS app, so keep the two in step. The tests run on both platforms (CogPlaylist scheme). The loader is tested with the real plugins in CogPluginsTests.

For now only iOS uses it. For the macOS app to adopt it:

  • Its PlaylistController delegates to PlaylistModel.
  • It stops generating the model's classes itself, since the entity classes would otherwise exist twice.
  • It drops its own copy of MaybeSecureValueDataTransformer.

Porting more of Cog

  • A project under Frameworks/:
    • Scripts/make-multiplatform.py makes its targets build for iOS too.
    • Scripts/link-ios-libraries.py links the iOS builds of the ThirdParty/ libraries it uses, leaving the macOS ones to macOS.
  • A library in ThirdParty/: add a build_<name> function to Scripts/build-ios-libraries.sh, with the release and patches its README.md names.
  • After changing plugin sources, check that the macOS app still builds.

Differences from macOS

  • No exclusive output or DoP. Everything is resampled to the audio session's rate.
  • 2SF (vio2sf) runs without its JIT, as iOS allows no executable memory.
  • MIDI's Apple synth is MIDISynth, as iOS has no DLSSynth. Its SoundFonts are the app's resources, as on macOS.