Swift5.1 Error -- Crash #1018

Closed
opened 2020-06-11 22:54:49 -07:00 by Aynnor · 3 comments
Aynnor commented 2020-06-11 22:54:49 -07:00 (Migrated from github.com)

I want to bring yogakit to my project

But it will lead to crash, I don't know why

Tool Version
Xcode 11.5
CocoaPods 1.9.2
Podfile platform: ios 9.0
YogaKit 13.0.1
//Xcode Swift5.1 Project ViewController add this code, but Layout cannot be displayed, Even crash 

func createUI() {
        
        let fontNames = UIFont.fontNames(forFamilyName: "PingFang HK")
        print(fontNames)
        
        for i in 0..<fontNames.count {
            let label = UILabel()
            label.text = "the \(i) label.."
            label.font = UIFont.init(name: fontNames[i], size: 20)
            view.addSubview(label)
            
            label.configureLayout { (layout) in
                layout.isEnabled = true
            }
        }
        
        view.configureLayout { (layout) in
            layout.isEnabled = true
            layout.flexDirection = .column
            layout.justifyContent = .flexStart
            layout.alignItems = .flexStart
            layout.paddingLeft = 15
        }
        
        view.yoga.applyLayout(preservingOrigin: false)
}

Message

Xcode Crash Image

# I want to bring yogakit to my project # But it will lead to crash, I don't know why Tool | Version ---|--- Xcode | 11.5 CocoaPods | 1.9.2 Podfile | platform: ios 9.0 YogaKit | 13.0.1 ```swift //Xcode Swift5.1 Project ViewController add this code, but Layout cannot be displayed, Even crash func createUI() { let fontNames = UIFont.fontNames(forFamilyName: "PingFang HK") print(fontNames) for i in 0..<fontNames.count { let label = UILabel() label.text = "the \(i) label.." label.font = UIFont.init(name: fontNames[i], size: 20) view.addSubview(label) label.configureLayout { (layout) in layout.isEnabled = true } } view.configureLayout { (layout) in layout.isEnabled = true layout.flexDirection = .column layout.justifyContent = .flexStart layout.alignItems = .flexStart layout.paddingLeft = 15 } view.yoga.applyLayout(preservingOrigin: false) } ``` ## Message ![Xcode Crash Image](https://raw.githubusercontent.com/Aynnor/YogaKitDemo/master/xcodeImage.png)
Aynnor commented 2020-06-12 18:29:02 -07:00 (Migrated from github.com)

feeling problem is on the SceneDelegate

feeling problem is on the `SceneDelegate`
cntrump commented 2020-08-12 23:56:37 -07:00 (Migrated from github.com)

Because width or height is nagative, fixed in my PR: https://github.com/facebook/yoga/pull/1026

YGLayout.m

.size =
           {
               .width = MAX(YGRoundPixelValue(bottomRight.x) -
                   YGRoundPixelValue(topLeft.x), 0),
               .height = MAX(YGRoundPixelValue(bottomRight.y) -
                   YGRoundPixelValue(topLeft.y), 0),
           },
Because width or height is nagative, fixed in my PR: https://github.com/facebook/yoga/pull/1026 YGLayout.m ```objc .size = { .width = MAX(YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x), 0), .height = MAX(YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y), 0), }, ```
NickGerleman commented 2023-06-13 08:09:10 -07:00 (Migrated from github.com)

We are deprecating YogaKit as part of the Yoga 2.0 release. We are still going to release a new revision based on the current state of the repo, but won't be accepting new contributions, since we are going to be removing it from the repo after.

We are deprecating YogaKit as part of the Yoga 2.0 release. We are still going to release a new revision based on the current state of the repo, but won't be accepting new contributions, since we are going to be removing it from the repo after.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1018
No description provided.