Skip to content

Commit

Permalink
iOS Bazel 6 (#261)
Browse files Browse the repository at this point in the history
* xcodeproj generation sorta working

* preprocessor macro working for resources in and out of bazel?

* test host not needed for unit test resources

* fixed bundle name

* better folder structure

* swiftui building

* viewinspector dependency resolved, tests need reference assets

* reference assets build working, demo app showing on screen

* add pending transaction ios plugin

* add base beacon plugin

* swiftui beacon plugin

* remove xcode project

* ignore xcodeproj

* generate resource Bundle.module shims

* check path ios

* swiftui check-path

* common-expressions ios

* common-types ios

* computed-properties ios

* expression plugin ios

* external action ios

* swiftui external action

* metrics plugin swiftui

* fix bundle access

* pubsub ios

* stage-revert-data ios

* types-provider ios

* move print logger ios to console-logger package

* test utilities core

* ios test-utils that rely on XCTest

* viewinspector tests running for ref assets

* update xcodeproj generation

* update demo with more plugins

* move transition plugin for ios

* plugins all moved out of ios directory

* pull in latest demo app files from main

* uitests run but demo app need flow finished alert

* remove old packages from ios

* wip using resource bundles from bazel targets not working

* Define process.env in native bundles

* Update pluginName for SwiftUI plugin

* use bazel target for beacon resources

* use bazel target for core resources

* use bazel target for check-path resources

* use bazel target for make-flow

* use bazel target for make-flow

* bazel targets for common types/expressions

* use bazel targets for ios resources

* remove old resource

* UITests passing

* remove old cocoapods related project files

* remove commented out tags

* update podspec and add Package.swift

* add bazel source targets, zip sources and resources into proper locations, pod lint passes

* port async wrapped function again, since this was branched prior to sync

* zip works as a pod

---------

Co-authored-by: Adam Dierkens <Adam_Dierkens@intuit.com>
  • Loading branch information
hborawski and adierkens authored Dec 11, 2023
1 parent ec7989b commit 32f20d6
Show file tree
Hide file tree
Showing 300 changed files with 4,120 additions and 4,125 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ CoverageData/
bep.json
xcui.json

#SPM
.build
.swiftpm
ios/Player.xcodeproj

# Bundles used by cocoapods for development
ios/*/*/Resources/**/*.js

# File used in CI to pass build number between iOS and release stage
.ios-build-number

.bazelrc.local
.bazelrc.local
173 changes: 143 additions & 30 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# load("@rules_player//cocoapods:cocoapod.bzl", "assemble_pod", "pod_push")
# load("@rules_player//internal:stamp.bzl", "stamp")
# load("//:generated.bzl", "PlayerUI", "PlayerUI_Demo", "ui_tests", "unit_tests")
load("//tools/ios:util.bzl", "assemble_pod")

load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand Down Expand Up @@ -97,36 +98,99 @@ js_library(
# },
# )

# assemble_pod(
# name = "PlayerUI_Pod",
# srcs = glob([
# "ios/**/*.swift",
# "LICENSE",
# ]),
# data = {
# # Core
# "//core/player:Player_Bundles_bundle_prod": "ios/packages/core/Resources/",
# "//plugins/partial-match-fingerprint/core:PartialMatchFingerprintPlugin_Bundles_bundle_prod": "ios/packages/core/Resources/",
# "//core/partial-match-registry:Registry_Bundles_bundle_prod": "ios/packages/core/Resources/",

# # Packages
# "//core/make-flow:MakeFlow_Bundles_bundle_prod": "ios/packages/test-utils/Resources/",
# "//plugins/reference-assets/core:ReferenceAssetsPlugin_Bundles_bundle_prod": "ios/packages/reference-assets/Resources/js/",
# # Plugins
# "//plugins/beacon/core:BeaconPlugin_Bundles_bundle_prod": "ios/plugins/BaseBeaconPlugin/Resources/",
# "//plugins/check-path/core:CheckPathPlugin_Bundles_bundle_prod": "ios/plugins/CheckPathPlugin/Resources/",
# "//plugins/common-types/core:CommonTypesPlugin_Bundles_bundle_prod": "ios/plugins/CommonTypesPlugin/Resources/",
# "//plugins/common-expressions/core:CommonExpressionsPlugin_Bundles_bundle_prod": "ios/plugins/CommonExpressionsPlugin/Resources/",
# "//plugins/computed-properties/core:ComputedPropertiesPlugin_Bundles_bundle_prod": "ios/plugins/ComputedPropertiesPlugin/Resources/",
# "//plugins/expression/core:ExpressionPlugin_Bundles_bundle_prod": "ios/plugins/ExpressionPlugin/Resources/",
# "//plugins/external-action/core:ExternalActionPlugin_Bundles_bundle_prod": "ios/plugins/ExternalActionPlugin/Resources/",
# "//plugins/metrics/core:MetricsPlugin_Bundles_bundle_prod": "ios/plugins/MetricsPlugin/Resources/",
# "//plugins/pubsub/core:PubSubPlugin_Bundles_bundle_prod": "ios/plugins/PubSubPlugin/Resources/",
# "//plugins/stage-revert-data/core:StageRevertDataPlugin_Bundles_bundle_prod": "ios/plugins/StageRevertDataPlugin/Resources/",
# "//plugins/types-provider/core:TypesProviderPlugin_Bundles_bundle_prod": "ios/plugins/TypesProviderPlugin/Resources/",
# },
# podspec = ":PlayerUI_Podspec",
# )
exports_files([
"PlayerUI.podspec"
])

assemble_pod(
name = "PlayerUI_Pod",
srcs = glob([
"LICENSE",
"Package.swift",
]),
data = {
# Core
"//ios/core:PlayerUI_Sources": "ios/core/",
"//core/player:player_native_bundle": "ios/core/Resources/",
"//plugins/partial-match-fingerprint/core:core_native_bundle": "ios/core/Resources/",
"//core/partial-match-registry:partial-match-registry_native_bundle": "ios/core/Resources/",

# SwiftUI
"//ios/swiftui:PlayerUISwiftUI_Sources": "ios/swiftui/",

# Logger
"//ios/logger:PlayerUILogger_Sources": "ios/logger/",

# Test Utilities
"//ios/test-utils-core:PlayerUITestUtilitiesCore_Sources": "ios/test-utils-core/",
"//ios/test-utils:PlayerUITestUtilities_Sources": "ios/test-utils/",
"//core/make-flow:make-flow_native_bundle": "ios/test-utils-core/Resources/",

# Plugins #

# Beacon
"//plugins/beacon/ios:PlayerUIBaseBeaconPlugin_Sources": "plugins/beacon/ios/",
"//plugins/beacon/swiftui:PlayerUIBeaconPlugin_Sources": "plugins/beacon/swiftui/",
"//plugins/beacon/core:core_native_bundle": "plugins/beacon/ios/Resources/",

# Check Path
"//plugins/check-path/ios:PlayerUICheckPathPlugin_Sources": "plugins/check-path/ios/",
"//plugins/check-path/swiftui:PlayerUISwiftUICheckPathPlugin_Sources": "plugins/check-path/swiftui/",
"//plugins/check-path/core:core_native_bundle": "plugins/check-path/ios/Resources/",

# Common Expressions
"//plugins/common-expressions/ios:PlayerUICommonExpressionsPlugin_Sources": "plugins/common-expressions/ios/",
"//plugins/common-expressions/core:core_native_bundle": "plugins/common-expressions/ios/Resources/",

# Common Types
"//plugins/common-types/ios:PlayerUICommonTypesPlugin_Sources": "plugins/common-types/ios/",
"//plugins/common-types/core:core_native_bundle": "plugins/common-types/ios/Resources/",

# Computed Properties
"//plugins/computed-properties/ios:PlayerUIComputedPropertiesPlugin_Sources": "plugins/computed-properties/ios/",
"//plugins/computed-properties/core:core_native_bundle": "plugins/computed-properties/ios/Resources/",

# Console Logger (PrintLoggerPlugin)
"//plugins/console-logger/ios:PlayerUIPrintLoggerPlugin_Sources": "plugins/console-logger/ios/",

# Expression
"//plugins/expression/ios:PlayerUIExpressionPlugin_Sources": "plugins/expression/ios/",
"//plugins/expression/core:core_native_bundle": "plugins/expression/ios/Resources/",

# External Action
"//plugins/external-action/ios:PlayerUIExternalActionPlugin_Sources": "plugins/external-action/ios/",
"//plugins/external-action/swiftui:PlayerUIExternalActionViewModifierPlugin_Sources": "plugins/external-action/swiftui/",
"//plugins/external-action/core:core_native_bundle": "plugins/external-action/ios/Resources/",

# Metrics
"//plugins/metrics/swiftui:PlayerUIMetricsPlugin_Sources": "plugins/metrics/swiftui/",
"//plugins/metrics/core:core_native_bundle": "plugins/metrics/swiftui/Resources/",

# Pending Transaction
"//plugins/pending-transaction/swiftui:PlayerUISwiftUIPendingTransactionPlugin_Sources": "plugins/pending-transaction/swiftui/",

# PubSub
"//plugins/pubsub/ios:PlayerUIPubSubPlugin_Sources": "plugins/pubsub/ios/",
"//plugins/pubsub/core:core_native_bundle": "plugins/pubsub/ios/Resources/",

# Reference Assets
"//plugins/reference-assets/swiftui:PlayerUIReferenceAssets_Sources": "plugins/reference-assets/swiftui/",
"//plugins/reference-assets/swiftui/Resources:PlayerUIReferenceAssets_Resources": "plugins/reference-assets/swiftui/Resources/",
"//plugins/reference-assets/core:core_native_bundle": "plugins/reference-assets/swiftui/Resources/js/",

# Stage Revert Data
"//plugins/stage-revert-data/ios:PlayerUIStageRevertDataPlugin_Sources": "plugins/stage-revert-data/ios/",
"//plugins/stage-revert-data/core:core_native_bundle": "plugins/stage-revert-data/ios/Resources/",

# Transition
"//plugins/transition/swiftui:PlayerUITransitionPlugin_Sources": "plugins/transition/swiftui",

# Types Provider
"//plugins/types-provider/ios:PlayerUITypesProviderPlugin_Sources": "plugins/types-provider/ios/",
"//plugins/types-provider/core:core_native_bundle": "plugins/types-provider/ios/Resources/",
},
podspec = ":PlayerUI.podspec",
)

# # Push podspec to specs repo
# # tag must exist in github first
Expand All @@ -141,3 +205,52 @@ js_library(
# "--skip-tests",
# ],
# )

load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")

# Ignore the `.build` folder that is created by running Swift package manager
# commands. The Swift Gazelle plugin executes some Swift package manager
# commands to resolve external dependencies. This results in a `.build` file
# being created.
# NOTE: Swift package manager is not used to build any of the external packages.
# The `.build` directory should be ignored. Be sure to configure your source
# control to ignore it (i.e., add it to your `.gitignore`).
# gazelle:exclude .build

# This declaration builds a Gazelle binary that incorporates all of the Gazelle
# plugins for the languages that you use in your workspace. In this example, we
# are only listing the Gazelle plugin for Swift from rules_swift_package_manager.
gazelle_binary(
name = "gazelle_bin",
languages = [
"@rules_swift_package_manager//gazelle",
],
)

# This macro defines two targets: `swift_update_pkgs` and
# `swift_update_pkgs_to_latest`.
#
# The `swift_update_pkgs` target should be run whenever the list of external
# dependencies is updated in the `Package.swift`. Running this target will
# populate the `swift_deps.bzl` with `swift_package` declarations for all of
# the direct and transitive Swift packages that your project uses.
#
# The `swift_update_pkgs_to_latest` target should be run when you want to
# update your Swift dependencies to their latest eligible version.
swift_update_packages(
name = "swift_update_pkgs",
gazelle = ":gazelle_bin",
swift_deps = "swift_deps.bzl",
swift_deps_index = "swift_deps_index.json",
generate_swift_deps_for_workspace = True,
update_bzlmod_stanzas = False,
package_manifest = "./xcode/Package.swift"
)

# This target updates the Bazel build files for your project. Run this target
# whenever you add or remove source files from your project.
gazelle(
name = "update_build_files",
gazelle = ":gazelle_bin",
)
30 changes: 29 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bazel_dep(name = "rules_player")

git_override(
remote = "https://github.com/player-ui/rules_player.git",
commit = "d9c8d7c1802916dc6e4619b5da2ac0cab590944a",
commit = "a1626024afabb38b9aca9981cc0e76b704d4fd77",
module_name = "rules_player",
)
# local_path_override(module_name = "rules_player", path = "../rules_player")
Expand All @@ -21,6 +21,34 @@ node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
node.toolchain(node_version = "18.18.0")
#################################


# iOS

bazel_dep(name = "rules_swift", version = "1.13.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_apple", version = "3.1.1", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_ios", version = "3.1.4", repo_name = "build_bazel_rules_ios")
bazel_dep(name = "rules_xcodeproj", version = "1.13.0")

bazel_dep(name = "gazelle", version = "0.34.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_swift_package_manager", version = "0.22.0")

# swift_deps START
swift_deps = use_extension(
"@rules_swift_package_manager//:extensions.bzl",
"swift_deps",
)
swift_deps.from_file(
deps_index = "//:swift_deps_index.json",
)

use_repo(
swift_deps,
"swiftpkg_swift_hooks",
"swiftpkg_viewinspector",
"swiftpkg_eyes_xcui_swift_package"
)

# end iOS
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")

npm.npm_translate_lock(
Expand Down
Loading

0 comments on commit 32f20d6

Please sign in to comment.