Should you use targets for code you don't own?

39 Views Asked by At

I am using this third-party view control in my project https://github.com/nicklockwood/SwipeView That project does not support CocoaPods or Carthage.

Note: my entire project is Swift and this other code is Objective-C.

To integrate this into my project I just dragged in the .h and .m files into my project.

Is this the proper approach? Instead should I have created a new target and put those files in there? Are there any considerations for me to make this choice?

1

There are 1 best solutions below

0
DDP On

I've used this technique (separate targets building static libraries) for third party code - even when that library does support CocoaPods or Carthage.

One benefit for me was when there were breaking changes, particularly with newer versions of the tool chain, before the third party code was updated. It was straightforward to disable e.g. certain newer compiler warnings in that target alone while keeping the rest of the project as clean / safe as possible.

It's also reasonably tidy when mixing Obj-C and Swift.

I haven't found a downside, as long as you're happy to manage the project integration yourself (that might otherwise be handled by CocoaPods). I only tend to have one or two third-party libraries in my macOS projects.