generated from mattrobmattrob/bazel-ios-swiftui-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1db0515
Showing
27 changed files
with
692 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## BUILD | ||
|
||
# https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env | ||
build --incompatible_strict_action_env | ||
|
||
# Disable the worker, which has sandboxing disabled by default, which can hide | ||
# issues with non-hermetic bugs. | ||
build --spawn_strategy=sandboxed,local | ||
build --worker_sandboxing=true | ||
|
||
build --incompatible_disallow_empty_glob | ||
|
||
build --features=swift.use_global_module_cache | ||
|
||
# Enable indexing while building. | ||
build --features swift.use_global_index_store | ||
build --features swift.index_while_building | ||
|
||
# Since there's no way to set the deployment version for swift_{binary,test}, | ||
# this forces all targets' minimum macOS to Github Actions macOS version. | ||
build --macos_minimum_os=12.6 | ||
|
||
## TEST | ||
|
||
# `bazel test` tries to build everything also by default, so skip that so the | ||
# *_library targets in examples/... aren't built (and fail since they are | ||
# platform specific). | ||
test --build_tests_only | ||
|
||
# Show detailed errors for test failures | ||
test --test_output=errors | ||
|
||
# Use llvm-cov instead of gcov (default). | ||
coverage --experimental_use_llvm_covmap | ||
|
||
## REMOTE CACHE | ||
|
||
# Do actions locally when it makes sense. | ||
build --modify_execution_info=^(BitcodeSymbolsCopy|BundleApp|BundleTreeApp|DsymDwarf|DsymLipo|GenerateAppleSymbolsFile|ObjcBinarySymbolStrip|CppLink|ObjcLink|ProcessAndSign|SignBinary|SwiftArchive|SwiftStdlibCopy)$=+no-remote,^(BundleResources|ImportedDynamicFrameworkProcessor)$=+no-remote-exec | ||
|
||
build:remote_cache --bes_results_url=https://app.buildbuddy.io/invocation/ | ||
build:remote_cache --bes_backend=grpcs://remote.buildbuddy.io | ||
build:remote_cache --remote_cache=grpcs://remote.buildbuddy.io | ||
# https://bazel.build/reference/command-line-reference#flag--remote_download_toplevel | ||
build:remote_cache --remote_download_toplevel | ||
# https://bazel.build/reference/command-line-reference#flag--remote_timeout | ||
build:remote_cache --remote_timeout=3600 | ||
# https://bazel.build/reference/command-line-reference#flag--experimental_remote_cache_compression | ||
build:remote_cache --experimental_remote_cache_compression | ||
|
||
## LOCAL CONFIG | ||
|
||
# Load a user.bazelrc | ||
try-import %workspace%/user.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
# One active job per PR, cancel older ones on push | ||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
name: Build and Test | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Select Xcode | ||
run: .github/workflows/xcode_select.sh | ||
- name: Lint | ||
run: bazelisk run :lint && git diff --exit-code | ||
- name: Build and Test | ||
run: | | ||
# Build the app | ||
bazelisk build -- //app | ||
# Run the tests | ||
bazelisk test --local_test_jobs=1 -- //... | ||
- name: Generate Xcode Project | ||
run: | | ||
# Generate Xcode project | ||
bazelisk run -- //:xcodeproj | ||
- uses: actions/upload-artifact@v2 | ||
if: failure() | ||
with: | ||
name: bazel-testlogs | ||
path: bazel-testlogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -e | ||
echo "Selecting Xcode for environment" | ||
|
||
printenv | ||
|
||
sudo xcode-select -p | ||
sudo xcode-select -s /Applications/Xcode_14.2.app | ||
|
||
echo "Generating bazelrc" | ||
|
||
# Enable remote cache for all Github Action builds | ||
echo "build --config=remote_cache" > user.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Bazel | ||
|
||
/bazel-* | ||
/user.bazelrc | ||
|
||
# macOS | ||
|
||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
/*.xcodeproj | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) | ||
*.xcscmblueprint | ||
*.xccheckout | ||
|
||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) | ||
build/ | ||
DerivedData/ | ||
*.moved-aside | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
|
||
## App packaging | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
# Package.pins | ||
# Package.resolved | ||
# *.xcodeproj | ||
# | ||
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata | ||
# hence it is not needed unless you have added a package configuration file to your project | ||
# .swiftpm | ||
|
||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ | ||
# | ||
# Add this line if you want to avoid checking in source code from the Xcode workspace | ||
# *.xcworkspace | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build/ | ||
|
||
# Accio dependency management | ||
Dependencies/ | ||
.accio/ | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. | ||
# Instead, use fastlane to re-generate the screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output | ||
|
||
# Code Injection | ||
# | ||
# After new code Injection tools there's a generated folder /iOSInjectionProject | ||
# https://github.com/johnno1962/injectionforxcode | ||
|
||
iOSInjectionProject/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
load( | ||
"@rules_xcodeproj//xcodeproj:defs.bzl", | ||
"top_level_target", | ||
"xcodeproj", | ||
) | ||
|
||
# Xcode | ||
|
||
xcodeproj( | ||
name = "xcodeproj", | ||
project_name = "App", | ||
top_level_targets = [ | ||
top_level_target( | ||
"//app", | ||
target_environments = ["simulator"], | ||
), | ||
top_level_target( | ||
"//modules/API:APITests", | ||
target_environments = ["simulator"], | ||
), | ||
top_level_target( | ||
"//modules/Models:ModelsTests", | ||
target_environments = ["simulator"], | ||
), | ||
], | ||
) | ||
|
||
# tools | ||
|
||
genrule( | ||
name = "lint", | ||
srcs = [], | ||
outs = ["lint.sh"], | ||
cmd = """ | ||
echo "set -e" > "$@" | ||
echo "./$(location @buildifier_prebuilt//:buildifier) -lint fix -mode fix -r \\$$BUILD_WORKSPACE_DIRECTORY" >> "$@" | ||
echo "./$(location @SwiftLint//:swiftlint) --fix \\$$BUILD_WORKSPACE_DIRECTORY" >> "$@" | ||
""", | ||
executable = True, | ||
tools = [ | ||
"@SwiftLint//:swiftlint", | ||
"@buildifier_prebuilt//:buildifier", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Matt Robinson | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SwiftUI iOS App with Bazel | ||
|
||
This is an iOS application written in SwiftUI and built via Bazel. This is a starting place similar to creating a new project in Xcode and choosing SwiftUI as the starting place. | ||
|
||
## Getting Started | ||
|
||
Install Bazelisk via `brew install bazelisk`. `bazel` & `bazelisk` will now use the `.bazelversion` file to download and run the chosen Bazel version. | ||
|
||
### Generate/Open Project | ||
|
||
```bash | ||
$ bazel run :xcodeproj | ||
$ open App.xcodeproj | ||
``` | ||
|
||
### Build Application (CLI) | ||
|
||
```bash | ||
$ bazel build //app | ||
``` | ||
|
||
### Run All Tests (CLI) | ||
|
||
```bash | ||
$ bazel test $(bazel query 'kind(ios_unit_test,//...)') | ||
``` | ||
|
||
## Underlying Tools | ||
|
||
- [`rules_apple`](https://github.com/bazelbuild/rules_apple) | ||
- [`rules_swift`](https://github.com/bazelbuild/rules_swift) | ||
- [`rules_xcodeproj`](https://github.com/buildbuddy-io/rules_xcodeproj) | ||
|
||
## Making It Your Own | ||
|
||
`tools/shared.bzl` contains a handful of definitions to define the name of the application, bundle identifier, and similar things. Update these values to change the application's name. |
Oops, something went wrong.