How to create a swift static framework

Now that it's possible to create Swift static libs, it should be possible to create a Swift static framework?


Creating a Swift dynamic framework and embedding it in an app is no sweat:

1. Create a Cocoa Framework target

2. Add a swift file

3. Create a class in the Swift file that with public access. Include some functions in the class that also have public access.

4. Build the framework target

5. Retrieve the .framework from the Products folder

6. Add the .framework to Embedded Binaries section in an app

7. Import the framework name, which is available because a module.modulemap was generated in a Modules folder when the .framework was build.

8. Make use of some of the publicly accessible functions in the Swift class from the framework

9. Run the app and good to go



I can't figure out how to do a static framework. My manual attempt was:

1. Copy steps 1-4 from above

2. Create a Static Library target

3. Build the Static Library target

4. Replace the dynamic lib executable with in the .framework with the static lib executable build product from step 3

5. Add the .framework with the static lib executable from step 5 to an app (I am adding it as a vendored cocoapod framework)

6. Import the .framework module into AppDelegate in the app and make use of the public class and one of it's public functions. Note that the static analyzer recognizes the class and it's functions (Possibly due to generated swiftmodule classes in framework)

7. Build framework and note the error when ViewController is compiled


Error:

```Undefined symbols for architecture x86_64```

In step 3, how did you build the static library? Did you select "Generic iOS Device" then Product -> Archive to prodice the static lib?

How to create a swift static framework
 
 
Q