0
votes

I am new to the Swift Package Manager so bear with me. I have searched around and haven't found an answer to my current problem. I am creating a custom framework. When I create a CocoaTouch Framework and then build it, I am able to find the ProjectName.framework in my "Products" folder in the project directory. However, when I use SPM to add a dependency (Alamofire for example) and generate a new project file with the

swift package generate-xcodeproj

terminal command, the Alamofire.framework shows up in "Products" but the ProjectName.framework is no longer available. Instead there is a ProjectName executable file. I am no longer able to find the framework or even include the whole project in another as a dependency.

enter image description here

In the image above, I expect to see KonvurjKit.framework in "Products" but I no longer see it. Any help would be greatly appreciated.

1

1 Answers

0
votes

Since your project contains main.swift, Swift Package Manager produces an executable. You should add your framework files, other than main.swift and then run swift package generate-xcodeproj. A framework will be generated in Products in the generated Xcode project.

If you want to create both an executable and a library (framework), a possible Source layout is this:

Sources - KonvurjKitExecutable main.swift - KonvurjKit <your framework files here>

Add two targets to your Package.swift: targets: [ Target(name: "KonvurjKitExecutable", dependencies: [.Target(name: "KonvurjKit")]), Target(name: "KonvurjKit")]

If you want to create a library (framework) only, just remove main.swift and add your framework files directly to Sources.