Yaman
Yaman

Reputation: 3991

Xcode showing error with embedded framework but it compiles well

I have an app with a custom Swift framework that is used to share business rules across different plateform. Every time I try to use a class from this framework, Xcode is showing me errors but everything compiles well. It also preventing me from using autocompletion regarding this framework.

I already try cleaning and deleting derived data but without any results.

My framework is included in my main projet via a submodule and manually linked on my main project.

Any thoughts on this ?

enter image description here

Upvotes: 4

Views: 1917

Answers (6)

Yakuhzi
Yakuhzi

Reputation: 1249

I did face the same problem recently. I solved it by setting the framework and header search path to non-recursive in the project scope and pointing directly to the correct directory without subfolders. My target then inherits the search paths from the project.

Upvotes: 0

Jen Hamilton
Jen Hamilton

Reputation: 11

Are you using git in this project? As odd as it may sound, I've resolved similar issues by committing the current code.

Upvotes: 0

KAVIYA VENKAT
KAVIYA VENKAT

Reputation: 337

My custom Swift framework class:

public class Myfile {
    public func textmethod(){
        print("The value of textmethod")
    }
}

Imported framework to the project

My ViewController file:

import MyFrameWork

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let log = Myfile()
        log.textmethod()
    }

}

Upvotes: 1

AD Progress
AD Progress

Reputation: 5096

Try removing your framework then CMD+B close XCODE open it again add the framework again and CMD+B. By the way have you moved your project folder recently??

Try this

Upvotes: 1

Lukas
Lukas

Reputation: 3433

I think your problem is with the framework's search path. I assume its now set for the target but not for the project (or incorrectly set on the project). You can set it only for the project and let Xcode handle target path.

Xcode has a separate compilation process for computing autocomplete references, from the compilation process for actually building your project. If you accidentally set the framework search path for your target instead of the project as a whole, your project will seem to build fine. https://medium.com/@_achou/one-weird-trick-to-fix-autocomplete-in-xcode-9f19dc856944

Solution 1: Fix framework search path in Project - Build Settings.

Solution 2: Remove the framework from your project, head to Targets - Build Phase - Embeded Frameworks, click on + (add) and then Add Other and find it in your directory.

Upvotes: 1

Nour
Nour

Reputation: 122

I have noticed the same problem recently. The solution I found that I had to run the app in the simulator for then the xCode to start recognizing the framework and hence to get the autocomplete feature..

Give it a try..!

Upvotes: 0

Related Questions