Skip to content

Commit 1df27c6

Browse files
authored
fix: add crashlytics example (#435)
- Treat `maccatalyst` like `ios` instead of `macos`. - Add `crashlytics` example to `firebase_example`. - Ensure that `defines` values that contain spaces are escaped properly. If not escaped, each space-separated part becomes its own define value. - Do not trust the package manifests! Check that directories exist before attempting to list their contents. - Include `.mm` files (Objective-C++) as valid sources. Closes #425.
1 parent cd81615 commit 1df27c6

File tree

51 files changed

+1180
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1180
-118
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# To update these lines, execute
22
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
3-
build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/third_party,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/tca_example,examples/tca_example/SwiftUICaseStudies,examples/tca_example/SwiftUICaseStudiesTests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
4-
query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/third_party,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/tca_example,examples/tca_example/SwiftUICaseStudies,examples/tca_example/SwiftUICaseStudiesTests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
3+
build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/third_party,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/tca_example,examples/tca_example/SwiftUICaseStudies,examples/tca_example/SwiftUICaseStudiesTests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
4+
query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/third_party,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/tca_example,examples/tca_example/SwiftUICaseStudies,examples/tca_example/SwiftUICaseStudiesTests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
55

66
# Import Shared settings
77
import %workspace%/shared.bazelrc

.github/actions/set_up_macos/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ inputs:
77
required: true
88
xcode_version:
99
description: The version of Xcode to use.
10-
default: '14.0.1'
10+
default: '14.3.1'
1111

1212
runs:
1313
using: composite

config_settings/spm/platform/platforms.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ def _label(name):
6262
Returns:
6363
The condition label as a `string`.
6464
"""
65+
66+
# There is currently no support Mac Catalyst in Bazel. These are Mac apps
67+
# that use iOS frameworks. Treat it like iOS for now.
6568
if name == "maccatalyst":
66-
name = "macos"
69+
name = "ios"
6770
return "@rules_swift_package_manager//config_settings/spm/platform:{}".format(name)
6871

6972
platforms = struct(

examples/firebase_example/.bazelrc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import %workspace%/../../ci.bazelrc
77
# Try to import a local.rc file; typically, written by CI
88
try-import %workspace%/../../local.bazelrc
99

10-
# The CNIOBoringSSL uses C++14 features like 'enable_if_t' macro support.
11-
# For more details on how to enable this in Bazel:
10+
# Per https://github.com/firebase/firebase-ios-sdk/blob/master/Package.swift#L1322-L1323
11+
# NOTE: Puposefully not specifying --copt='-std=c99' as it is applied to
12+
# objc_library targets that contain Objective-C++ files. Tried using
13+
# --per_file_copt to exclude .mm files, but did not have success.
1214
# https://stackoverflow.com/questions/40260242/how-to-set-c-standard-version-when-build-with-bazel/43388168#43388168
13-
build --cxxopt='-std=c++14'
15+
build --cxxopt='-std=gnu++14'
1416

1517
# Firebase SPM support requires `-ObjC` linker option.
1618
# https://github.com/firebase/firebase-ios-sdk/blob/master/SwiftPackageManager.md#requirements

examples/firebase_example/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ swift_deps.from_file(
4343
use_repo(
4444
swift_deps,
4545
"swiftpkg_firebase_ios_sdk",
46+
"swiftpkg_reachability.swift",
4647
)
4748
# swift_deps END

examples/firebase_example/Package.resolved

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
11
{
22
"pins" : [
33
{
4-
"identity" : "abseil-cpp-swiftpm",
4+
"identity" : "abseil-cpp-binary",
55
"kind" : "remoteSourceControl",
6-
"location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git",
6+
"location" : "https://github.com/google/abseil-cpp-binary.git",
77
"state" : {
8-
"revision" : "583de9bd60f66b40e78d08599cc92036c2e7e4e1",
9-
"version" : "0.20220203.2"
10-
}
11-
},
12-
{
13-
"identity" : "boringssl-swiftpm",
14-
"kind" : "remoteSourceControl",
15-
"location" : "https://github.com/firebase/boringssl-SwiftPM.git",
16-
"state" : {
17-
"revision" : "dd3eda2b05a3f459fc3073695ad1b28659066eab",
18-
"version" : "0.9.1"
8+
"revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c",
9+
"version" : "1.2022062300.0"
1910
}
2011
},
2112
{
2213
"identity" : "firebase-ios-sdk",
2314
"kind" : "remoteSourceControl",
2415
"location" : "https://github.com/firebase/firebase-ios-sdk",
2516
"state" : {
26-
"revision" : "f567ed9a2b30e29159df258049a9c662c517688e",
27-
"version" : "10.5.0"
17+
"revision" : "e700a8f40c87c31cab7984875fcc1225d96b25bf",
18+
"version" : "10.11.0"
2819
}
2920
},
3021
{
3122
"identity" : "googleappmeasurement",
3223
"kind" : "remoteSourceControl",
3324
"location" : "https://github.com/google/GoogleAppMeasurement.git",
3425
"state" : {
35-
"revision" : "9a09ece724128e8d1e14c5133b87c0e236844ac0",
36-
"version" : "10.4.0"
26+
"revision" : "62e3a0c09a75e2637f5300d46f05a59313f1c286",
27+
"version" : "10.11.0"
3728
}
3829
},
3930
{
@@ -55,21 +46,21 @@
5546
}
5647
},
5748
{
58-
"identity" : "grpc-ios",
49+
"identity" : "grpc-binary",
5950
"kind" : "remoteSourceControl",
60-
"location" : "https://github.com/grpc/grpc-ios.git",
51+
"location" : "https://github.com/google/grpc-binary.git",
6152
"state" : {
62-
"revision" : "8440b914756e0d26d4f4d054a1c1581daedfc5b6",
63-
"version" : "1.44.3-grpc"
53+
"revision" : "f1b366129d1125be7db83247e003fc333104b569",
54+
"version" : "1.50.2"
6455
}
6556
},
6657
{
6758
"identity" : "gtm-session-fetcher",
6859
"kind" : "remoteSourceControl",
6960
"location" : "https://github.com/google/gtm-session-fetcher.git",
7061
"state" : {
71-
"revision" : "96d7cc73a71ce950723aa3c50ce4fb275ae180b8",
72-
"version" : "3.1.0"
62+
"revision" : "5ccda3981422a84186387dbb763ba739178b529c",
63+
"version" : "2.3.0"
7364
}
7465
},
7566
{
@@ -99,6 +90,15 @@
9990
"version" : "2.1.1"
10091
}
10192
},
93+
{
94+
"identity" : "reachability.swift",
95+
"kind" : "remoteSourceControl",
96+
"location" : "https://github.com/ashleymills/Reachability.swift.git",
97+
"state" : {
98+
"revision" : "c01bbdf2d633cf049ae1ed1a68a2020a8bda32e2",
99+
"version" : "5.1.0"
100+
}
101+
},
102102
{
103103
"identity" : "swift-protobuf",
104104
"kind" : "remoteSourceControl",

examples/firebase_example/Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ let package = Package(
66
name: "firebase_example",
77
dependencies: [
88
.package(url: "https://github.com/firebase/firebase-ios-sdk", .upToNextMajor(from: "10.0.0")),
9+
// Used by crashlytics example
10+
.package(url: "https://github.com/ashleymills/Reachability.swift.git", .upToNextMajor(from: "5.1.0")),
911
]
1012
)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2+
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
3+
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application")
4+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
5+
6+
# Exclude this entire directory from having anything generated by Gazelle. That
7+
# way the test cases won't be fixed by `bazel run //:update_build_files` when
8+
# run in this repository.
9+
# gazelle:exclude **
10+
11+
swift_library(
12+
name = "CrashlyticsSwiftUIExample",
13+
srcs = [
14+
"Shared/ContentView.swift",
15+
"Shared/CrashlyticsSwiftUIExampleApp.swift",
16+
"Shared/ReachabililtyHelper.swift",
17+
],
18+
module_name = "CrashlyticsSwiftUIExample",
19+
tags = ["manual"],
20+
visibility = ["//visibility:public"],
21+
deps = [
22+
"@swiftpkg_firebase_ios_sdk//:Crashlytics_FirebaseCrashlytics",
23+
"@swiftpkg_reachability.swift//:Sources_Reachability",
24+
],
25+
)
26+
27+
ios_application(
28+
name = "iosapp",
29+
bundle_id = "com.google.firebase.quickstart.CrashlyticsExample",
30+
families = [
31+
"iphone",
32+
"ipad",
33+
],
34+
infoplists = [":iOS/Info.plist"],
35+
minimum_os_version = "15.0",
36+
resources = glob(
37+
["CrashlyticsSwiftUIExample/Assets.xcassets/**"],
38+
exclude = ["CrashlyticsSwiftUIExample/Assets.xcassets/AppIconTopShelfImage.brandassets/**"],
39+
),
40+
deps = [":CrashlyticsSwiftUIExample"],
41+
)
42+
43+
macos_application(
44+
name = "macosapp",
45+
bundle_id = "com.google.firebase.quickstart.CrashlyticsExample",
46+
entitlements = ":macOS/macOS.entitlements",
47+
infoplists = [":macOS/Info.plist"],
48+
minimum_os_version = "11.0",
49+
resources = glob(
50+
["CrashlyticsSwiftUIExample/Assets.xcassets/**"],
51+
exclude = ["CrashlyticsSwiftUIExample/Assets.xcassets/AppIconTopShelfImage.brandassets/**"],
52+
),
53+
deps = [":CrashlyticsSwiftUIExample"],
54+
)
55+
56+
build_test(
57+
name = "iosapp_build_test",
58+
targets = [
59+
":iosapp",
60+
":macosapp",
61+
],
62+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "tv",
9+
"scale" : "2x"
10+
}
11+
],
12+
"info" : {
13+
"author" : "xcode",
14+
"version" : 1
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
},
6+
"layers" : [
7+
{
8+
"filename" : "Front.imagestacklayer"
9+
},
10+
{
11+
"filename" : "Middle.imagestacklayer"
12+
},
13+
{
14+
"filename" : "Back.imagestacklayer"
15+
}
16+
]
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "tv",
9+
"scale" : "2x"
10+
}
11+
],
12+
"info" : {
13+
"author" : "xcode",
14+
"version" : 1
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "tv",
9+
"scale" : "2x"
10+
}
11+
],
12+
"info" : {
13+
"author" : "xcode",
14+
"version" : 1
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
},
6+
"layers" : [
7+
{
8+
"filename" : "Front.imagestacklayer"
9+
},
10+
{
11+
"filename" : "Middle.imagestacklayer"
12+
},
13+
{
14+
"filename" : "Back.imagestacklayer"
15+
}
16+
]
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

0 commit comments

Comments
 (0)