All Projects → pinterest → Xchammer

pinterest / Xchammer

Licence: apache-2.0
XCHammer generates Xcode projects from a Bazel Workspace.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Xchammer

Tulsi
An Xcode Project Generator For Bazel
Stars: ✭ 365 (+87.18%)
Mutual labels:  bazel, xcode
Index Import
Tool to import swiftc and clang index-store files into Xcode
Stars: ✭ 240 (+23.08%)
Mutual labels:  bazel, xcode
Environmentoverrides
QA assistant for a SwiftUI app: change the color scheme, accessibility settings, and localization on the fly!
Stars: ✭ 181 (-7.18%)
Mutual labels:  xcode
Todaynews
Swift4 - 今日头条
Stars: ✭ 2,187 (+1021.54%)
Mutual labels:  xcode
Cleanclosurexcode
An Xcode Source Editor extension to clean the closure syntax.
Stars: ✭ 186 (-4.62%)
Mutual labels:  xcode
Buildbuddy
BuildBuddy is an open source Bazel build event viewer, result store, and remote cache.
Stars: ✭ 182 (-6.67%)
Mutual labels:  bazel
Xcodeequatablegenerator
Xcode 8 Source Code Extension will generate conformance to Swift Equatable protocol based on type and fields selection.
Stars: ✭ 188 (-3.59%)
Mutual labels:  xcode
Luft
The Xcode Plugin that helps you write lighter view controllers
Stars: ✭ 179 (-8.21%)
Mutual labels:  xcode
Pixelsdk
The modern photo and video editor for your iPhone / iPad app. A fully customizable image & video editing iOS Swift framework.
Stars: ✭ 192 (-1.54%)
Mutual labels:  xcode
Amappexporttoipa Xcode Plugin
AMAppExportToIPA-Xcode-Plugin is a simple Xcode plugin to export .app to .ipa file.
Stars: ✭ 185 (-5.13%)
Mutual labels:  xcode
Starlark Rust
Starlark (https://github.com/bazelbuild/starlark) in Rust
Stars: ✭ 190 (-2.56%)
Mutual labels:  bazel
Openssl For Iphone
A script for compiling OpenSSL for iOS Devices (iPhone, iPad, iPod Touch, AppleTV, MacCatalyst)
Stars: ✭ 2,190 (+1023.08%)
Mutual labels:  xcode
Satin
A 3D Graphics Framework built on Apple's Metal
Stars: ✭ 182 (-6.67%)
Mutual labels:  xcode
Traceutility
Extract data from .trace documents generated by Instruments
Stars: ✭ 188 (-3.59%)
Mutual labels:  xcode
Lgbutton
A fully customisable subclass of the native UIControl which allows you to create beautiful buttons without writing any line of code.
Stars: ✭ 2,216 (+1036.41%)
Mutual labels:  xcode
Xvim2
Vim key-bindings for Xcode 9
Stars: ✭ 2,297 (+1077.95%)
Mutual labels:  xcode
Expandable Table View
Expandable UITableView in iOS
Stars: ✭ 180 (-7.69%)
Mutual labels:  xcode
Macos Cookbook
A Chef cookbook used to provision macOS
Stars: ✭ 183 (-6.15%)
Mutual labels:  xcode
Faimagecropper
Image Cropper like Instagram
Stars: ✭ 188 (-3.59%)
Mutual labels:  xcode
Podtobuild
An easy way to integrate CocoaPods into Bazel
Stars: ✭ 193 (-1.03%)
Mutual labels:  bazel

XCHammer

If all you've got is Xcode, your only tool is a 🔨

XCHammer generates Xcode projects from a Bazel Workspace.

  • [x] Complete Bazel Xcode IDE integration
    • [x] Bazel build and run via Xcode
    • [x] Xcode test runner integration
    • [x] Full LLDB support without DSYM generation
    • [x] Autocompletion and indexing support
    • [x] Renders Bazel's progress in Xcode's progress bar
    • [x] Optionally import index's via index-import with Run Scripts
    • [x] Customize Bazel invocations for Xcode
  • [x] Incremental project generation
  • [x] Focused Xcode projects
  • [x] Xcode build Bazel targets without Bazel
  • [x] Optionally Bazel build Xcode projects
    • [x] Define and compose Xcode projects in Skylark
    • [x] Builds reproducible and remote cacheable projects
  • [x] Automatically updates Xcode projects

Usage

Note: this README is intended to be a minimal, quick start guide to XCHammer. To learn more about XCHammer see Introducing XCHammer and The XCHammer FAQ. To learn more about Bazel, see Bazel for iOS developers. To learn about how Pinterest uses XCHammer see Introducing XCHammer and Pinterest Focused Xcode Projects

Bazel build Xcode projects

First, pull XCHammer into the WORKSPACE file:

Ideally, pull in a release optimized binary build to keep XCHammer's dependencies, Swift version, Xcode version, compiler flags, Bazel version, and build time outside of the main iOS/macOS application's WORKSPACE. To easily achieve this, GitHub CI creates a binary release artifact on receiving a new tag.

# WORKSPACE
# Recommended approach - the CI auto releases when you push a tag matching `v*`
# The release prefix is the _tested_ bazel version, and XCHammer is often
# forwards and backwards compatible
http_archive(
    name = "xchammer",
    urls = [ "https://github.com/pinterest/xchammer/releases/download/v3.4.1.0/xchammer.zip" ],
)

Next, create an xcode_project target including targets:

# BUILD.Bazel
load("@xchammer//:xcodeproject.bzl", "xcode_project")
xcode_project(
    name = "MyProject",
    targets = [ "//ios-app:ios-app" ],
    paths = [ "**" ],
)

Finally, build the project with Bazel

bazel build MyProject

CLI Usage ( Non Bazel built projects )

XCHammer also works as a standalone project generator. First build XCHammer and install to the path:

# Installs to `/usr/local/bin/`
make install

Then, generate using a XCHammerConfig.

xchammer generate <configPath>

Configuration Format

XCHammer is configured via a yaml representation of XCHammerConfig.

The configuration describes projects that should be generated.

# Generates a project containing the target ios-app
targets:
    - "//ios-app:ios-app"

projects:
    "MyProject":
        paths:
            - "**"

See XCHammerConfig.swift for detailed documentation of the format.

To learn about how Pinterest uses XCHammer with Bazel locally check out Pinterest Xcode Focused Projects.

Practical configuration examples

By default, XCHammer doesn't provide or enforce any build configuration defaults in Bazel or Xcode. It exposes APIs to make it possible to configure Bazel options Xcode dynamically, on a target level, on a project level, and per architecture.

When using the CLI the XCHammerConfig.swift is passed via an .yml file, and when using the xcode_project rule, the XCHammerConfig is passed into the rule.

Project level

The parameter bazel makes it possible to select a wrapper command for Bazel. In practice, this might be bazelisk or a wrapper script. In the case of XCHammer's own Xcode project, it's tools/bazelwrapper to handle make variable substitution at build time.

The configuration option, build_bazel_platform_options make it possible to configure architecture specific settings for each target. Checkout sample/UrlGet/BUILD.bazel passes a config per architecture in an iOS app.

Target Level

The configuration option, build_bazel_options makes it possible, to set extra options on bazel target.

Finally, the build_bazel_template makes it possible to run a script inside of Xcode before and after building. This also allows the user to pass in Bazel arguments at build time.

Checkout the BUILD file and samples for examples.

Build Time - debugging and static analysis

At the time of writing, there should be a way to build in "debug mode" in order for LLDB to work. One possibility is to set this as a default and override when releasing. By default, it's possible to pass variables to Bazel. For example, in XCHammer's own Xcode project, tools/XCHammerXcodeRunscript.sh it set's the compilation_mode based on Xcode's CONFIGURATION variable.

For the purpose of running static analysis, linters, and enabling other options, it's possible to pass in extra bazel arguments at build time. For example you might hinge running static analyzer on the analysis action in Xcode which sets RUN_CLANG_STATIC_ANALYZER. Bazel doesn't have a way to run linters or static analysis so it's totally up to the user how to run this.

Samples

Xcode progress bar integration

XCHammer provides a path to optionally integrate with Xcode's build system and progress bar.

  • Install support for Xcode's progress bar for Xcode 11
xchammer install_xcode_build_system
  • add --build_event_binary_file=/tmp/bep.bep to your .bazelrc
  • make sure Xcode's new build system is enabled

LLDB integration

Under Swift and clang compilers, the execution root is written into debug info in object files by default. XCHammer writes an lldbinit file to map this directory to the source root of source code, so that both breakpoints and sources work in Xcode.

To make outputs consistent and debuggable across machines, e.g. with remote caching, it's recommended to use debug info remapping. Debug info remapping is a technique that simply remaps absolute paths in debug info to a stable location. LLDB then is able to map these to the source directory, via a target.source-map. By default, these Bazel flags are not configured and require adding additional flags to the build. Generally, these flags should set in your .bazelrc for every build.

Clang provides debug info remapping via the -fdebug-prefix-map flag. For Objective-C, C, C++, debug info remapping is implemented at the crosstool level. Configure Bazel to pass these arguments by setting --copt="DEBUG_PREFIX_MAP_PWD=." or providing a custom crosstool. See setting up crosstool logic for more info.

Starting with Xcode 10.2, Swift provides debug info remapping via the -debug-prefix-map flag. rules_swift supports the ability to pass the debug remapping. Simply add --swiftcopt=-Xwrapped-swift=-debug-prefix-pwd-is-dot to remap debug info in Swift.

XCHammer will automatically write a compatible remapping in the .lldbinit. Set HAMMER_USE_DEBUG_INFO_REMAPPING=YES via an xcconfig. See XCHammer's BUILD file, for an example of this.

Generating a dSYM for development is not recommended due to the performance hit, and in practice is only required for Instruments.app.

Development

Please find more info about developing XCHammer in The XCHammer FAQ. Pull requests welcome 💖.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].