kodika / MutataApp

49 stars 9 forks source link

Swift compiler can't find CGFloat #4

Closed OmerFlame closed 2 years ago

OmerFlame commented 2 years ago

When I try to compile a simple app that uses a CGFloat explicitly, like this:

let cgFloat = CGFloat(255)

The compiler tells me that it doesn't know what a CGFloat is (yes, I imported UIKit).

But when a function takes a parameter of type CGFloat (a function that is defined outside of my program, e.g. inside UIKit) and I give it a parameter that is not a CGFloat, the compiler suddenly tells me that the function requests a CGFloat and not something else.

kostassite commented 2 years ago

Could you try to

import Foundation
import UIKit

at the top of your file?

OmerFlame commented 2 years ago

@kostassite it works! Though, now I am facing another issue: When I try to modify the sample app by adding my own view controller to the list of demo view controllers (all in the same fashion as the other view controllers) and I set all of the outlets and everything and then try to show the view controller itself, it just gives me a blank view controller, without any of the layout and components I put in the XIB file.

kostassite commented 2 years ago

When you add or change an image or a .xib, you need to rerun the scripts/18-CopyIosImagesAndXibs.sh or manually add the file in the ./copiedFromPackage/assets folder

OmerFlame commented 2 years ago

I am just running scripts/100-UpdateAndRun, I believe that should have the exact same effect?

OmerFlame commented 2 years ago

I can confirm that the XIB file exists in the folder, it compiles successfully and it doesn't show it at all when displaying it. I tried it on macOS and iOS and it works properly.

kostassite commented 2 years ago

Yeah. It should. If you do any change in the current VCs, do you see the difference?

iOS and macOS take the files for different path

OmerFlame commented 2 years ago

I am running the app on macOS using Mac Catalyst and the paths don't matter at all.

OmerFlame commented 2 years ago

Well... now I am having issues turning the emulator on at the moment.

sigh

This will take bit.

kostassite commented 2 years ago

I am running the app on macOS using Mac Catalyst and the paths don't matter at all.

I didn't mean between iOS and macOS. These are the same. I mean that Mutata uses a copy of these files. You can see that the files do exist also in ./build/iOSFiles/copiedFromPackage/assets

OmerFlame commented 2 years ago

Alright.

When I try to change an existing thing (the color of the top view in the Segmented Control demo), it changes in the Android app.

However, when I add a segmented control to the bottom of the view controller (without any container view, because it shouldn't require one), it doesn't show up at all.

kostassite commented 2 years ago

Could you add just a red UIView and set its constraints for top and left, and for width and height. Or try set the constraints for the Segmented. In Android, you always need to set the constraints as they are not autogenerated like in iOS.

OmerFlame commented 2 years ago
Screen Shot 2022-03-14 at 12 18 44

Notice the segmented control at the bottom appearing in Mac Catalyst, but not appearing at all in the Android emulator (both have the latest XIB files).

OmerFlame commented 2 years ago

The segmented control already has its positioning constraints as well as leading and trailing constraints (top, leading and trailing)!

(EDIT: fixed typo)

OmerFlame commented 2 years ago

Closing this issue.

I fixed it by actually manually setting a height constraint to the segmented control. Sorry for bugging you!