I've seen this question asked a few times like here and here but all the questions I've looked up seemed outdated or had answers that did not line up with the issue I'm having.
I have 2 frameworks - one with some classes to do processing (lets call it ProcessingLibrary
) and a second that makes use of my processing framework.
In the ProcessingLibrary
framework I have a public class declared in a swift file like so:
public class SomeClass {
public init(_ stuff: String) {
// do stuff
}
...
and it builds and everything is beautiful and life is wonderful.
Then in the other framework that tries to make use of SomeClass
I import the .framework file to Linked Frameworks and Libraries
and add it to the framework search path, and then have another class that tries to create an instance of SomeClass
like this:
Import Foundation
Import ProcessingLibrary
class SomeOtherClass {
var someClassInstance: SomeClass
init() {
someClassInstance = SomeClass("stuff")
}
...
When I do this xcode tells me that someClassInstance is an ErrorType
and gives me the Use of undeclared type SomeClass
error, however if I build the library it succeeds with no warnings and no errors. In fact I can even archive it and use it in other projects.
So technically I could just write the library knowing what calls I need to make and just ignore these xcode errors, but it would be nice to be able to have the autocomplete and not see errors on every line. (In fact in the last 2 days since i originally asked this question I have done this)
I've tried doing clean build, deleting derived data, deleting and re-adding the framework, restarting xcode... nothing seems to fix it.
It may be important to note that xcode DOES autocomplete the import line for ProcessingLibrary
and the only other thing it can find with autocomplete / is able to jump to definition of is ProcessingLibraryVersionNumber
which is defined in the ProcessingLibrary.h
header file.
I need to distribute this outer framework however it seems that anywhere I include the outer framework also has the same problem it does, where xcode can't find its class / method definitions but it will build successfully.
Okay, so based on the answers there must be something else missing that I'm not including causing the issue.
So the only info I hadn't mentioned in the original post (since I thought it was unrealated) is that the ProcessingLibrary
also includes a static library of C code and is essentially just a swift wrapper for that C code.
It has a CWrapper.m
and CWrapper.h
file that import the C code I need and provide easier calls for it and the ProcessingLibrary.h
imports the CWrapper.h
like:
#import <ProcessingLibrary/CWrapper.h>
and CWrapper.h
is a public header.
Then the majority of the code for the project is in SomeClass.swift
that makes the C calls through my CWrapper files.
The static c library .a
files are in another directory outside of the project and I just point to them and have a build setting for library search paths that points to it.
The only other build setting I have changed from the default is Enable Bitcode -> NO
because my C library doesn't support the bitcode.
Not sure if any of that info will relate to this error but hopefully it helps.
Thanks everyone who has given an answer!
Just restarting XCode worked for me.
Apologies for the trivial answer but this issue kept me busy for a while so hopefully will help someone else
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With