[swift-evolution] [DRAFT] Enhancing the Platform Configuration Test Suite for Conditional Compilation Blocks

Erica Sadun erica at ericasadun.com
Wed Jun 29 10:19:37 CDT 2016


Unless I'm greatly misunderstanding things, this won't enter the language until after at least December, 
probably more like February or March of 2017, as it is purely additive.  

You can see the proposals marked for "post 3.0" in the Github pull requests list.

-- E

> On Jun 29, 2016, at 12:55 AM, Jacob Bandes-Storch <jtbandes at gmail.com> wrote:
> 
> +1 on getting this proposal reviewed soon; I ran into the lack of
> TARGET_OS_SIMULATOR today (and was about to send an email, before I
> searched a little harder and found this).
> 
> On Thu, Jun 16, 2016 at 9:49 AM, Erica Sadun via swift-evolution <
> swift-evolution at swift.org> wrote:
> 
>> This is an omnibus conditional compilation block proposal. It is built out
>> of Swift Evolution community requests and discussions dating back on
>> various threads to the genesis of the list.
>> 
>> 
>>   - This draft does not include tests for debug conditions. That was
>>   pitched under separate cover using runtime functions instead of conditional
>>   compilation blocks.
>>   - This draft does not include tests for OS versions, as that seems to
>>   be better addressed using the existing availability tests.
>>   - This draft is rewritten with respect to Jordan Rose's "Rename "build
>>   configurations" to "conditional compilation blocks"" swift commit
>>   <https://github.com/apple/swift/commit/6272941c5cba9581a5ee93d92a6ee66e28c1bf13> from
>>   12 February (rdar://problem/19812930).
>>   - It is offered as an omnibus because all the tests fall under the
>>   same "conditional compilation block" umbrella. Using an omnibus reduces
>>   list traffic and demands on core team resources. It's understood that the
>>   proposal is likely to be accepted with modifications (or rejected as a
>>   whole) due to the multiple tests.
>> 
>> 
>> -- Erica
>> 
>> gist: https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298
>> 
>> Enhancing the Platform Configuration Test Suite for Conditional
>> Compilation Blocks
>> 
>>   - Proposal: TBD
>>   - Author: Erica Sadun <http://github.com/erica>
>>   - Status: TBD
>>   - Review manager: TBD
>> 
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#introduction>
>> Introduction
>> 
>> This proposal introduces additional configuration tests to differentiate
>> platform conditions in conditional compilation blocks.
>> 
>> This proposal was first discussed on-list in the [Draft] Introducing
>> Build Configuration Tests for Platform Conditions
>> <http://thread.gmane.org/gmane.comp.lang.swift.evolution/12140/focus=12267> thread
>> and then re-pitched in TBD <https://gist.github.com/erica/TBD>.
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#note>Note
>> 
>> The term "build configuration" is subsumed by "conditional compilation
>> block". See this accepted patch
>> <https://github.com/apple/swift/commit/6272941c5cba9581a5ee93d92a6ee66e28c1bf13>
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#motivation>
>> Motivation
>> 
>> Testing for platform conditions is a typical developer task. Although some
>> built-in features like CFByteOrderGetCurrentexist, it seems a natural
>> match for Swift to introduce conditional compilation blocks specific to
>> common platform conditions.
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#current-art>Current
>> Art
>> 
>> Swift currently supports the following platform configuration tests,
>> defined in lib/Basic/LangOptions.cpp.
>> 
>>   - The literals true and false
>>   - The os() function that tests for OSX, iOS, watchOS, tvOS, Linux,
>>   Windows, Android, and FreeBSD
>>   - The arch() function that tests for x86_64, arm, arm64, i386,
>>   powerpc64, s390x, and powerpc64le
>>   - The swift() function that tests for specific Swift language
>>   releases, e.g. swift(>=2.2)
>> 
>> The following platform configuration test has been accepted in SE-0075
>> <https://github.com/apple/swift-evolution/blob/master/proposals/0075-import-test.md> but
>> not yet implemented:
>> 
>>   - The canImport() function that tests whether specific modules can be
>>   imported.
>> 
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#detailed-design>Detailed
>> Design
>> 
>> This proposal introduces several platform condition tests for use in
>> conditional compilation blocks: endianness, bitwidth, vendor, objc interop,
>> and simulator.
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#endianness>
>> Endianness
>> 
>> Endianness refers to the byte order used in memory. This proposal exposes
>> endian test conditions, promoting them from private underscored names to
>> public developer-referencable ones.
>> 
>> // Set the "_endian" platform condition.
>>  switch (Target.getArch()) {
>>  case llvm::Triple::ArchType::arm:
>>  case llvm::Triple::ArchType::thumb:
>>    addPlatformConditionValue("_endian", "little");
>>    break;
>>  case llvm::Triple::ArchType::aarch64:
>>    addPlatformConditionValue("_endian", "little");
>>    break;
>>  case llvm::Triple::ArchType::ppc64:
>>    addPlatformConditionValue("_endian", "big");
>>    break;
>>  case llvm::Triple::ArchType::ppc64le:
>>    addPlatformConditionValue("_endian", "little");
>>    break;
>>  case llvm::Triple::ArchType::x86:
>>    addPlatformConditionValue("_endian", "little");
>>    break;
>>  case llvm::Triple::ArchType::x86_64:
>>    addPlatformConditionValue("_endian", "little");
>>    break;
>>  case llvm::Triple::ArchType::systemz:
>>    addPlatformConditionValue("_endian", "big");
>>    break;
>>  default:
>>    llvm_unreachable("undefined architecture endianness");
>> 
>> Under this proposal _endian is renamed to endian and made a public API.
>> 
>> Use:
>> 
>> #if endian(big)
>>    // Big endian code
>> #endif
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#bitwidth>
>> Bitwidth
>> 
>> Bitwidth describes the number of bits used to represent a number. This
>> proposal introduces a bitwidth test with two options: 32 and 64.
>> 
>> Use:
>> 
>> #if bitwidth(64)
>>    // 64-bit code
>> #endif
>> 
>> List members briefly discussed whether it was better to measure pointer
>> width or the size of Int. William Dillon suggested renaming bitwidth to
>> either intwidth or intsize. Brent Royal-Gordon suggests intbits.
>> Alternatives include bitsand bitsize. This proposal avoids wordbits because
>> of the way, for example, Intel ends up doing “dword”, “qword”, and so forth
>> for backwards compatibility.
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#vendor>
>> Vendor
>> 
>> A vendor describes the corporate or other originator of a platform. This
>> proposal introduces a test that returns platform vendor, with one option at
>> this time: Apple. Apple deployment provides an umbrella case for wide
>> range of coding norms that may not be available on non-Apple platforms.
>> This "family of targets" provides a simpler test than looking for specific
>> modules or listing individual operating systems, both of which provide
>> fragile approaches to this requirement.
>> 
>> This call would be supported in Swift's source-code by the existing
>> private getVendor() used in lib/Basic/LangOptions.cpp.
>> 
>> Use:
>> 
>> #if vendor(Apple)
>>    // Code specific to Apple platform deployment
>> #endif
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#interop>
>> Interop
>> 
>> Swift's Objective-C compatibility enables developers to build
>> mix-and-match projects with a mixed-language codebase. This proposal
>> introduces a test to determine whether the Objective-C runtime is available
>> for use. This test uses only one option, objc, although it could
>> potentially expand to other scenarios, such as jvm, clr, and C++.
>> 
>> if (EnableObjCInterop)
>>    addPlatformConditionValue("_runtime", "_ObjC");else
>>    addPlatformConditionValue("_runtime", "_Native")
>> 
>> Use:
>> 
>> #if interop(objc)
>>    // Code that depends on Objective-C
>> #endif
>> 
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#simulator-conditions>Simulator
>> Conditions
>> 
>> Xcode simulators enable developers to test code on a wide range of
>> platforms without directly using physical devices. A simulator may not
>> offer the full suite of modules available with device deployment or provide
>> device-only hardware hooks like GPS. This proposal introduces a test for
>> simulator platform conditions, enabling developers to omit references to
>> unsupported features. It offers two options: simulator and device.
>> 
>> bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
>>    return tripleIsiOSSimulator(triple) ||
>>    tripleIsWatchSimulator(triple) ||
>>    tripleIsAppleTVSimulator(triple);
>> }
>> 
>> This proposal uses a targetEnvironment test as target or platform are too
>> valuable burn on this test.
>> 
>> Use:
>> 
>> #if targetEnvironment(simulator)
>>    // Code specific to simulator use
>> #endif
>> 
>> This condition test would reduce the fragility and special casing
>> currently in use:
>> 
>> #if (arch(i386) || arch(x86_64)) && os(iOS)
>>    print("Probably simulator")
>> #endif
>> 
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#impact-on-existing-code>Impact
>> on Existing Code
>> 
>> This proposal is additive and should not affect existing code. Some
>> developers may refactor code as in the case of the simulator/device test.
>> 
>> <https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#alternatives-considered>Alternatives
>> Considered
>> Not accepting this proposal
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> 
> 
> --94eb2c06f27acab4dd0536653f4f
> Content-Type: text/html; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable
> 
> <div dir="ltr">+1 on getting this proposal reviewed soon; I ran into the lack of TARGET_OS_SIMULATOR today (and was about to send an email, before I searched a little harder and found this).<div class="gmail_extra">
> <br><div class="gmail_quote">On Thu, Jun 16, 2016 at 9:49 AM, Erica Sadun via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution at swift.org" target="_blank">swift-evolution at swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>This is an omnibus conditional compilation block proposal. It is built out of Swift Evolution community requests and discussions dating back on various threads to the genesis of the list. </div><div><br></div><div><ul><li>This draft does not include tests for debug conditions. That was pitched under separate cover using runtime functions instead of conditional compilation blocks.</li><li>This draft does not include tests for OS versions, as that seems to be better addressed using the existing availability tests.</li><li>This draft is rewritten with respect to Jordan Rose&#39;s &quot;Rename &quot;build configurations&quot; to &quot;conditional compilation blocks&quot;&quot; <a href="https://github.com/apple/swift/commit/6272941c5cba9581a5ee93d92a6ee66e28c1bf13" target="_blank">swift commit</a> from 12 February (<a>rdar://problem/19812930</a>). </li><li>It is offered as an omnibus because all the tests fall under the same &quot;conditional compilation block&quot; umbrella. Using an omnibus reduces list traffic and demands on core team resources. It&#39;s understood that the proposal is likely to be accepted with modifications (or rejected as a whole) due to the multiple tests. </li></ul></div><div><br></div><div>-- Erica</div><div><br></div><div><div>gist: <a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298" target="_blank">https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298</a></div></div><div><br></div><div><h1 style="font-size:2.25em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.2;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255);margin-top:0px!important">Enhancing the Platform Configuration Test Suite for Conditional Compilation Blocks</h1><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li>Proposal: TBD</li><li>Author: <a href="http://github.com/erica" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">Erica Sadun</a></li><li>Status: TBD</li><li>Review manager: TBD</li></ul><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#introduction" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Introduction</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This proposal introduces additional configuration tests to differentiate platform conditions in conditional compilation blocks.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This proposal was first discussed on-list in the <a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/12140/focus=12267" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">[Draft] Introducing Build Configuration Tests for Platform Conditions</a> thread and then re-pitched in <a href="https://gist.github.com/erica/TBD" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">TBD</a>.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#note" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Note</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The term &quot;build configuration&quot; is subsumed by &quot;conditional compilation block&quot;. See <a href="https://github.com/apple/swift/commit/6272941c5cba9581a5ee93d92a6ee66e28c1bf13" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">this accepted patch</a></p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#motivation" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Motivation</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Testing for platform conditions is a typical developer task. Although some built-in features like <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">CFByteOrderGetCurrent</code>exist, it seems a natural match for Swift to introduce conditional compilation blocks specific to common platform conditions.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#current-art" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Current Art</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Swift currently supports the following platform configuration tests, defined in lib/Basic/LangOptions.cpp.</p><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li>The literals <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">true</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">false</code></li><li>The <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">os()</code> function that tests for <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">OSX, iOS, watchOS, tvOS, Linux, Windows, Android, and FreeBSD</code></li><li>The <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">arch()</code> function that tests for <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">x86_64, arm, arm64, i386, powerpc64, s390x, and powerpc64le</code></li><li>The <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">swift()</code> function that tests for specific Swift language releases, e.g. <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">swift(&gt;=2.2)</code></li></ul><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The following platform configuration test has been accepted in <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0075-import-test.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">SE-0075</a> but not yet implemented:</p><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li>The <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">canImport()</code> function that tests whether specific modules can be imported.</li></ul><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#detailed-design" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Detailed Design</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This proposal introduces several platform condition tests for use in conditional compilation blocks: endianness, bitwidth, vendor, objc interop, and simulator.</p><h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#endianness" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1.2" target="_blank"><u></u><u></u><u></u><u></u></a>Endianness</h3><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Endianness refers to the byte order used in memory. This proposal exposes endian test conditions, promoting them from private underscored names to public developer-referencable ones.</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(150,152,150)">// Set the &quot;_endian&quot; platform condition.</span>
>  <span style="color:rgb(167,29,93)">switch</span> (Target<span style="color:rgb(167,29,93)">.</span>getArch()) {
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::arm:
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::thumb:
>    addPlatformConditionValue(<span style="color:rgb(24,54,145)"><span>&quot;</span>_endian<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>little<span>&quot;</span></span>);
>    <span style="color:rgb(167,29,93)">break</span>;
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::aarch64:
>    addPlatformConditionValue(<span style="color:rgb(24,54,145)"><span>&quot;</span>_endian<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>little<span>&quot;</span></span>);
>    <span style="color:rgb(167,29,93)">break</span>;
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::ppc64:
>    addPlatformConditionValue(<span style="color:rgb(24,54,145)"><span>&quot;</span>_endian<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>big<span>&quot;</span></span>);
>    <span style="color:rgb(167,29,93)">break</span>;
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::ppc64le:
>    addPlatformConditionValue(<span style="color:rgb(24,54,145)"><span>&quot;</span>_endian<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>little<span>&quot;</span></span>);
>    <span style="color:rgb(167,29,93)">break</span>;
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::x86:
>    addPlatformConditionValue(<span style="color:rgb(24,54,145)"><span>&quot;</span>_endian<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>little<span>&quot;</span></span>);
>    <span style="color:rgb(167,29,93)">break</span>;
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::x86_64:
>    addPlatformConditionValue(<span style="color:rgb(24,54,145)"><span>&quot;</span>_endian<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>little<span>&quot;</span></span>);
>    <span style="color:rgb(167,29,93)">break</span>;
>  <span style="color:rgb(167,29,93)">case</span> llvm::Triple::ArchType::systemz:
>    addPlatformConditionValue(<span style="color:rgb(24,54,145)"><span>&quot;</span>_endian<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>big<span>&quot;</span></span>);
>    <span style="color:rgb(167,29,93)">break</span>;
>  <span style="color:rgb(167,29,93)">default</span>:
>    llvm_unreachable(<span style="color:rgb(24,54,145)"><span>&quot;</span>undefined architecture endianness<span>&quot;</span></span>);</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Under this proposal <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">_endian</code> is renamed to <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">endian</code> and made a public API.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Use:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal">#<span style="color:rgb(167,29,93)">if</span> endian(big) 
>    <span style="color:rgb(150,152,150)">// Big endian code</span>
> #endif</pre></div><h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#bitwidth" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1.2" target="_blank"><u></u><u></u><u></u><u></u></a>Bitwidth</h3><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Bitwidth describes the number of bits used to represent a number. This proposal introduces a bitwidth test with two options: 32 and 64. </p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Use:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal">#<span style="color:rgb(167,29,93)">if</span> bitwidth(<span style="color:rgb(0,134,179)">64</span>) 
>    <span style="color:rgb(150,152,150)">// 64-bit code</span>
> #endif</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">List members briefly discussed whether it was better to measure pointer width or the size of Int. William Dillon suggested renaming bitwidth to either <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">intwidth</code> or <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">intsize</code>. Brent Royal-Gordon suggests <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">intbits</code>. Alternatives include <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">bits</code>and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">bitsize</code>. This proposal avoids <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">wordbits</code> because of the way, for example, Intel ends up doing “dword”, “qword”, and so forth for backwards compatibility.</p><h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#vendor" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1.2" target="_blank"><u></u><u></u><u></u><u></u></a>Vendor</h3><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">A vendor describes the corporate or other originator of a platform. This proposal introduces a test that returns platform vendor, with one option at this time: <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Apple</code>. Apple deployment provides an umbrella case for wide range of coding norms that may not be available on non-Apple platforms. This &quot;family of targets&quot; provides a simpler test than looking for specific modules or listing individual operating systems, both of which provide fragile approaches to this requirement.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This call would be supported in Swift&#39;s source-code by the existing private <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">getVendor()</code> used in lib/Basic/LangOptions.cpp.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Use:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal">#<span style="color:rgb(167,29,93)">if</span> vendor(Apple) 
>    <span style="color:rgb(150,152,150)">// Code specific to Apple platform deployment</span>
> #endif</pre></div><h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#interop" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1.2" target="_blank"><u></u><u></u><u></u><u></u></a>Interop</h3><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Swift&#39;s Objective-C compatibility enables developers to build mix-and-match projects with a mixed-language codebase. This proposal introduces a test to determine whether the Objective-C runtime is available for use. This test uses only one option, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">objc</code>, although it could potentially expand to other scenarios, such as jvm, clr, and C++. </p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">if</span> (EnableObjCInterop)
>    <span style="color:rgb(121,93,163)">addPlatformConditionValue</span>(<span style="color:rgb(24,54,145)"><span>&quot;</span>_runtime<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>_ObjC<span>&quot;</span></span>);
> <span style="color:rgb(167,29,93)">else</span>
>    <span style="color:rgb(121,93,163)">addPlatformConditionValue</span>(<span style="color:rgb(24,54,145)"><span>&quot;</span>_runtime<span>&quot;</span></span>, <span style="color:rgb(24,54,145)"><span>&quot;</span>_Native<span>&quot;</span></span>)</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Use:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal">#<span style="color:rgb(167,29,93)">if</span> interop(objc) 
>    <span style="color:rgb(150,152,150)">// Code that depends on Objective-C</span>
> #endif</pre></div><h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#simulator-conditions" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1.2" target="_blank"><u></u><u></u><u></u><u></u></a>Simulator Conditions</h3><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Xcode simulators enable developers to test code on a wide range of platforms without directly using physical devices. A simulator may not offer the full suite of modules available with device deployment or provide device-only hardware hooks like GPS. This proposal introduces a test for simulator platform conditions, enabling developers to omit references to unsupported features. It offers two options: <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">simulator</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">device</code>.</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span style="color:rgb(167,29,93)">bool</span> <span style="color:rgb(121,93,163)">swift::tripleIsAnySimulator</span>(<span style="color:rgb(167,29,93)">const</span> llvm::Triple &amp;triple) {
>    <span style="color:rgb(167,29,93)">return</span> <span style="color:rgb(0,134,179)">tripleIsiOSSimulator</span>(triple) ||
>    <span style="color:rgb(0,134,179)">tripleIsWatchSimulator</span>(triple) ||
>    <span style="color:rgb(0,134,179)">tripleIsAppleTVSimulator</span>(triple);
> }</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This proposal uses a <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">targetEnvironment</code> test as <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">target</code> or <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">platform</code> are too valuable burn on this test.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Use:</p><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)"><code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">#if targetEnvironment(simulator)
>    // Code specific to simulator use
> #endif
> </code></pre><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This condition test would reduce the fragility and special casing currently in use: </p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal">#<span style="color:rgb(167,29,93)">if</span> (arch(i386) <span style="color:rgb(167,29,93)">||</span> arch(x86_64)) <span style="color:rgb(167,29,93)">&amp;&amp;</span> os(iOS) 
>    <span style="color:rgb(0,134,179)">print</span>(<span style="color:rgb(24,54,145)"><span>&quot;</span>Probably simulator<span>&quot;</span></span>)
> #endif</pre></div><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#impact-on-existing-code" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Impact on Existing Code</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This proposal is additive and should not affect existing code. Some developers may refactor code as in the case of the simulator/device test.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://gist.github.com/erica/c9c11b540a2439696b2f514c2ffc6298#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Alternatives Considered</h2><div style="margin-top:0px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255);margin-bottom:0px!important">Not accepting this proposal</div></div></div><br>_______________________________________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution at swift.org">swift-evolution at swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
> <br></blockquote></div><br></div></div>
> 
> --94eb2c06f27acab4dd0536653f4f--



More information about the swift-evolution mailing list