Open mostafa-v opened 8 months ago
When building on MacOS, the Swift version is dictated by the Xcode version. By any chance, do you have multiple versions of Xcode installed? I use the third-party utility, xcodes, to manage my Xcode installations.
What do you get when you run swift --version
?
❯ swift --version
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
Hi I had multiple versions in the past, but now I only have Xcode 15.1 installation.
$ swift --version swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5) Target: x86_64-apple-macosx13.0
Is there any chance that you can post a repro for the issue? It would help with diagnosing it.
I can't share my project but I'll try to reproduce the issue in another project.
The error didn't happen in a sample bazel project.
So it means there is some problem with my project. here is my .bazelrc file. could it be something related to this file?
build --action_env=ZERO_AR_DATE=1
build --apple_platform_type=ios
build --enable_platform_specific_config
build --apple_crosstool_top=@local_config_apple_cc//:toolchain
build --crosstool_top=@local_config_apple_cc//:toolchain
build --host_crosstool_top=@local_config_apple_cc//:toolchain
build --cxxopt='-std=c++17'
build --swiftcopt=-whole-module-optimization
build --per_file_copt=".*\.m$","@-fno-objc-msgsend-selector-stubs"
build --per_file_copt=".*\.mm$","@-fno-objc-msgsend-selector-stubs"
build --linkopt="-ld_classic"
build --features=debug_prefix_map_pwd_is_dot
build --features=swift.cacheable_swiftmodules
build --features=swift.debug_prefix_map
build --features=swift.enable_vfsoverlays
build --strategy=Genrule=standalone
build --spawn_strategy=standalone
build --strategy=SwiftCompile=standalone
build --define RULES_SWIFT_BUILD_DUMMY_WORKER=1
# Required by firebase-ios-sdk, googleappmeasurement, googledatatransport, googleutilities
#build --copt='-std=c99'
# Required by firebase-ios-sdk, googleappmeasurement, googledatatransport, googleutilities, leveldb
build --cxxopt='-std=gnu++14'
.bazelrc file seems irrelevant to the issue.
I don't have any idea even where to find a clue.
The only thing that jumps out at me from your bazelrc are these two line:
build --strategy=SwiftCompile=standalone
build --define RULES_SWIFT_BUILD_DUMMY_WORKER=1
I did some Googling. They are legitimate. However, it does appear that they may change how the code is built. I would try removing those and see if the problem persists.
anyway even in the sample project, the FirebaseAnalytics framework is built with swift 5.7.1. I can't figure out how it is possible since my swift version is 5.9.2.
Can you share your sample project?
Can you share your sample project?
@mostafa-v I cloned the sample project. I am not seeing any errors when building or running the tests. I did need to make some changes to the project. Can you give me permission to write to the sampe repo so that I can push a branch with my changes?
@cgrindel As I said, the sample project builds without error, but it still builds with swift 5.7.1 as I looked into swiftinterface files.
I suspected that my main project didn't build because of warnings-as-errors configuration, but even after removing them, the error persists.
I gave you the permission to the repo.
Thank you
@mostafa-v Where in your output tree are you finding the .swiftinterface
files that indicate the Swift version mismatch?
Also, I pushed a branch, chuck_debug
, that contains my changes.
@mostafa-v Where in your output tree are you finding the
.swiftinterface
files that indicate the Swift version mismatch?
/private/var/tmp/_bazel_user/6b735afcfbd845b535942247d945b5a9/rules_xcodeproj.noindex/build_output_base/external/rules_swift_package_manager~0.25.0~swift_deps~swiftpkg_firebase_ios_sdk/remote/archive/FirebaseAnalytics.zip/FirebaseAnalytics.xcframework/ios-arm64_x86_64-simulator/FirebaseAnalytics.framework/Modules/FirebaseAnalytics.swiftmodule
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
// swift-module-flags: -target x86_64-apple-ios10.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name FirebaseAnalytics
// swift-module-flags-ignorable: -enable-bare-slash-regex
@_exported import FirebaseAnalytics
import StoreKit
import Swift
import SwiftUI
import _Concurrency
import _StringProcessing
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, *)
@available(watchOS, unavailable)
extension FirebaseAnalytics.Analytics {
public static func logTransaction(_ transaction: StoreKit.Transaction)
}
@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, *)
@available(watchOS, unavailable)
extension SwiftUI.View {
public func analyticsScreen(name: Swift.String, class: Swift.String = "View", extraParameters: [Swift.String : Any] = [:]) -> some SwiftUI.View
}
Those files are from the Firestore xcframework. The Bazel build does not generate them.
Without seeing the project that is failing, the only suggestion that I have is to compare it to the Firebase Analytics example in the rules_swift_package_manager
repo.
Those files are from the Firestore xcframework. The Bazel build does not generate them.
Without seeing the project that is failing, the only suggestion that I have is to compare it to the Firebase Analytics example in the
rules_swift_package_manager
repo.
My project fails at the swiftmodule I mentioned.
Maybe if I run my project on a remote mac server and send the credentials to your email, could you please check it there?
Sure. I can take a look.
Hi
I use rules_swift_package_manager to include Firebase in my bazel project.
After updating to Xcode 15, I have got a strange error about swift compiler version.
Failed to build module 'FirebaseAnalytics'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)', while this compiler is 'Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)'). Please select a toolchain which matches the SDK.
As my knowledge, swift package manger should build the framework with current swift version, but in my case there is some issues which I can't find where the root of the problem is.
I haven't had such issues before upgrading to Xcode 15.
Also this error does not happen if I import Firebase in a normal Xcode 15 project (created by Xcode)
Is it something that should be fixed on my bazel project configurations, or Firebase repo, or rules_swift_package_manger repo or rules_swift repo or any other bazel repo?
Please help.