Xcode can't see added package dependency

I've finally gotten my SPM-based wrapper library working by itself. So now I added it as a local dependency following Apple’s instructions. It shows up in Xcode's project navigator, in the Link Binary With Libraries build phase, and in the General Frameworks, Libraries, and Embedded Content section (although there's no selector for whether or not to embed it, which would be necessary for distribution).

Unfortunately, if I import GDAL in my app's source, the compiler complains that there's no such module. Sigh.

Did I miss a step?

Have you added it to your app's Package.swift as a dependency as well?

It doesn’t have one; it’s an Xcode project.

AFAIK the instructions you linked are for overriding dependencies in a SwiftPM app not a generic Xcode app. I could be wrong however but that's how I used it in the past and how it works for me

I don't think so. I got there from Adding Package Dependencies to Your App, which is about adding them to an Xcode project. That is, it talks about using Xcode UI to add a dependency, and entering the package's repo URL. It should, of course, let you browse the local filesystem and let you drag a local package onto Xcode, but it certainly isn't documented that you can do that.

Under “Edit a Package Dependency” (as you indicated) is the link I posted earlier. It does talk about dragging the package folder to your Xcode project. It is, however, also referring to an Xcode project, not a Package (e.g. it says “Open your app’s Xcode project or workspace”; as far as I know, Packages are not opened in workspaces).* If you look closely, all of the screenshots show a regular project, as there is no Package.swift file visible in the top level of the Files & Groups hierarchy.

There’s no good reason Xcode shouldn't let me add a local package as a dependency to a non-Package Xcode project. Why should that be limited only to Packages published in Github or some other repo? I haven't yet tried putting in a local file URL, as I both want to be able to edit the local Package, and the instructions work, as far as anyone can tell (all of the icons appear in the correct places in Xcode: Files & Groups, General Tab, and Link build phase. By all UI indication, Xcode has been configured for the dependency, but it is not including it in the build instructions.

*This, of course, is a ridiculous amount of work; one should simply be able to disclose the dependent package contents in Xcode and edit them, instead of jumping through all these hoops. My understanding is that avenue was deliberately considered and prohibited, for reasons unknown.

Oh, I see. To make a package dependency editable, it first has to be added as a "normal" package dependency.

This is poorly designed and implemented.

Man, I'm done. I checked my library in, added it to Xcode as a Package dependency, which required I completely restructure it to have the Package.swift at the top level.

Then Xcode bitched about The package product 'GDAL' cannot be used as a dependency of this target because it uses unsafe build flags.

So, I can't build my Package without unsafe flags, and I can't build my app with them.

No more Packages for me.

Terms of Service

Privacy Policy

Cookie Policy