3

I'm trying to import a swift file from https://github.com/codestergit/SweetAlert-iOS/blob/master/SweetAlert/SweetAlert.swift into an existing objective-c project.

After adding the file to the project I try to compile (just adding the file without doing anything else) and I get the following build error:

Swift is not supported for static libraries

I'm new to swift, and don't see how this library is marked as static and what I should do to change it and make it compile - I don't need it to be static.

how can I solve this?

4 Answers 4

1

You will have to either add the Swift file to a framework or an application.

Due to problems with importing Swift information from static libraries, Apple hasn't implemented building and linking static libraries that have Swift code.

Sign up to request clarification or add additional context in comments.

1 Comment

What I ended up doing is to create a framework that contains the Swift file and having my static library use that framework, therefor having access to all features of my Swift file.
0

just adding the file without doing anything else

I don't know what you added or where you added it. But what you want to do is add just the SweetAlert.swift file — nothing else — and you want to add it to your project as part of your app target.

You will then also need to accept the dialog that creates a bridging header, and import the hidden bridging header into your Objective-C code that wants to call this code.

2 Comments

Do you need more help? Post your project on github and I'll fix it for you. Or if you like, I can post an example on github for you.
Ooooh, it may be that your project already contains a static library. In that case, yes, you won't be able to incorporate the Swift file into it.
0

the problem occur because you use the swift code for the objective-c project.you will find the file under podsTarget pods/XXXX/XXX is swift file. for example use pod 'ReactiveCocoa','2.1.8'instead of pod 'ReactiveCocoa'

Comments

0

The current runtime doesn't ship with the OS, so static libs would lead to multiple runtimes in the final executable. See more https://twitter.com/owensd/status/555060783407591424

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.