Slide 1

Slide 1 text

Contributing to Swift @ayanonagon

Slide 2

Slide 2 text

Hi! I’m Ayaka.

Slide 3

Slide 3 text

Workflow

Slide 4

Slide 4 text

June 30, 2016

Slide 5

Slide 5 text

#if DC_TARGET_MOBILE #import @compatibility_alias DCColor UIColor; #else #import @compatibility_alias DCColor NSColor; #endif

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

My job here is done. !

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Contributing to Swift @ayanonagon

Slide 15

Slide 15 text

0. Make sure you don’t need to write a proposal for it.

Slide 16

Slide 16 text

1.Check [email protected] archives 2.Email [email protected] 3.Get a ! from Swift team member 4.Get SR assigned to you.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Now what?

Slide 19

Slide 19 text

Fears 1.New codebases 2.Compilers 3.C++

Slide 20

Slide 20 text

I have no idea what I’m doing.

Slide 21

Slide 21 text

Proceed fearlessly!

Slide 22

Slide 22 text

0.5. Find a mentor My mentor: Robert (aka @_CodaFi)

Slide 23

Slide 23 text

1. Clone the repo github.com/apple/swift

Slide 24

Slide 24 text

1. Clone the repo 1.mkdir swift-source (or wherever) 2.cd into swift-source & clone repo 3../swift/utils/update-checkout --clone

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

2. Get CMake and Ninja

Slide 27

Slide 27 text

» CMake: manages build configurations » Ninja: does the building

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Homebrew ! brew install cmake ninja

Slide 31

Slide 31 text

3. Build the project

Slide 32

Slide 32 text

./swift/utils/build-script -x

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

build/Xcode-DebugAssert/swift-macosx-x86_64/ Swift.xcodeproj

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

4. Implement the thing

Slide 38

Slide 38 text

4. Implement the thing !

Slide 39

Slide 39 text

I really have no idea what I’m doing.

Slide 40

Slide 40 text

But… 1.There’s a lot of great existing example code. 2.What’s the worst that can happen?

Slide 41

Slide 41 text

Import @compatibility_alia s as typealias

Slide 42

Slide 42 text

“Where are similar things implemented?”

Slide 43

Slide 43 text

“Where are other Objective-C things pulled into Swift?”

Slide 44

Slide 44 text

ImportDecl.cpp

Slide 45

Slide 45 text

ImportDecl.cpp Decl * VisitObjCCompatibleAliasDecl(const clang::ObjCCompatibleAliasDecl *decl) { // Like C++ using declarations, name lookup simply looks through // Objective-C compatibility aliases. They are not imported directly. return nullptr; }

Slide 46

Slide 46 text

“What behaves similarly to @compatibility_ali as?”

Slide 47

Slide 47 text

“What also gets imported as typealias?”

Slide 48

Slide 48 text

typedef typedef NSString StringCheese;

Slide 49

Slide 49 text

! " ✨$ !"#$

Slide 50

Slide 50 text

… It builds. !

Slide 51

Slide 51 text

!?

Slide 52

Slide 52 text

!

Slide 53

Slide 53 text

4. Tests!

Slide 54

Slide 54 text

1.Write some Objective-C code. 2.Import it from Swift. 3.Make some assertions based on what you would expect.

Slide 55

Slide 55 text

1.Write some Objective-C code. import Foundation; @compatibility_alias StringCheese NSString;

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

1.Write some Objective-C code. ✅ 2.Import it from Swift. 3.Make some assertions based on what you would expect.

Slide 58

Slide 58 text

1.Import it from Swift import CompatibilityAlias

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

test/IDE/Inputs/custom-modules/module.map module CompatibilityAlias { header "CompatibilityAlias.h" export * }

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

1.Import it from Swift import CompatibilityAlias func dontMove(cheese: StringCheese) -> StringCheese { return cheese }

Slide 64

Slide 64 text

1.Write some Objective-C code. ✅ 2.Import it from Swift. ✅ 3.Make some assertions based on what you would expect.

Slide 65

Slide 65 text

lit testing It’s lit !

Slide 66

Slide 66 text

// RUN: rm -rf %t // RUN: mkdir -p %t // RUN: %build-clang-importer-objc-overlays // RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk-nosource) -I %t -I %S/Inputs/custom-modules // -print-module -source-filename %s -module-to-print=CompatibilityAlias > %t.printed.CompatibilityAlias.txt // RUN: FileCheck %s -check-prefix=PRINT -strict-whitespace < %t.printed.CompatibilityAlias.txt // RUN: %target-parse-verify-swift -sdk %clang-importer-sdk -I %S/Inputs/custom-modules -I %t %s // REQUIRES: objc_interop // PRINT: typealias StringCheese = NSString import CompatibilityAlias func dontMove(cheese: StringCheese) -> StringCheese { return cheese }

Slide 67

Slide 67 text

// PRINT: typealias StringCheese = NSString import CompatibilityAlias func dontMove(cheese: StringCheese) -> StringCheese { return cheese }

Slide 68

Slide 68 text

// RUN: rm -rf %t // RUN: mkdir -p %t // RUN: %build-clang-importer-objc-overlays // RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk-nosource) -I %t -I %S/Inputs/custom-modules // -print-module -source-filename %s -module-to-print=CompatibilityAlias > %t.printed.CompatibilityAlias.txt // RUN: FileCheck %s -check-prefix=PRINT -strict-whitespace < %t.printed.CompatibilityAlias.txt // RUN: %target-parse-verify-swift -sdk %clang-importer-sdk -I %S/Inputs/custom-modules -I %t %s // REQUIRES: objc_interop // PRINT: typealias StringCheese = NSString

Slide 69

Slide 69 text

“What also links with an Objective-C module?”

Slide 70

Slide 70 text

swift_newtype

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

Running the Tests

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

./llvm/utils/lit/lit.py -sv ./build/Ninja- DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/ --filter=compatibility_alias.swift

Slide 83

Slide 83 text

Tests Failed !

Slide 84

Slide 84 text

6. Debugging

Slide 85

Slide 85 text

LLDB

Slide 86

Slide 86 text

./llvm/utils/lit/lit.py -sv ./build/Ninja- DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/ --filter=compatibility_alias.swift

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

lldb -- /Users/ayanonagon/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc -frontend -target x86_64-apple-macosx10.9 -module-cache-path '/var/folders/g9/jwhqvm3x1rx65dtfhdrb00dc0000gn/T/swift-testsuite-clang-module-cacheK6GoT_' -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -parse -verify -disable-objc-attr-requires-foundation-module /Users/ayanonagon/swift-source/swift/test/IDE/compatibility_alias.swift -sdk -enable-source-import -sdk '/Users/ayanonagon/swift-source/swift/test'/Inputs/clang-importer-sdk -I '/Users/ayanonagon/swift-source/swift/test'/Inputs/clang-importer-sdk/swift-modules -I /Users/ayanonagon/swift-source/swift/test/IDE/Inputs/custom-modules -I /Users/ayanonagon/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/IDE/Output/compatibility_alias.swift.tmp /Users/ayanonagon/swift-source/swift/test/IDE/compatibility_alias.swift

Slide 90

Slide 90 text

!

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

» The secret life of types in Swift by Slava Pestov » Porting the Swift Runtime to Android by Brian Gesiak » Contributing to Open Source Swift by Jesse Squires » Contributing to Swift by Russ Bishop

Slide 96

Slide 96 text

» The secret life of types in Swift by Slava Pestov » Porting the Swift Runtime to Android by Brian Gesiak » Contributing to Open Source Swift by Jesse Squires » Contributing to Swift by Russ Bishop » Contributing to Swift by YOU <3

Slide 97

Slide 97 text

Proceed Fearlessly!

Slide 98

Slide 98 text

Thanks! ? → @ayanonagon