Hello I have 3 libraries, one in Objective-C (Amplitude-iOS), other one in Swift (ObjectMapper) and a mixed one (RxSwift + a dummy .m file)
bazel build //:Amplitude-iOS //:ObjectMapper //:RxSwift --python_version=PY3 --cpu=ios_x86_64 --apple_platform_type=ios --verbose_failures --sandbox_debug --subcommands --ios_minimum_os=12.0
And when I look in the bazel-bin directory there are only two .a files: libAmplitude-iOS.a and libRxSwift.a
If a run ar -t with the libAmplitude-iOS.a I see that there are 14 .o files which corresponds with the number of .m source files
omarzl@mbp-omar exported_libs % ar -t bazel-bin/libAmplitude-iOS.a
__.SYMDEF
AMPConstants_69d0a734354b5db134c2893a4161a6d7.o
AMPDatabaseHelper_3ce394e8374a71ca185335530daf03f7.o
AMPDeviceInfo_6941f9a7f4f2f9c7b05ffb59cfcae914.o
AMPIdentify_b6e25ffb9a47bb738a3110067cbd6bdf.o
AMPLocationManagerDelegate_d6cc0574ce7b251a1a0de43f5096b8d9.o
AMPRevenue_edcc78e5e6939b0865f93de2b3781aa9.o
AMPTrackingOptions_5923c90a5ee0e9d29a35228ca584be61.o
AMPURLConnection_29b1a1224fd7ccf7036a8f66da53774f.o
AMPURLSession_ae5a05de96254d84934ab2d6e7a0ea27.o
AMPUtils_42cfe63f40eb632317ac07b38e0c9099.o
Amplitude_33a97a094c115fc384cad215184f0fbd.o
ISPCertificatePinning_5256c1810f4cd79ee1a3e3ed5f000abd.o
ISPPinnedNSURLConnectionDelegate_99c34a6f04fbfca446535d93f055ea8b.o
ISPPinnedNSURLSessionDelegate_d802e965b4b973ebb90843b7ad6c755a.o
But if I run ar -t with the libRxSwift.a library there is only the dummy m file but no swift object files are being archived
omarzl@mbp-omar exported_libs % ar -t bazel-bin/libRxSwift.a
__.SYMDEF SORTED
RxSwift-dummy_e151122338dca6ddb0d82612c1760f0d.o
And finally with the target ObjectMapper that is swift only, there is no .a file and don't see it is compiling the code at all.
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "build_bazel_rules_apple",
remote = "https://github.com/bazelbuild/rules_apple.git",
commit = "18fbeadb089638eb2248de6e7685e0d4415c21cc",
)
git_repository(
name = "build_bazel_rules_swift",
remote = "https://github.com/bazelbuild/rules_swift.git",
commit = "cd66dc7c0aa6010f56676dbb89091f882d4ec9c5",
)
git_repository(
name = "rules_apple_line",
remote = "https://github.com/line/rules_apple_line.git",
commit = "d6a7706751634b938cb28fa666c4e04e1aeb4832",
)
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
load(
"@rules_apple_line//apple:repositories.bzl",
"rules_apple_line_dependencies",
)
# If you want to lock apple_support, rules_apple and rules_swift to specific
# versions, be sure to call this function after their repository rules.
rules_apple_line_dependencies()
load("@rules_apple_line//apple:apple_library.bzl", "apple_library")
load("@rules_apple_line//apple:objc_library.bzl", "objc_library")
load("@rules_apple_line//apple:swift_library.bzl", "swift_library")
objc_library(
name = "Amplitude-iOS",
srcs = glob([
"Amplitude-iOS/Sources/Amplitude/*.m",
"Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/*.m",
]),
hdrs = [
"Amplitude-iOS/Sources/Amplitude/AMPConstants.h",
"Amplitude-iOS/Sources/Amplitude/AMPDatabaseHelper.h",
"Amplitude-iOS/Sources/Amplitude/AMPDeviceInfo.h",
"Amplitude-iOS/Sources/Amplitude/AMPIdentify.h",
"Amplitude-iOS/Sources/Amplitude/Amplitude+SSLPinning.h",
"Amplitude-iOS/Sources/Amplitude/Amplitude.h",
"Amplitude-iOS/Sources/Amplitude/AMPLocationManagerDelegate.h",
"Amplitude-iOS/Sources/Amplitude/AMPRevenue.h",
"Amplitude-iOS/Sources/Amplitude/AMPTrackingOptions.h",
"Amplitude-iOS/Sources/Amplitude/AMPURLConnection.h",
"Amplitude-iOS/Sources/Amplitude/AMPURLSession.h",
"Amplitude-iOS/Sources/Amplitude/AMPUtils.h",
"Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/ISPCertificatePinning.h",
"Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/ISPPinnedNSURLConnectionDelegate.h",
"Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/ISPPinnedNSURLSessionDelegate.h",
],
copts = [
"-w",
"-Xanalyzer",
"-analyzer-disable-all-checks",
],
enable_modules = True,
module_name = "Amplitude_iOS",
sdk_dylibs = ["sqlite3.0"],
visibility = ["//visibility:public"],
)
swift_library(
name = "ObjectMapper",
srcs = glob([
"ObjectMapper/Sources/*.swift"
]),
enable_modules = True,
module_name = "ObjectMapper",
visibility = ["//visibility:public"],
)
apple_library(
name = "RxSwift",
srcs = glob(
[
"RxSwift/RxSwift/**/*.swift",
"RxSwift/Platform/**/*.swift",
"RxSwift/RxSwift-dummy.m",
],
exclude = [
"RxSwift/RxSwift/Platform/**/*.swift",
],
),
enable_modules = True,
module_name = "RxSwift",
objc_copts = [
"-w",
"-Xanalyzer",
"-analyzer-disable-all-checks",
],
visibility = ["//visibility:public"],
)
What I am missing? How could I make that all the targets generate an .a static archive?
I am using the latest commit for all the rules and here are the files to test with.