adamwulf / ClippingBezier

ClippingBezier calculates intersection points, paths, and shapes between two UIBezierPaths
http://getlooseleaf.com/opensource/
MIT License
254 stars 34 forks source link

How to run in Swift project? #5

Closed chika-kasymov closed 6 years ago

chika-kasymov commented 6 years ago

I cloned the project to the local machine and did update submodules. Then build the PerformanceBezier and ClippingBezier frameworks. To test I ran the example project and it works fine.

After I found the built frameworks by pressing "Show in Finder" on frameworks in Products group folder and added both frameworks (by copying) to my Swift project. Then I added both of them in Embedded Binaries section in project settings. I added "-ObjC" and "-lstdc++" flags to Other LInker flags in my target Build Settings.

Then I added sample code like this:

var beginsInside = ObjCBool(false)
let intersectionPoints = path1.findIntersections(withClosedPath: path2, andBeginsInside: &beginsInside)
if intersectionPoints?.count ?? 0 > 0 {
    return true
}
return false

The project runs successfully but gives the error when running logic on ClippingBezier framework method: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIBezierPath findIntersectionsWithClosedPath:andBeginsInside:]: unrecognized selector sent to instance

Can you point what I'm doing wrong? I think the problem is that I improperly integrated your framework.

adamwulf commented 6 years ago

It sounds like the category methods aren't getting linked into the project. Try adding -all_load to the linker flags and see if that changes anything.

chika-kasymov commented 6 years ago

@adamwulf yes, I tried this before posting an issue but without success. After changing some project settings I also tried to clean project and build folder, but the error still occurs.

I'll look into that issue again today and if there's progress I notify you.

chika-kasymov commented 6 years ago

@adamwulf finally I solved my problem. I saw that Xcode shows the warnings like ... ignoring file ... missing required architecture x86_64 ... 2 slices for ClippingBezier and PerformanceBezier frameworks.

To solve I it I used the first proposed solution on SO. More specifically I added arm64, armv7, and armv7s to Xcode Architectures settings which by default includes Standard architectures ($(ARCHS_STANDARD)).

adamwulf commented 6 years ago

Ah! that'd do it :) Glad you were able to track it down. Thanks for posting what you found in case others run into this as well.