Skip to content

Commit

Permalink
feat: support @import of modules in Objective-C code (#238)
Browse files Browse the repository at this point in the history
- Fix the generation logic for Apple built-in frameworks to retrieve the
values from the correct directories.
- For Objective-C code, look for the import of Apple built-in frameworks
and conditionally add them to the `sdk_frameworks` option in
`objc_library`.
- Generate modulemap for Swift targets `@import`'d by Objective-C.
- Update module-to-Bazel label resolution to include modulemap targets
when necessary.
- Update Firebase example to use 10.5.0.
- Enable the `appdistribution` example in the Firebase example.

Closes #208.
Closes #231.
  • Loading branch information
cgrindel authored Feb 23, 2023
1 parent 96bf4ce commit d3f4765
Show file tree
Hide file tree
Showing 40 changed files with 2,544 additions and 326 deletions.
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# To update these lines, execute
# `bazel run @contrib_rules_bazel_integration_test//tools:update_deleted_packages`
build --deleted_packages=examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,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/objc_code,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/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
query --deleted_packages=examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,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/objc_code,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/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
build --deleted_packages=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/objc_code,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/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
query --deleted_packages=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/objc_code,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/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example

# Import Shared settings
import %workspace%/shared.bazelrc
Expand Down
32 changes: 16 additions & 16 deletions examples/firebase_example/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git",
"state" : {
"revision" : "fffc3c2729be5747390ad02d5100291a0d9ad26a",
"version" : "0.20200225.4"
"revision" : "583de9bd60f66b40e78d08599cc92036c2e7e4e1",
"version" : "0.20220203.2"
}
},
{
"identity" : "boringssl-swiftpm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/boringssl-SwiftPM.git",
"state" : {
"revision" : "734a8247442fde37df4364c21f6a0085b6a36728",
"version" : "0.7.2"
"revision" : "dd3eda2b05a3f459fc3073695ad1b28659066eab",
"version" : "0.9.1"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "839cc6b0cd80b0b8bf81fe9bd82b743b25dc6446",
"version" : "8.9.1"
"revision" : "f567ed9a2b30e29159df258049a9c662c517688e",
"version" : "10.5.0"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "9b2f6aca5b4685c45f9f5481f19bee8e7982c538",
"version" : "8.9.1"
"revision" : "9a09ece724128e8d1e14c5133b87c0e236844ac0",
"version" : "10.4.0"
}
},
{
Expand All @@ -55,21 +55,21 @@
}
},
{
"identity" : "grpc-swiftpm",
"identity" : "grpc-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/grpc-SwiftPM.git",
"location" : "https://github.com/grpc/grpc-ios.git",
"state" : {
"revision" : "fb405dd2c7901485f7e158b24e3a0a47e4efd8b5",
"version" : "1.28.4"
"revision" : "8440b914756e0d26d4f4d054a1c1581daedfc5b6",
"version" : "1.44.3-grpc"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "4e9bbf2808b8fee444e84a48f5f3c12641987d3e",
"version" : "1.7.2"
"revision" : "96d7cc73a71ce950723aa3c50ce4fb275ae180b8",
"version" : "3.1.0"
}
},
{
Expand All @@ -86,8 +86,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "7ee9ef9f627d85cbe1b8c4f49a3ed26eed216c77",
"version" : "2.30908.0"
"revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
"version" : "2.30909.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/firebase_example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import PackageDescription
let package = Package(
name: "firebase_example",
dependencies: [
.package(url: "https://github.com/firebase/firebase-ios-sdk", .exact("8.9.1")),
.package(url: "https://github.com/firebase/firebase-ios-sdk", .upToNextMajor(from: "10.0.0")),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ swift_library(
tags = ["manual"],
visibility = ["//visibility:public"],
# GH202: Incomplete deps are generated.
deps = ["@swiftpkg_firebase_ios_sdk//:SwiftPM-PlatformExclude_FirebaseAppDistributionWrap_FirebaseAppDistributionTarget"],
deps = [
"@swiftpkg_firebase_ios_sdk//:SwiftPM-PlatformExclude_FirebaseAppDistributionWrap_FirebaseAppDistributionTarget",
],
)

ios_application(
Expand All @@ -29,10 +31,7 @@ ios_application(
["Assets.xcassets/**"],
exclude = ["Assets.xcassets/AppIcon.appiconset/**"],
) + [
":GoogleService-Info.plist",
"//appdistribution:shared_resources",
],
# GH208: This fails due to an Objc module not being found by another Objc module.
# Marking as manual so that they do not run during CI.
tags = ["manual"],
deps = [":AppDistributionExample"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ swift_library(
ios_unit_test(
name = "FooTests",
minimum_os_version = "13.0",
# GH208: This fails due to an Objc module not being found by another Objc module.
# Marking as manual so that they do not run during CI.
tags = ["manual"],
visibility = ["//visibility:private"],
deps = [":AppDistributionTests"],
)
7 changes: 7 additions & 0 deletions examples/firebase_example/appdistribution/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
filegroup(
name = "shared_resources",
srcs = [
"GoogleService-Info.plist",
],
visibility = ["//appdistribution:__subpackages__"],
)
20 changes: 10 additions & 10 deletions examples/firebase_example/swift_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ def swift_dependencies():
# version: 0.20200225.4
swift_package(
name = "swiftpkg_abseil_cpp_swiftpm",
commit = "fffc3c2729be5747390ad02d5100291a0d9ad26a",
commit = "583de9bd60f66b40e78d08599cc92036c2e7e4e1",
dependencies_index = "@//:swift_deps_index.json",
remote = "https://github.com/firebase/abseil-cpp-SwiftPM.git",
)

# version: 0.7.2
swift_package(
name = "swiftpkg_boringssl_swiftpm",
commit = "734a8247442fde37df4364c21f6a0085b6a36728",
commit = "dd3eda2b05a3f459fc3073695ad1b28659066eab",
dependencies_index = "@//:swift_deps_index.json",
remote = "https://github.com/firebase/boringssl-SwiftPM.git",
)

# version: 8.9.1
swift_package(
name = "swiftpkg_firebase_ios_sdk",
commit = "839cc6b0cd80b0b8bf81fe9bd82b743b25dc6446",
commit = "f567ed9a2b30e29159df258049a9c662c517688e",
dependencies_index = "@//:swift_deps_index.json",
remote = "https://github.com/firebase/firebase-ios-sdk",
)

# version: 8.9.1
swift_package(
name = "swiftpkg_googleappmeasurement",
commit = "9b2f6aca5b4685c45f9f5481f19bee8e7982c538",
commit = "9a09ece724128e8d1e14c5133b87c0e236844ac0",
dependencies_index = "@//:swift_deps_index.json",
remote = "https://github.com/google/GoogleAppMeasurement.git",
)
Expand All @@ -49,18 +49,18 @@ def swift_dependencies():
remote = "https://github.com/google/GoogleUtilities.git",
)

# version: 1.28.4
# version: 1.44.3-grpc
swift_package(
name = "swiftpkg_grpc_swiftpm",
commit = "fb405dd2c7901485f7e158b24e3a0a47e4efd8b5",
name = "swiftpkg_grpc_ios",
commit = "8440b914756e0d26d4f4d054a1c1581daedfc5b6",
dependencies_index = "@//:swift_deps_index.json",
remote = "https://github.com/firebase/grpc-SwiftPM.git",
remote = "https://github.com/grpc/grpc-ios.git",
)

# version: 1.7.2
swift_package(
name = "swiftpkg_gtm_session_fetcher",
commit = "4e9bbf2808b8fee444e84a48f5f3c12641987d3e",
commit = "96d7cc73a71ce950723aa3c50ce4fb275ae180b8",
dependencies_index = "@//:swift_deps_index.json",
remote = "https://github.com/google/gtm-session-fetcher.git",
)
Expand All @@ -76,7 +76,7 @@ def swift_dependencies():
# version: 2.30908.0
swift_package(
name = "swiftpkg_nanopb",
commit = "7ee9ef9f627d85cbe1b8c4f49a3ed26eed216c77",
commit = "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
dependencies_index = "@//:swift_deps_index.json",
remote = "https://github.com/firebase/nanopb.git",
)
Expand Down
Loading

0 comments on commit d3f4765

Please sign in to comment.