my-swift-projects icon indicating copy to clipboard operation
my-swift-projects copied to clipboard

Missing import in Align.swift

Open kimasendorf opened this issue 7 years ago β€’ 20 comments

I added the swift-utils as submodule to a test project. When I simply try to compile it without writing any additional code I get a bunch of errors in ./swift-utils/Sources/Utils/misc/layout/alignment/Align.swift.

All the CG datatypes are undeclared.

I assume there is an import of Foundation missing.

kimasendorf avatar Sep 22 '18 17:09 kimasendorf

@kimasendorf Sorry for not including Carthage or instructions on how to use it. Will add Carthage tomorrow.

So to get it running in 30sec what you do is:

http://eon.codes/blog/2017/11/08/local-frameworks/

Do Step 1 until 5. Just don't name it AwesomeLib, Name it Utils.

Let me know if you get stuck. I will try to help. πŸ‘

eonist avatar Sep 22 '18 18:09 eonist

The reason we use .framework is so that you don't have to compile all the files on every run.

This library is meant more as a pick and choose lib. I use many parts of it in other projects. Almost never the whole thing. I have a Tester project that has the entire lib, for whenever I want to clean it up or add things.

eonist avatar Sep 22 '18 18:09 eonist

Hey, thanks for the info. Do you add each packages from their single repository? I saw their are many cross references. Will try the .framework wrapper, sounds useful =)

kimasendorf avatar Sep 23 '18 00:09 kimasendorf

I break out libs on a need by need basis.

If you want to use the Constaint lib. You need Constraint.swift, Alignment.swift and ConstraintKind.swift. FYI: the constraint lib wil get its own repo soon, and will be re-branded to Spatial πŸŽ‰

If you just want to try the entire Utils lib out. You can just downloader and drag it into xcode. And start ising everything.

eonist avatar Sep 23 '18 06:09 eonist

Hey, thanks for the info. Do you add each packages from their single repository? I saw their are many cross references. Will try the .framework wrapper, sounds useful =)

kimasendorf avatar Sep 27 '18 19:09 kimasendorf

One more stupid question, which Swift version do you use?

kimasendorf avatar Sep 27 '18 19:09 kimasendorf

There are no stupid questions πŸ˜‰. I USE the latest swift version so that should be 4.2. I just upgraded to Mojave so im not 100%

eonist avatar Sep 27 '18 19:09 eonist

I just installed High Sierra and Xcode 10.0. It comes with Swift 4.2.

I get many compiler errors.. Thought I have to use 4.1 but it seems really hard to get an older version working..

kimasendorf avatar Sep 27 '18 19:09 kimasendorf

AS far AS i know there ahould not be huge differences in warnings between 4.1 and 4.2 i will give it a spin at the office today in Mojave. I’m still moving atom.io prefs and setting up My os config. So a bit behind atm.

eonist avatar Sep 28 '18 05:09 eonist

@kimasendorf Alrighty, here we go. 4.2 πŸ”Έ I tested it in Mojave + Xcode 10.0 + swift 4.2 all tests run. https://github.com/eonist/swift-utils/commit/395e8b83575821efbd53736172f06e344d609da3

eonist avatar Sep 28 '18 14:09 eonist

Great! There is one error left in swift-utils/Sources/Utils/misc/layout/menu/CustomMenuItem.swift

override func validateMenuItem(_ menuItem:NSMenuItem) -> Bool { //override in subclass (optional) return true }

Method does not override any method from its superclass

kimasendorf avatar Sep 28 '18 19:09 kimasendorf

There are also still errors in swift-utils/Sources/Utils/text/utils/format/TextFormatUtils.swift

and in swift-utils/Sources/Utils/geom/path/ns/NSBezierPathParser.swift.

They are easy to fix..

However, I put all code in a framework but the framework just has an objective-c header file.. Do I need to create some sort of swift index file and import all file I need?

kimasendorf avatar Sep 28 '18 20:09 kimasendorf

I will try to Add the code to a new project and see if there stil are bugs. Also I will make an on boarding wiki page with some gifs explaining the steps to build from frameowork. It’s dead simple but you have to sort of have an overview look.

eonist avatar Sep 29 '18 08:09 eonist

Thanks a lot =)

kimasendorf avatar Sep 29 '18 08:09 kimasendorf

@kimasendorf Updated the files that threw an error and made better on boarding for using the lib, http://eon.codes/blog/2018/09/30/Manually-adding-a-lib/

Will update the build from framework article with gifs later today.

eonist avatar Sep 30 '18 10:09 eonist

@kimasendorf As promised, I added gif videos the explains the steps to build from a framework file: http://eon.codes/blog/2017/11/08/local-frameworks/ in your case you would just need to name the target Utils and then use import Utils in subsequent code that wants to use the Utils code.

eonist avatar Oct 01 '18 13:10 eonist

Great, all errors are gone.

Still not able to get the framework approach right. I created a framework and added the utils, but I think it needs a root file or something?

kimasendorf avatar Oct 01 '18 21:10 kimasendorf

If you do the steps in the local framwork article exactly AS they are sone in the GIFs it should work. This is how you would menes any framework, not just this.

eonist avatar Oct 02 '18 12:10 eonist

But in your post you just add a function to the framework and no files. I mean I've created a framework and added all files and wasn't able to use any func after import..

kimasendorf avatar Oct 03 '18 22:10 kimasendorf

Notice that you have to prefix import with @testable. You also need reach the correct class/instance scope . I.e ArrayParser.count([7,9,7]) //output:3

eonist avatar Oct 04 '18 07:10 eonist