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

Import failure of CGFloat in LineManager class #37

Closed
irangareddy opened this issue Dec 7, 2022 · 1 comment
Closed

Import failure of CGFloat in LineManager class #37

irangareddy opened this issue Dec 7, 2022 · 1 comment
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@irangareddy
Copy link

Summary:

Import failure of CGFloat in LineManager class, causing fastlane build error while compiling WrappingHStack.swift

Steps to reproduce:

Create a new Xcode project.

Add the following code to a file in the project:

import Foundation

enum Stage {
    case child
    case boyhood
    case adult
    case old
    
    var ageBar: CGFloat {
        switch self {
        case .child:
            return 0.2
        case .boyhood:
            return 0.4
        case .adult:
            return 0.8
        case .old:
            return 1.0
        }
    }
}

Build and run the project.

Expected result:

The project builds and runs without any errors.

Actual result:

The project fails to build with the following error:

Cannot find type 'CGFloat' in scope

Code that causing an issue with respect to WrappingHStack. reference

import Foundation

/// This class is in charge of calculating which items fit on which lines.
/// It should be reused whenever possible.
class LineManager {
    private var contentManager: ContentManager!
    private var spacing: WrappingHStack.Spacing!
    private var width: CGFloat!
}

Version Details

{
        "package": "WrappingHStack",
        "repositoryURL": "https://github.com/dkk/WrappingHStack.git",
        "state": {
          "branch": null,
          "revision": "3cc84e786aa996da32f476d89dab4e02d30ce691",
          "version": "2.1.3"
   }
}

Notes:

It seems that the import of the Foundation module is not sufficient to use the CGFloat type.

To fix this issue, you can import the CoreGraphics module, which defines the CGFloat type, by adding the following line to the top of the file:

import CoreGraphics

After importing the CoreGraphics module, the CGFloat type should be available and the project should build and run without any errors.

@irangareddy irangareddy added bug Something isn't working help wanted Extra attention is needed labels Dec 7, 2022
@dkk dkk self-assigned this Dec 7, 2022
@dkk dkk closed this as completed in 1975ea1 Dec 7, 2022
@irangareddy
Copy link
Author

Thank you @dkk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants