Swift packages won't load in Xcode

Hi there,

I was looking into adding a package to be able to use CoreAnimation framework, but when I try to add a package via File > Swift Packages > Add Package Dependency, the window keeps loading


Any idea what is going wrong here?

Thanks!

Core Animation is built into UIKit (and SwiftUI) so you get it for free.

Here is a video on the basics of how to use it.

Hey @Chris_Parker thanks, I was trying to use CATransform3DIdentity in a SwiftUI view, but it says ’ Cannot find type CATransform3DIdentity in scope (also does not work if I import UIKit). The same goes for other core animations components. Do I need to enable a setting for this somewhere?

Thanks a lot!

CATransform3DIdentity is a function that takes a parameter of type CATransform3D.

So you need to declare a variable of type CATransform3D:
var transform3D: CATransform3D?

Have you followed a tutorial on Core Animation or are you just winging it?

Yes I was trying out this tutorial: How to create a flipping card effect - Learn Swift UI - YouTube

But none of the CA elements can be found ‘in scope’. Your example gives the same error:


However it does work when trying it out in the playground - so I really think it’s some sort of setting or xcode bug?

@bjorndv
This is a bit odd.

What version of Xcode are you using?
How are you creating your project?
Can you provide a screen shot of your entire Xcode screen to include the File Navigator on the left which shows the files that make up the project?
Shift + Command + 5 will allow you to take snapshot of your entire Xcode Window like this:

Hey @Chris_Parker I found out the issue: I was trying it out on a watch os project as I did not realise that it wouldn’t be supported there, however, the documentation shows that watch os isn’t supported Apple Developer Documentation

I thought that I also tested it in an iOS project, but it works fine when creating a new project, so I probably did not test it out properly!
Of course this does raise some new questions, like

  • why won’t the swift dependencies (see original screenshot) load?
  • what are the alternatives for watch os (for more complex animations than the built-in ‘animate’ attributes - for example, how is the activity ring completion animated at the moment if the core animation framework isn’t available?)

Happy to create a new topic for the last one, the first one isn’t that important.
In the meantime, I’m fine with closing this topic :slight_smile:

Thanks again for your help, I’ll try to be more specific next time!

Because Core Animation is not an external package that you can load.

In SwiftUI (which is probably what they have written that App in) the activity ring is easy to create.

It’s not the core animation that is not loading, it’s the entire swift package repository window (nothing is filled out in the search field, so it should show something right?)

With the activity ring completion animation I mean the actual fireworks animation you get when completing a ring, not just the activity rings that fill (this is indeed doable in SwiftUI), as discussed in this SO thread How to reproduce watchOS closing activity ring animation with sparks on iOS? - Stack Overflow
but it’s probably not rendered on device, and exported as a series of images instead (using WKImageAnimatable).

No, it wont show anything if you don’t provide a URL to an external package.

The Swift package manager is for 3rd party packages that provide functionality beyond that provided by the built in Swift frameworks. These packages are typically stored on Github and made available to anyone who wants to use them.

Ok makes sense, tried it out with a github package and indeed works if you click on next. Just a bit odd that you keep seeing the loading spinner. This topic can be closed.