GithubHelp home page GithubHelp logo

apple / swift-xcode-playground-support Goto Github PK

View Code? Open in Web Editor NEW
279.0 133.0 64.0 528 KB

Logging and communication to allow Swift toolchains to communicate with Xcode.

License: Apache License 2.0

Swift 91.98% Objective-C 4.31% Python 3.55% C 0.17%

swift-xcode-playground-support's Introduction

Swift Xcode Playground Support

Welcome to Swift Xcode Playground Support!

The Xcode Playground Support project enables Xcode playgrounds to communicate their results in a displayable fashion, and to control some aspects of playground behavior. In order to use a custom build of Swift with Xcode the frameworks described below must be compiled with the new Swift compiler and included in a toolchain. Snapshots will include this project to deliver everything required. Just download, install, and select the toolchain to work with the corresponding Swift features in Xcode playgrounds.

Contents

The project contains these frameworks:

  • PlaygroundSupport. This framework defines API that may be explicitly referred to by playground code to communicate with Xcode. For example: this is typical for playgrounds that identify a particular view to display live for animation or interaction, and when playgrounds automatically move between pages when defined criteria are met. A legacy XCPlayground version is also provided for compatibility with older playgrounds.

  • PlaygroundLogger. This project is used implicitly to record values of interest on a line-by-line basis and communicate them to Xcode. Calls are automatically injected into playground code so no explicit reference is required.

Documentation

PlaygroundSupport offers a limited set of APIs for communicating specific requests to Xcode and should be self-explanatory.

PlaygroundLogger is more complex and includes documentation on the API in PlaygroundLogger/Documentation/LoggerAPI.md and communication format in PlaygroundLogger/Documentation/LoggerFormat.md.

Working with Xcode Playground Support

Getting Started

The standard Swift build script included in the Swift repository automatically pulls and builds the Xcode Playground Support source.

Getting Sources Directly

Via HTTPS For those checking out sources as read-only, HTTPS works best:

git clone https://github.com/apple/swift-xcode-playground-support.git
cd swift-xcode-playground-support

Via SSH For those who plan on regularly making direct commits, cloning over SSH may provide a better experience (which requires uploading SSH keys to GitHub):

git clone [email protected]:apple/swift-xcode-playground-support.git
cd swift-xcode-playground-support

Building Individual Frameworks

Inside Xcode

PlaygroundSupport and PlaygroundLogger can be built individually building the respective Xcode projects. It is critical that they're built using the Swift compiler they're intended to be used with, which can be achieved by building, installing, and selecting the corresponding toolchain in the Xcode UI.

Both projects contain universal targets that build all applicable products. The target in PlaygroundLogger is named All Platforms Logger; in PlaygroundSupport it is named AllProducts.

For testing purposes, PlaygroundLogger requires the presence of the StdlibUnittest module which is part of Swift. This can be overriden either by using the BuildAndIntegration configuration, or via the NOSTDLIBUNITTEST conditional compilation directive.

Command-Line Builds

Command-line builds using xcodebuild require setting the SWIFT_EXEC environment variable to a fully-qualified path for the corresponding Swift compiler.

Contributing to Swift Xcode Playground Support

Swift Xcode Playground Support changes may be required as the Swift language evolves. As with other aspects of Swift, contributions are welcomed and encouraged! Please see the Contributing to Swift guide.

To be a truly great community, Swift.org needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.

To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the Code of Conduct.

swift-xcode-playground-support's People

Contributors

aschwaighofer avatar atrick avatar codafi avatar cwakamo avatar eeckstein avatar egranata avatar gribozavr avatar harlanhaskins avatar jckarter avatar kant avatar karwa avatar lattner avatar milseman avatar moiseev avatar sampage avatar shahmishal avatar slavapestov avatar springsup avatar tkremenek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swift-xcode-playground-support's Issues

[SR-12514] PlaygroundSupport module is not compiled with Swift 5.2

Previous ID SR-12514
Radar rdar://problem/62201629
Original Reporter yak (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: 6e47f6fa79f49db804fb0fe5b1e47f02

Issue Description:

I am trying to use the Swift playground book template from here

https://developer.apple.com/download/more/?=Swift%20Playgrounds%20Author%20Template

This template does not compile. I get the error when import PlaygroundSupport

Module compiled with Swift 5.1 cannot be imported by the Swift 5.2.1 compiler

I found the playgroundsupport framework code here

https://github.com/apple/swift-xcode-playground-support

I can compile this code but unable to import this binary framework into playground support template.

Please help.

[SR-8196] Xcode Beta 3: Fatal error: Only BidirectionalCollections can be advanced by a negative amount

Previous ID SR-8196
Radar rdar://problem/41976357
Original Reporter [email protected] (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode Beta 3

MacBook Air

OS X High Sierra

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: d9ee1a3d8bd5234232986876e8fce714

Issue Description:

When I create playground with the code below, I get the following error when running.

Fatal error: Only BidirectionalCollections can be advanced by a negative amount

It seems editing parts of the text out can cause the error to go away. I don't see how this code goes backward in the collection. I was able to make it happen when in an App as well as a playground.

If I pass the string in as a parameter to the function I also don't get the error.

let text = """

What was Bruce Lee’s cause of death? Matthew Polly, the author of the excellent new biography “Bruce Lee: A Life,” has a strange, sad, and entirely plausible explanation.

Polly digs deep into how Lee died in our new “Shoot This Now” podcast, which you can listen to on iTunes or here:

The cause of Bruce Lee’s death is one of the most confounding questions in his spectacular life: How did a 32-year-old man who exercised constantly and was known for toned physique suddenly die? Misinformation abounds.

Now Playing: Fitness Nut Shows Off His Impressive Balancing Skills

Fitness nut Travis Horn showed off his impressive balancing skills while on top of multiple dumbbells and wine glasses. Travis takes balance to a whole new level and claims his skills are “a mixture between god’s power and Bruce lee’s mindset.” Credit: The balance guru via Storyful

Media: Storyful

Also Read: 'Jaws 2' Was Almost 'Saving Private Ryan' With Sharks (Podcast)

Google “How did Bruce Lee die” and you’ll receive, thanks to Quora, the most common answer: cerebral edema. A cerebral edema is an excess accumulation of fluid in the brain that can cause seizures, coma, and even respiratory arrest.

Lee collapsed on May 10, 1973, while recording dialogue for his film, “Enter the Dragon.” He was taken to a Hong Kong hospital where doctors diagnosed him with cerebral edema. So it is probably not surprising that when Lee died suddenly on July 20, 1973, another Hong Kong hospital reported that cerebral edema was the cause of death.

A Hong Kong inquest later found Lee’s cause of death to be “death by misadventure,” a type of accidental death that involves a degree of bad luck. That finding included the possibility that one factor in Lee’s death was his decision to take a drug called Equagesic, which contained aspirin and a tranquilizer.

Also Read: How Bruce Lee Used Kung Fu to Beat Bigotry (Podcast)

But Polly argues persuasively on our podcast that Lee’s real cause of death may have been overheating. And his overheating may have been intensified by a decision to have his “sweat glands removed from his armpits because he felt his dripping pits looked bad onscreen,” as Polly writes in his book. “Without these sweat glands, his body would have been less able to dissipate heat.”

Yes: It is possible to have the sweat glands of the armpits removed. But Polly argues it was a dangerous decision for someone who exercised as intensely as Lee did.

Overheating is better understood today than it was in 1973. But it is “the third-most-common killer of athletes and rises to first during the hottest months of summer,” Polly explains. Lee died on the hottest day of July 1973.

Also Read: About That Drake Cultural Appropriation Debate... (Podcast)

Polly’s book carefully unpacks the rumors and misinformation around Lee — which were fed by a decision to remove his body from the home of his mistress, Betty Ting Pei, to avoid upsetting his family.

If Lee did die, in part, because of the decision to remove the sweat glands from his armpits, it would be a tragic turn in his lifelong quest to excel. Lee worked hard for his entire life to overcome every obstacle, first to impress his father and later to provide for his wife, Linda, and their two children. He was relentlessly competitive, always seeking an edge, and always willing to sacrifice to succeed.

He traveled to Hong Kong to make films after Hollywood couldn’t overcome its racism to make him a leading man in an American film. He became the greatest martial arts star in the world, against unbelievable odds.

His death cut short a courageous struggle for success. And the mystery around it has contributed to the fascination with his too-short life.

the end.

"""

//let text1 = """

// Hello world how are you today.

// His death cut short a courageous struggle for success. And the mystery around it has contributed to the fascination with his too-short life.

//

// """

let nibFile = NSNib.Name("MyView")

var topLevelObjects : NSArray?

let words = text.split(separator: " ")

let counts = words.reduce(into: [String: Int]()) {

$0\[String($1), default: 0\] += 1

}

counts

print(words)

Bundle.main.loadNibNamed(nibFile, owner:nil, topLevelObjects: &topLevelObjects)

let views = (topLevelObjects as! Array<Any>).filter { $0 is NSView }

// Present the view in Playground

PlaygroundPage.current.liveView = views[0] as! NSView

In-app asset validation issue

Description:
While performing application asset validation, I observed the following issues:

Error 1: Missing Info.plist Value

ID: 1d4a51a3-41f6-4d0b-84e0-42ce5d1292ad
Description: The application is generating the following validation error: "Missing Info.plist Value. Your app's Info.plist must contain a string value for the 'CFBundleIcons.CFBundlePrimaryIcon' key."
Error 2: Missing Info.plist Key

ID: 38a7e929-2090-41c3-afe9-89952d7b0df9
Description: Additionally, the app is also giving the error: "Missing Info.plist Key. Your app's Info.plist must contain the 'TVTopShelfImage.TVTopShelfPrimaryImageWide' key."

Platform: iOS/tvOS
Xcode Version: 15.2

[SR-5665] Simple nested function not working

Previous ID SR-5665
Radar None
Original Reporter ShamoX (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 8.3.3

Switch 4 (Snapshot installed today)

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: fd8fb2bfdc52dac46e8098587cf86756

Issue Description:

Trying the guided tour and any nested function crashes the playground execution.

[SR-3047] i want to Create an application same this

Previous ID SR-3047
Radar None
Original Reporter khalid1800 (JIRA User)
Type Improvement
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Improvement
Assignee None
Priority Medium

md5: c251726e8f838e16d231d0f33232cf4f

Issue Description:

Hello

i want to creat an app
i explain what i want

one tableView
i foundation 5 category an exmple
any category i want to special tableview
and any tableview i add categoryies and link to view
Controller

i want same this nare
https://itunes.apple.com/sa/app/mjlt-tbybk-alkhas-thtm-bshtk/id428483536?mt=8

how to wirte code

[SR-13896] Confusing error message when assigning an optional UIImage as a state property

Previous ID SR-13896
Radar rdar://60600911
Original Reporter frostra1n (JIRA User)
Type Bug

Attachment: Download

Environment

macOS Catalina 10.15.7

Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)

Xcode 12.1

Additional Detail from JIRA
Votes 0
Component/s Compiler, Xcode Playground Support
Labels Bug, PropertyWrappers
Assignee None
Priority Medium

md5: f20a4f1b3d227c0ef91b2fdd21421924

Issue Description:

I'm working on project that uses both UIKit and SwiftUI and I found a scenario that shows a confusing error when assigning a `UIImage?` in a struct initializer. The error is:

Variable 'self.asPreview' used before being initialized

And this is the code that produces the error:

import SwiftUI
import UIKit

struct BookView: View {
    let asPreview: Bool
    @State var image: UIImage?

    init(image: UIImage?, asPreview: Bool = false) {
        self.image = image         
        self.asPreview = asPreview
    }

    var body: some View {
         Group {}
     }
 }

The error is pointed in line 9 right under the equal sign ("self.image = image"), but actually that line assigns a different struct property, so it's a little bit confusing.

What it could be happening is that a different type of value is being assigned to the image variable, so the error message that should be shown instead could be something related of assigning an `UIImage?` to a `State<UIImage?>` variable.

The code above can be used in Xcode playground to reproduce the issue. I've attached a screenshot reproducing the bug.

[SR-3613] PlaygroundLogger test failures NSImageLogging: expected optional to be non-nil

Previous ID SR-3613
Radar rdar://29970085
Original Reporter @aschwaighofer
Type Bug
Status Reopened
Resolution
Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: 54cf922917ec73340aa29ee2967651e5

Issue Description:

https://ci.swift.org/job/oss-swift-incremental-RA-osx/7872

[ RUN ] PlaygroundLogger test suite.NSImageLogging
stdout>>> check failed at /Users/buildnode/jenkins/workspace/oss-swift-incremental-RA-osx/swift-xcode-playground-support/PlaygroundLogger/PlaygroundLogger/TestInfrastructure.swift, line 181
stdout>>> expected optional to be non-nil
stderr>>> fatal error: unexpectedly found nil while unwrapping an Optional value: file /Users/buildnode/jenkins/workspace/oss-swift-incremental-RA-osx/swift-xcode-playground-support/PlaygroundLogger/PlaygroundLogger/TestInfrastructure.swift, line 182
stderr>>> Current stack trace:
stderr>>> 0 libswiftCore.dylib 0x0000000105755bb0 swift_reportError + 125
stderr>>> 1 libswiftCore.dylib 0x0000000105776760 _swift_stdlib_reportFatalErrorInFile + 100
stderr>>> 2 libswiftCore.dylib 0x000000010553d9d0 (_assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1).(closure #1).(closure #1) + 143
stderr>>> 3 libswiftCore.dylib 0x000000010571a5d0 partial apply for (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1).(closure #1).(closure #1) + 112
stderr>>> 4 libswiftCore.dylib 0x000000010553ce90 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 342
stderr>>> 5 libswiftCore.dylib 0x000000010571a510 partial apply for (_assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1).(closure #1) + 144
stderr>>> 6 libswiftCore.dylib 0x000000010553ce90 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 342
stderr>>> 7 libswiftCore.dylib 0x00000001056b9490 partial apply for (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1) + 154
stderr>>> 8 libswiftCore.dylib 0x000000010553ce90 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 342
stderr>>> 9 libswiftCore.dylib 0x000000010553cd40 _fatalErrorMessage(StaticString, StaticString, file : StaticString, line : UInt, flags : UInt32) -> Never + 126
stderr>>> 10 PlaygroundLogger 0x0000000105450770 static TestHelpers.unwrapOrFail<A> (A?) -> A + 759
stderr>>> 11 PlaygroundLogger 0x00000001054266a0 NSImageLoggingTestCase.doTest() -> () + 369
stderr>>> 12 PlaygroundLogger 0x0000000105426fe0 protocol witness for TestCase.doTest() -> () in conformance NSImageLoggingTestCase + 47
stderr>>> 13 PlaygroundLogger 0x0000000105450710 (playground_logger_test() -> ()).(closure #1) + 70
stderr>>> 14 libswiftStdlibUnittest.dylib 0x00000001061d1ae0 specialized TestSuite._runTest(name : String, parameter : Int?) -> () + 521
stderr>>> 15 libswiftStdlibUnittest.dylib 0x000000010616e230 _childProcess() -> () + 2141
stderr>>> 16 libswiftStdlibUnittest.dylib 0x00000001061741a0 runAllTests() -> () + 717
stderr>>> 17 PlaygroundLogger 0x000000010544e290 playground_logger_test() -> () + 7981
stderr>>> 18 PlaygroundLogger_TestDriver 0x0000000105408efb <unavailable> + 3835
stderr>>> 19 libdyld.dylib 0x00007fff95eea5ac start + 1
stderr>>> CRASHED: SIGILL
the test crashed unexpectedly
[ FAIL ] PlaygroundLogger test suite.NSImageLogging

[SR-10838] Recent development toolchains not compatible with Xcode Playgrounds

Previous ID SR-10838
Radar None
Original Reporter @vguerra
Type Bug
Environment

$> uname -a
Darwin C02X63G9JHD3 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

$> xcrun -show-sdk-path -sdk macosx
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: 13b90e50d617e699b0bcd75eb792ba57

Issue Description:

When downloading a recent development toolchain and trying to use it in Xcode Playgrounds the following error is displayed:

"The active toolchain is not compatible with playgrounds. PlaygroundLogger.framework could not be loaded."

I found a post in Apple developer forums dating end of March : https://forums.developer.apple.com/thread/115141

It seems the problem has been there for some weeks now.

[SR-9783] Playground live view doesn't render radial CAGradientLayer correctly

Previous ID SR-9783
Radar None
Original Reporter kerrmarin (JIRA User)
Type Bug

Attachment: Download

Environment

2018 13" macbook pro, OSX Mojave 10.14.3 (18D42)

Xcode Version 10.1 (10B61)

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: bc7fb19603f6a839c3e7f241cf714cb9

Issue Description:

With a simple playground showing a radial gradient, playgrounds doesn't display the correct gradient (see attached screenshot)

import UIKit
import PlaygroundSupport
let colors: [UIColor] = [.blue, .orange]
let view = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 300, height: 300)))
view.backgroundColor = .white
let gradientLayer = CAGradientLayer()
gradientLayer.frame = view.bounds
gradientLayer.colors = colors.map { $0.cgColor }
gradientLayer.type = .radial
view.layer.addSublayer(gradientLayer)
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = view

Expected:

The live view will show the correct gradient

Actual:
A weird visual artifact (correct colours but not the gradient)

[SR-8771] Object deallocation in Xcode 10 Playground does not work

Previous ID SR-8771
Radar rdar://problem/44513925
Original Reporter @DevAndArtist
Type Bug
Environment

Xcode 10 GM

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: ca7b422a0aafdb7e1527b0c4b35306bd

Issue Description:

Playgroud does proceed with deallocation of objects when expected in Xcode 10 GM.

class Ref {
  weak var obj: Obj?
}

class Obj {
  deinit {
    print("deinit")
  }
}

var obj: Obj? = Obj() // Never deallocates in Xcode 10 Playground
let ref = Ref()
ref.obj = obj
obj = nil

Discussion in the forums:

https://forums.swift.org/t/is-this-a-swift-4-2-regression-object-not-deallocating/16136

[SR-3347] Playground as a data analysis console

Previous ID SR-3347
Radar None
Original Reporter chung (JIRA User)
Type Improvement
Status Reopened
Resolution
Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Improvement
Assignee None
Priority Medium

md5: 8f2d38468d8eaf679426fb6369264154

Issue Description:

It would be interesting to see playground used like ipython. Have anyone thought about this? Does swift have a strategy towards that direction?

[SR-3497] NSTextAttachment with image crashes Playground

Previous ID SR-3497
Radar None
Original Reporter mohd-akram (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 1
Component/s Xcode Playground Support
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: 498244dba60ce5c2cccd197dfd32a6f5

Issue Description:

The following code crashes Xcode when run in Playground:

import UIKit

let image = UIImage()
let attachment = NSTextAttachment()
attachment.image = image
let string = NSAttributedString(attachment: attachment)

Crash log attached.

[SR-9673] Swift playgrounds do not show when a value is optional

Previous ID SR-9673
Radar None
Original Reporter @mbrandonw
Type Improvement

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Improvement
Assignee None
Priority Medium

md5: e0cc4660581b0838a1edca581e173d81

Issue Description:

Optional values are rendered in the sidebar without an indication that they are optional. This leads to confusion as to what value a variable truly holds. The optionality of the value should be displayed somehow, perhaps as:

Optional(1)

It does correctly show `nil` when the value is `nil`.

[SR-8349] CustomStringConvertible and rethrows in Playgrounds

Previous ID SR-8349
Radar rdar://problem/41460357
Original Reporter Tony Y. (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

macOS High Sierra

Xcode 9.4.1 (9F2000), Xcode 10 beta 1 to 6, Xcode 10 GM seed, and Xcode 10.0 (10A255)

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug, RunTimeCrash
Assignee Tony Y. (JIRA)
Priority Medium

md5: f44e7e48b8a3f02ecbd930690a6ba11c

Issue Description:

The following code crashes Xcode when run in Playground:

struct BuggyStruct {
    func bug(_ body: (Int) throws -> Void) rethrows { try body(0) }
}
extension BuggyStruct : CustomStringConvertible {
    var description: String {
        var text = "Bug"
        self.bug({ element in
            text += "\(element)"
        })
        return text
    }
}
do {
    print(BuggyStruct())
}

I got error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=2, address=0x7ffeeeb54ff8). The computed variable description was used many times (more than 1000 times as shown in the side bar of Playgrounds). When using throws instead of rethrows and adding try! at the throwing function self.bug(...), I got no error.

Swift Forums threads

[SR-9079] Playgrounds in "Manually Run" mode doesn't support computed variables

Previous ID SR-9079
Radar rdar://problem/45588366
Original Reporter @HarshilShah
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Xcode 10 (10A255) Playgrounds

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: 6dc84062c35c2cac81188c23b749b16c

Issue Description:

When in "Manually Run" mode, Playgrounds doesn't support computed variables. The declaration is interpreted as separate from the definition, and since the REPL doesn't allow for declarations without initial declarations, computed variables produce crashes.

The following code:

import UIKit

let controller = UIViewController()
var view: UIView { return controller.view }

crashes with the following error message:

error: Scratchpad.playground:6:1: error: variables currently must have an initial value when entered at the top level of the REPL

[SR-14633] Generic structs sometimes cause a crash when using existential types (only in Xcode Playground)

Previous ID SR-14633
Radar rdar://problem/78224316
Original Reporter fermion17 (JIRA User)
Type Bug
Environment

iMac (Retina 5K, 27-inch, 2019), macOS 11.3, Xcode 12.5

MacBook Pro (Retina, 15-inch, Mid 2015), macOS 10.15.7, Xcode 12.3

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: e78de01bb76e1378e78ad689d5720824

Issue Description:

Generic structs S<T> cause a crash when:

  • it contains a field with type T?

  • it is specialized by an existential type, e.g. S<P> where P is a protocol.

For example, the following code in Xcode Playground causes a crash.

protocol P {}
struct S<T> {
    let field: T? = nil
}
let x = S<P>() // error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT).

This issue only occurs in Xcode Playground.

[SR-11959] Segmentation fault: 11

Previous ID SR-11959
Radar rdar://problem/58438123
Original Reporter ranudhh (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s CodeCompletion, Compiler, Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: 6a5951bc10f45ae0016ba4db480784b2

Issue Description:

I am getting bug as Segmentation fault: 11 in my Xcode

[SR-9771] Playgrounds not Trapping during Bad Access

Previous ID SR-9771
Radar rdar://33820622
Original Reporter SafelySwift (JIRA User)
Type Bug

Attachment: Download

Environment

![](https://raw.githubusercontent.com/SafelySwift/images/master/Screen%20Shot%202019-01-26%20at%204.31.20%20PM.png)

Additional Detail from JIRA
Votes 0
Component/s Xcode Playground Support
Labels Bug
Assignee None
Priority Medium

md5: 795ff7ff2b7dd30d73ddefbcd99f8fd5

Issue Description:

As per this Swift Forums topic, the following code should trap due to overlapping read/write access.

var stepSize = 1

func increment(_ number: inout Int) {
    number += stepSize
}

increment(&stepSize)

As specified on the docs,

> The read and write accesses refer to the same memory and they overlap, producing a conflict.

However, I put the code in a playground like such:

![](https://github.com/SafelySwift/images/blob/master/Screen%20Shot%202019-01-26%20at%204.30.06%20PM.png)

And nothing happens

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.