Brave for iOS

repository·development·Indexed 23 days ago

https://github.com/brave/brave-ios

The mobile browser application for Apple's iOS platform. This repository includes documentation for localization via Transifex, project configuration using local templates, and development workflows for BraveCore, including building xcframeworks and running unit tests. Note that primary development and the codebase have migrated to the brave-core repository.

Tokens
3.4K
Snippets
17
Records
25
Agent score
83%

What's inside brave-ios

  1. Understand Dynamic Scripts in Brave for iOS

    development

    Dynamic Scripts are scripts within the Brave for iOS environment that are not processed via Webpack or NPM. Unlike standard web-packed scripts, these are loaded directly.

    Security Requirement: Every Dynamic Script must implement a message handler. If a script is not sandboxed, developers are responsible for ensuring the message handler is properly secured to prevent unauthorized access or exploitation.

  2. How Static works: Rows, Sections, and DataSources

    development

    Static is designed to separate model data from presentation by using Rows and Sections as view models for cells.

    • Row: Represents a single row in a section. It holds data like text, detailText, and accessory types, and handles selection logic.
    • Section: A collection of Rows. It can include a header and footer.
    • DataSource: The bridge between your data and the UITableView. You assign your Sections to the DataSource and then assign the DataSource to your tableView.

    Important: Do not manually change the dataSource or delegate of your UITableView. The DataSource object must manage these to handle events correctly.

  3. Import latest translations from Transifex

    development

    To pull the latest translations from Transifex into the local Xcode project, run the pull-translations-into-project.sh script from the l10n/ directory. Errors are logged to output.log.

    Note: Before importing, be aware that the xcodebuild command-line tool used in this process does not allow specifying the import destination folder and may add duplicate .strings entries to the Copy Bundle Resources section of Build Phases. These duplicates must be removed manually.

    cd l10n/
    USERNAME=<username> PASSWORD=<password> ./pull-translations-into-project.sh
  4. Build BraveCore.xcframework for iOS

    development

    When making changes to files in the ios directory of brave-core, you must update BUILD.gn if any files are added or removed. Use npm run build with specific flags to generate the required builds.

    Build Commands:

    • Debug build:
      npm run build -- Debug --target_os=ios
    • iOS Simulator Debug build (Required for Apple Silicon simulators):
      npm run build -- Debug --target_os=ios --target_arch=arm64 --target_environment=simulator
    • Release build:
      npm run build -- Release --target_os=ios
    • arm64 Release build:
      npm run build -- Release --target_os=ios --target_arch=arm64
    # Creates debug build
    npm run build -- Debug --target_os=ios
    
    # Creates iOS simulator debug build (required to run on Apple Silicon simulators)
    npm run build -- Debug --target_os=ios --target_arch=arm64 --target_environment=simulator
    
    # Creates release build
    npm run build -- Release --target_os=ios
    
    # Creates arm64 build
    npm run build -- Release --target_os=ios --target_arch=arm64
  5. Install Static via Carthage, CocoaPods, or Manual installation

    development

    You can install the Static library using Carthage, CocoaPods, or by adding it manually to your project.

    Carthage

    Add the following to your Cartfile:

    CocoaPods

    Ensure CocoaPods version 0.37 or greater is installed. Update your Podfile with:

    Manual

    Add the project as a subproject to your project or workspace and add the appropriate framework as a target dependency.

    github "venmo/Static"
    use_frameworks!
    pod 'Static', git: 'https://github.com/venmo/Static'
  6. Add a new localized string to the project

    development

    New strings must be added statically to the Strings.swift file within the en_US locale. Use the following pattern:

    extension Strings {
        public static let someString = NSLocalizedString("SomeString", value: "Some String", comment: "Comments are used to bring context to the string to aide others")
    }
  7. Push new strings to Transifex

    development

    After adding new strings to Strings.swift, push them to Transifex by running the push-strings-to-transifex.sh script from the l10n/ directory. Any errors encountered during the push will be logged to output.log.

    cd l10n/
    USERNAME=<username> PASSWORD=<password> ./push-strings-to-transifex.sh
  8. Install localization tool prerequisites

    development

    To ensure code strings are properly tokenized and managed, you must install the following dependencies via Terminal:

    1. Install pip: sudo easy_install pip
    2. Install Tornado: sudo -H pip install tornado
    3. Install lxml: sudo -H pip install lxml
    sudo easy_install pip
    sudo -H pip install tornado
    sudo -H pip install lxml
  9. Set up the BraveCore development environment

    development

    To develop with BraveCore, you must first set up the brave-browser repository and its dependencies.

    Prerequisites:

    1. Clone the brave-browser repository.
    2. Ensure your macOS development environment meets the requirements specified in the brave-browser wiki.
    3. Include Brave NPM configs.
    4. Install Java JDK and ensure it is in your PATH.
    5. Run npm install in the brave-browser directory.

    Initial Setup: Run the following commands to initialize the iOS target:

    cd brave-browser
    git checkout -- "*" && git pull
    npm run init -- --target_os=ios