Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@build_bazel_rules_android//android:rules.bzl", "aar_import")
load("@build_bazel_rules_apple//apple:apple.bzl", "apple_static_framework_import")
load("@io_bazel_rules_kotlin//kotlin/internal:toolchains.bzl", "define_kt_toolchain")
load("@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:xcodeproj.bzl", "xcodeproj")
load("//bazel:framework_imports_extractor.bzl", "framework_imports_extractor")

licenses(["notice"]) # Apache 2
Expand Down Expand Up @@ -102,3 +103,19 @@ genrule(
""",
tools = ["@kotlin_formatter//file"],
)

xcodeproj(
name = "xcodeproj",
archived_bundles_allowed = True,
build_mode = "bazel",
project_name = "Envoy",
tags = ["manual"],
targets = [
# TODO(jpsim): Fix Objective-C app support
# "//examples/objective-c/hello_world:app",
"//examples/swift/async_await:app",
"//examples/swift/hello_world:app",
"//test/swift/apps/baseline:app",
"//test/swift/apps/experimental:app",
],
)
3 changes: 3 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ android_configure(

load("@local_config_android//:android_configure.bzl", "android_workspace")
android_workspace()

load("@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:repositories.bzl", "xcodeproj_rules_dependencies")
xcodeproj_rules_dependencies()
14 changes: 12 additions & 2 deletions bazel/envoy_mobile_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ def swift_repos():
url = "https://github.com/bazelbuild/rules_apple/archive/2d1fa9ea5f3544fed41d50c28c8508af035bc0a0.tar.gz",
)

# TODO(jpsim): Update to the next release which includes https://github.com/bazelbuild/rules_swift/pull/818
http_archive(
name = "build_bazel_rules_swift",
sha256 = "a2fd565e527f83fb3f9eb07eb9737240e668c9242d3bc318712efa54a7deda97",
url = "https://github.com/bazelbuild/rules_swift/releases/download/0.27.0/rules_swift.0.27.0.tar.gz",
sha256 = "b5966b422113866398035cd970feffb4ab6c081fa1c96c02d942b17e5b8429c4",
strip_prefix = "rules_swift-8d4b096b90e47095755e47c27e749ae9b9f83e81",
url = "https://github.com/bazelbuild/rules_swift/archive/8d4b096b90e47095755e47c27e749ae9b9f83e81.tar.gz",
)

http_archive(
Expand All @@ -98,6 +100,14 @@ def swift_repos():
url = "https://github.com/realm/SwiftLint/releases/download/0.47.1/portable_swiftlint.zip",
)

# TODO(jpsim): Update to the next release which includes https://github.com/buildbuddy-io/rules_xcodeproj/pull/407
http_archive(
name = "com_github_buildbuddy_io_rules_xcodeproj",
sha256 = "af9f6ebbf4d7c83cf35d7ced0b9d13fd6e91e9da5e4ceaf06614ed8caeab45aa",
strip_prefix = "rules_xcodeproj-96f59d785e8ec226b74af0586f856770b5e7e60c",
url = "https://github.com/buildbuddy-io/rules_xcodeproj/archive/96f59d785e8ec226b74af0586f856770b5e7e60c.tar.gz",
)

def kotlin_repos():
http_archive(
name = "rules_java",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions docs/root/development/debugging/ios_local.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.. _debugging_ios_instructions:

Build & run the example iOS apps
=======================================

*Note: This document assumes that you have installed the
:ref:`iOS build requirements <ios_requirements>`_.*

The fastest way to build and run the sample iOS apps is to run the
following command::

./bazelw run //examples/swift/hello_world:app

This will build and run the Hello World iOS app in a new iOS Simulator.

.. _using_xcode:

Using the Xcode GUI
-------------------

Envoy Mobile makes use of the
`rules_xcodeproj <https://github.com/buildbuddy-io/rules_xcodeproj>`_
project to add support for many of Xcode's development, debugging and
profiling features to Envoy Mobile.

To start, run ``./bazelw run //:xcodeproj`` to generate an Xcode project
and ``xed .`` to open it in Xcode (or double-click ``Envoy.xcodeproj``
in Finder).

In Xcode's scheme selector, pick the app target you want to build (e.g.
``__examples_swift_hello_world_app``), pick a Simulator to run it on,
then hit cmd-R to build and run.

From there, most Xcode features should just work for all transitively
compiled source files in C/C++/Objective-C/Objective-C++/Swift:

* Auto-complete
* Syntax highlighting
* Go to definition
* Breakpoints
* LLDB console
* Thread navigator
* Symbols
* Metrics like CPU/memory/networking/energy
* Profiling with Instruments

|xcode_breakpoint| |instruments|

.. |xcode_breakpoint| image:: images/xcode_breakpoint.jpg
:width: 45%

.. |instruments| image:: images/instruments.jpg
:width: 45%

Running on a real iPhone
------------------------

Although building and running on a physical device is
`not yet officially supported <https://github.com/buildbuddy-io/rules_xcodeproj/issues/285>`_
by rules_xcodeproj, following these steps may work:

1. Add ``build --ios_multi_cpus=arm64`` to ``.bazelrc``.
2. Add a ``.mobileprovision`` provisioning profile capable of signing
the app you want to run next to its ``BUILD`` file.
E.g. ``examples/swift/hello_world/dev.mobileprovision``
3. Set the provisioning profile on the ``ios_application`` you want to
run. E.g. ``provisioning_profile = "dev.mobileprovision",``
4. Remove all apps without a provisioning profile from the ``xcodeproj``
configuration in Envoy Mobile's root ``BUILD`` file.
5. Follow the same steps as defined in the
:ref:`Using the Xcode GUI <using_xcode>`_ section above, but
targeting your device instead of a simulator.

*Note: You may need to clean from Xcode with cmd-shift-k between device
runs.*
1 change: 1 addition & 0 deletions docs/root/development/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ developing Envoy Mobile.
testing/testing
tools/tools
debugging/android_local
debugging/ios_local
2 changes: 2 additions & 0 deletions docs/root/start/building/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ For local builds, set ``ANDROID_HOME`` and ``ANDROID_NDK_HOME`` to point to the

See `ci/mac_ci_setup.sh` for the specific NDK version used during builds.

.. _ios_requirements:

----------------
iOS requirements
----------------
Expand Down
5 changes: 2 additions & 3 deletions examples/objective-c/hello_world/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ios_application(
families = ["iphone"],
infoplists = ["Info.plist"],
minimum_os_version = MINIMUM_IOS_VERSION,
deps = [
"appmain",
],
visibility = ["//visibility:public"],
deps = ["appmain"],
)
4 changes: 2 additions & 2 deletions examples/swift/async_await/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ licenses(["notice"]) # Apache 2
swift_library(
name = "appmain",
srcs = glob(["*.swift"]),
linkopts = ["-lNetwork"],
deps = ["//:envoy_mobile_ios"],
deps = ["//library/swift:ios_lib"],
)

ios_application(
Expand All @@ -16,5 +15,6 @@ ios_application(
families = ["iphone"],
infoplists = ["Info.plist"],
minimum_os_version = "15.0",
visibility = ["//visibility:public"],
deps = ["appmain"],
)
3 changes: 2 additions & 1 deletion examples/swift/hello_world/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ licenses(["notice"]) # Apache 2
swift_library(
name = "appmain",
srcs = glob(["*.swift"]),
deps = ["//:envoy_mobile_ios"],
deps = ["//library/swift:ios_lib"],
)

ios_application(
Expand All @@ -16,5 +16,6 @@ ios_application(
families = ["iphone"],
infoplists = ["Info.plist"],
minimum_os_version = MINIMUM_IOS_VERSION,
visibility = ["//visibility:public"],
deps = ["appmain"],
)
3 changes: 2 additions & 1 deletion test/swift/apps/baseline/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ licenses(["notice"]) # Apache 2
swift_library(
name = "appmain",
srcs = glob(["*.swift"]),
deps = ["//:envoy_mobile_ios"],
deps = ["//library/swift:ios_lib"],
)

ios_application(
Expand All @@ -16,5 +16,6 @@ ios_application(
families = ["iphone"],
infoplists = ["Info.plist"],
minimum_os_version = MINIMUM_IOS_VERSION,
visibility = ["//visibility:public"],
deps = ["appmain"],
)
3 changes: 2 additions & 1 deletion test/swift/apps/experimental/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ licenses(["notice"]) # Apache 2
swift_library(
name = "appmain",
srcs = glob(["*.swift"]),
deps = ["//:envoy_mobile_ios"],
deps = ["//library/swift:ios_lib"],
)

ios_application(
Expand All @@ -16,5 +16,6 @@ ios_application(
families = ["iphone"],
infoplists = ["Info.plist"],
minimum_os_version = MINIMUM_IOS_VERSION,
visibility = ["//visibility:public"],
deps = ["appmain"],
)
2 changes: 1 addition & 1 deletion tools/check_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TARGET_PATH="$2"
# TODO(mattklein123): WORKSPACE is excluded due to warning about @bazel_tools reference. Fix here
# or in the upstream checker.
ENVOY_BAZEL_PREFIX=@envoy envoy/tools/code_format/check_format.py \
--add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./dist/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl ./bazel/envoy_mobile_repositories.bzl \
--add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./Envoy.xcodeproj/ ./dist/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl ./bazel/envoy_mobile_repositories.bzl \
--skip_envoy_build_rule_check "$ENVOY_FORMAT_ACTION" $TARGET_PATH \
--namespace_check_excluded_paths ./envoy ./examples/ ./library/java/ ./library/kotlin ./library/objective-c ./test/java ./test/java ./test/objective-c ./test/swift ./experimental/swift \
--build_fixer_check_excluded_paths ./envoy ./BUILD ./dist ./examples ./library/java ./library/kotlin ./library/objective-c ./library/swift ./library/common/extensions ./test/java ./test/kotlin ./test/objective-c ./test/swift ./experimental/swift