Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not run successfully #1

Open
funland opened this issue Oct 16, 2018 · 8 comments
Open

Can not run successfully #1

funland opened this issue Oct 16, 2018 · 8 comments

Comments

@funland
Copy link

funland commented Oct 16, 2018

The playground will stop before

self.view.addSubview(scnView)

in every playground

my iOS version is iOS12 and the playground is the latest
can you give me some advice ? thx

@ToshihiroGoto
Copy link
Owner

I do not have an IOS 12 version of the iPad,
but may be repaired with the following fixes.

Case 1:

let scene = SCNScene(named: "bg.scn")!

to

let scene = SCNScene()

Case 2:

scnView.translatesAutoresizingMaskIntoConstraints = false
self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat:
    "V:|[scnView]|", options: NSLayoutFormatOptions(rawValue: 0),
                        metrics: nil, views: ["scnView": scnView]))
self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat:
    "H:|[scnView]|", options: NSLayoutFormatOptions(rawValue: 0),
                        metrics: nil, views: ["scnView": scnView]))

to

scnView.translatesAutoresizingMaskIntoConstraints = false
self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat:
    "V:|[scnView]|", options: NSLayoutConstraint.FormatOptions(rawValue: 0),
                        metrics: nil, views: ["scnView": scnView]))
self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat:
    "H:|[scnView]|", options: NSLayoutConstraint.FormatOptions(rawValue: 0),
                        metrics: nil, views: ["scnView": scnView]))

In Case 1, resource acquisition failed.
In Case 2, change Swift's syntax.

@funland
Copy link
Author

funland commented Oct 16, 2018

Thanks for you kindly reply , it looks the problem happens while the program will add the scnView to the mainview as a subview and it will be always crashed .
By the way , I 've tried the code above and it not works .

@funland
Copy link
Author

funland commented Oct 16, 2018

When I run it on the mac , it noticed :
error: 09_SceneGraph.playground:134:109: error: 'NSLayoutFormatOptions' has been renamed to 'NSLayoutConstraint.FormatOptions'
self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[scnView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["scnView": scnView]))
^~~~~~~~~~~~~~~~~~~~~
NSLayoutConstraint.FormatOptions

maybe I can give a try ,thank you!

@funland
Copy link
Author

funland commented Oct 16, 2018

It warns me "Class NSLayoutConstraint haven't member FormatOptions" in iPad , but it can work on Xcode perfectly , wired .

@ToshihiroGoto
Copy link
Owner

Thank you for your reply.
When I tried it, the new Swift Playground on iOS 11 crashes in mainview.

Because it works with Xcode, it may be a bug in Swift Playground on iPad.
(official AR sample on the iPad works with SceneKit using the storyboard)

@funland
Copy link
Author

funland commented Oct 16, 2018

OK , in some playground change NSLayoutFormatOptions can let the playground work correctly , but 09_SceneGraph is still has problem .
Thanks for your reply , you do an excellent job !

@funland
Copy link
Author

funland commented Oct 18, 2018

update: I think some crash is caused by out of memory , when I remove some node , the program can run successfully , but sometimes it can not run even I just change the background color

@ToshihiroGoto
Copy link
Owner

If memory is a problem,
it may work with "PlaygroundPage.current.liveView = scnView" without using UIViewController.

Or set the size of the SCNView to remove the constraint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants