Skip to content

Commit 74a3c3a

Browse files
authored
4.x: Bump Swift stdlib presence thresholds for Span compatibility (#2915) (#2916)
1 parent 32e0610 commit 74a3c3a

File tree

6 files changed

+123
-14
lines changed

6 files changed

+123
-14
lines changed

apple/internal/partials/swift_dylibs.bzl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ File object that represents a directory containing the Swift dylibs to package f
5757
},
5858
)
5959

60-
# Minimum OS versions for which we no longer need to potentially bundle any
61-
# Swift dylibs with the application. The first cutoff point was when the
62-
# platforms bundled the standard libraries, the second was when they started
63-
# bundling the Concurrency library. There may be future libraries that require
64-
# us to continue bumping these values. The tool is smart enough only to bundle
65-
# those libraries required by the minimum OS version of the scanned binaries.
60+
# For each platform, the minimum OS version at which we no longer need to bundle
61+
# any Swift dylibs with the application -- either the pre-ABI-stable runtime or
62+
# back-deployed runtimes (e.g., Concurrency and Span). We do not need to
63+
# consider each of these cases individually; `swift-stdlib-tool` will only
64+
# bundle the libraries required based on the minimum OS version of the scanned
65+
# binaries.
6666
#
67-
# Values are the first version where bundling is no longer required and should
68-
# correspond with the Swift compilers values for these which is the source of
69-
# truth https://github.com/apple/swift/blob/998d3518938bd7229e7c5e7b66088d0501c02051/lib/Basic/Platform.cpp#L82-L105
67+
# These values should be kept in sync with the values in
68+
# `swift::tripleRequiresRPathForSwiftLibrariesInOS` defined in:
69+
# https://github.com/apple/swift/blob/main/lib/Basic/Platform.cpp.
7070
_MIN_OS_PLATFORM_SWIFT_PRESENCE = {
71-
"ios": apple_common.dotted_version("15.0"),
72-
"macos": apple_common.dotted_version("12.0"),
73-
"tvos": apple_common.dotted_version("15.0"),
74-
"visionos": apple_common.dotted_version("1.0"),
75-
"watchos": apple_common.dotted_version("8.0"),
71+
"ios": apple_common.dotted_version("26.0"),
72+
"macos": apple_common.dotted_version("26.0"),
73+
"tvos": apple_common.dotted_version("26.0"),
74+
"visionos": apple_common.dotted_version("26.0"),
75+
"watchos": apple_common.dotted_version("26.0"),
7676
}
7777

7878
def _swift_dylib_action(

test/starlark_tests/common.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ _min_os_ios = struct(
3838
icon_bundle_required = "26.0",
3939
oldest_supported = "11.0",
4040
nplus1 = "13.0",
41+
span_in_os = "26.0",
4142
stable_swift_abi = "12.2",
4243
widget_configuration_intents_support = "16.0",
4344
)

test/starlark_tests/ios_application_tests.bzl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,54 @@ def ios_application_test_suite(name):
237237
tags = [name],
238238
)
239239

240+
archive_contents_test(
241+
name = "{}_device_swift_span_compatibility_dylib_present_on_older_os".format(name),
242+
build_type = "device",
243+
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_using_span_pre_26",
244+
contains = [
245+
"$BUNDLE_ROOT/Frameworks/libswiftCompatibilitySpan.dylib",
246+
"$ARCHIVE_ROOT/SwiftSupport/iphoneos/libswiftCompatibilitySpan.dylib",
247+
],
248+
tags = [
249+
name,
250+
],
251+
)
252+
archive_contents_test(
253+
name = "{}_simulator_swift_span_compatibility_dylib_present_on_older_os".format(name),
254+
build_type = "simulator",
255+
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_using_span_pre_26",
256+
contains = [
257+
"$BUNDLE_ROOT/Frameworks/libswiftCompatibilitySpan.dylib",
258+
],
259+
tags = [
260+
name,
261+
],
262+
)
263+
264+
archive_contents_test(
265+
name = "{}_device_swift_span_compatibility_dylib_not_present_on_newer_os".format(name),
266+
build_type = "device",
267+
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_using_span_post_26",
268+
not_contains = [
269+
"$BUNDLE_ROOT/Frameworks/libswiftCompatibilitySpan.dylib",
270+
"$ARCHIVE_ROOT/SwiftSupport/iphoneos/libswiftCompatibilitySpan.dylib",
271+
],
272+
tags = [
273+
name,
274+
],
275+
)
276+
archive_contents_test(
277+
name = "{}_simulator_swift_span_compatibility_dylib_not_present_on_newer_os".format(name),
278+
build_type = "simulator",
279+
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_using_span_post_26",
280+
not_contains = [
281+
"$BUNDLE_ROOT/Frameworks/libswiftCompatibilitySpan.dylib",
282+
],
283+
tags = [
284+
name,
285+
],
286+
)
287+
240288
apple_verification_test(
241289
name = "{}_imported_fmwk_codesign_test".format(name),
242290
build_type = "simulator",

test/starlark_tests/resources/BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ swift_library(
237237
tags = common.fixture_tags,
238238
)
239239

240+
swift_library(
241+
name = "swift_span_main_lib",
242+
srcs = ["span_main.swift"],
243+
tags = common.fixture_tags,
244+
)
245+
240246
swift_library(
241247
name = "swift_lib_with_structured_resources",
242248
testonly = True,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2025 The Bazel Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
16+
@main
17+
struct App {
18+
static func main() {
19+
// Many back-deployed functions are `@_alwaysEmitIntoClient` so referencing them won't
20+
// necessarily require the dylib to be linked. Type metadata, on the other hand, will always
21+
// require the dylib to be linked.
22+
print(Span<Int>.self)
23+
}
24+
}

test/starlark_tests/targets_under_test/ios/BUILD

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@ xcarchive(
146146
tags = common.fixture_tags,
147147
)
148148

149+
ios_application(
150+
name = "swift_app_using_span_pre_26",
151+
bundle_id = "com.google.example",
152+
families = ["iphone"],
153+
infoplists = [
154+
"//test/starlark_tests/resources:Info.plist",
155+
],
156+
minimum_os_version = common.min_os_ios.stable_swift_abi,
157+
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
158+
tags = common.fixture_tags,
159+
deps = [
160+
"//test/starlark_tests/resources:swift_span_main_lib",
161+
],
162+
)
163+
164+
ios_application(
165+
name = "swift_app_using_span_post_26",
166+
bundle_id = "com.google.example",
167+
families = ["iphone"],
168+
infoplists = [
169+
"//test/starlark_tests/resources:Info.plist",
170+
],
171+
minimum_os_version = common.min_os_ios.span_in_os,
172+
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
173+
tags = common.fixture_tags,
174+
deps = [
175+
"//test/starlark_tests/resources:swift_span_main_lib",
176+
],
177+
)
178+
149179
ios_application(
150180
name = "app_minimal_with_deployment_version",
151181
bundle_id = "com.google.example",

0 commit comments

Comments
 (0)