Support Swift in the iOS embedder#167530
Merged
Merged
Conversation
2b0c064 to
f8841c0
Compare
73ed14a to
2f44201
Compare
zanderso
reviewed
Apr 22, 2025
f102b89 to
d384568
Compare
vashworth
reviewed
Apr 23, 2025
cbracken
commented
Apr 23, 2025
| _tool = rebase_path("//build/toolchain/apple/swiftc.py", root_build_dir) | ||
|
|
||
| depfile = "{{target_out_dir}}/{{module_name}}.d" | ||
| depsformat = "gcc" |
Member
Author
There was a problem hiding this comment.
For those who haven't been sufficiently traumatised by gn, the reason for the seemingly random alternation between variables prefixed/unprefixed in _ is that the unprefixed ones are special tool attributes that gn knows about whereas the prefixed ones are locals to make this less painful to read.
bf46015 to
1503f02
Compare
1503f02 to
111da32
Compare
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 29, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 29, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 29, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
May 1, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
May 1, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
May 1, 2025
| # This is here so that all files get recompiled after an Xcode update. | ||
| # (defines are passed via the command line, and build system rebuild things | ||
| # when their commandline changes). Nothing should ever read this define. | ||
| #defines = [ "CR_XCODE_VERSION=$xcode_version" ] |
Contributor
There was a problem hiding this comment.
@cbracken Oh i just remembered I came across this a while back when trying to support swift 6.
From the comment it looks like you intended to pass it in below to handle xcode update scenario, but it's commented out. Wondering what's the current state (can it be removed or do we still want it?)
9 tasks
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
swifttool to the gn mac toolchain and wires up support for Swiftsource_settargets. PortsFlutterUIPressProxyto Swift.gntoolchain modifications include://flutter/third_party/libcxx/includeand//flutter/third_party/libcxxabi/includefrom the defaultinclude_dirson allsource_settargets, and instead adds them viacflagsandcflags_ccso they continue to be picked up by C, C++, Obj-C, Obj-C++ targets. Flutter's custom libc++ library headers should be picked up by C, C++, Objective-C, and Objective-C++ targets, but not Swift targets. Swift code does not use libc++ directly, but many Apple core libraries such as Foundation.framework are implemented in Objective-C/Objective-C++ and directly or indirectly rely on Apple's libc++ implementation in System.framework. Because of this, and because Swift compiles use Clang modules, we should ensure the correct (Apple) libc++ is picked up from Swift targets by ensuring our own libc++ is not.swiftflagstosource_settargets. This list is used by for Swiftsource_settargets by theswifttool in the gn toolchain.//build/config/ios:compilerconfig toengine/src/build/config/ios/BUILD.gn. This sets defaultswiftflagsfor iOS targets. This attribute is (only) used by the newswifttool in the toolchain.-gtoswiftflagsfor debug (unopt) builds inengine/src/build/config/compiler/BUILD.gn.swifttool to the gn toolchain that invokesswiftc.pyto perform compilation and generate a bridging header. This tool is invoked automatically by gn for Swiftsource_settargets.//build/toolchain/apple/swiftc.py, a wrapper script aroundswiftcin Xcode's Swift toolchain. This script ensures builds are invoked hermetically using a new build cache directory for the emitted swiftmodule, precompiled header, and bridging header, for each compile. The outputs are then copied into the gn output directory. Also adds supporting script//build/toolchain/apple/get_tool_mtime.pyand data//build/toolchain/apple/swift_const_gather_protocols.json, both used byswiftc.py.cxx_moduletool to the gn toolchain that supports clang module-based compiles. This is used for libc++ transitively via System.framework and others that rely on it.gnvariable modifications include:apple_host_toolchain_pathvariable inengine/src/build/config/apple/apple_sdk.gni. This is set using//build/mac/find_sdk.pyto the path of Xcode'sXcodeDefault.xctoolchain. This is where Xcode'sswiftctool and some Swift libraries are located. This will be used to create a symlink in the//flutter/prebuilts/SDKsdirectory to locate Swift tooling during builds.enging/src/tools/gnto pre-populate that path as we do with other Xcode SDK path symlinks, to improve performance.ios_swift_lib_pathsinengine/src/build/config/ios/ios_sdk.gniwhich holds the path of Swift shared libraries for either iOS physical device or simulator targets. This is within the appropriateiphoneoriphonesimulatorSDK directory within Xcode.verify_exported.dartchanges:^_\$s\d+InternalFlutterSwift. To allow Swift symbols to be exported in an Objective-C bridging header, they must bepublicoropen. We only ever use these types internally within the framework and never publish these types in a public header. Like_InternalFlutterObj-C symbols, we allowInternalFlutterSwiftsymbols, as they are clearly marked as internal and an end user would need to reverse engineer out their own header to use them.(__DATA,__data)and(__DATA_CONST,__const)in addition to the existing Mach-O sections, so long as it matches the existing criteria.Finally, this patch adds Swift code to the embedder and embedder tests as proof of concept and to prevent regressions. This ports
FlutterUIPressProxyand its subclassFakeUIPressProxyto Swift in order to verify both:Issue: #144791
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.