Can't access class from custom dynamic framework (Swift)

12,089

Found the answer. I had to prefix my class declaration with the public modifier. So this:

class XYZ {

}

became:

public class XYZ {

}

And, as always, trashing the ~/Library/Developer/Xcode/DerivedData folder fixed any minor complications.

Share:
12,089
Vatsal Manot
Author by

Vatsal Manot

Updated on June 05, 2022

Comments

  • Vatsal Manot
    Vatsal Manot almost 2 years

    My test dynamic iOS framework XYZFramework consists of a single class XYZ.

    However, even after declaring:

    import XYZFramework
    

    I am unable to access this class, with any attempts yielding the following error:

    Use of unresolved identifier 'XYZ'
    

    How do I resolve this issue?

  • mash
    mash over 9 years
    After I did add "public" to everything, quit Xcode, remove ~/Library/Developer/Xcode/DerivedData, relaunch Xcode and errors disappeared.
  • naz
    naz over 9 years
    I forget this part everytime...grrrrr
  • John Shammas
    John Shammas about 9 years
    Old thread but one note: Instead of deleting that folder, I found that switching my scheme to the framework and running a build, then switching the scheme back to my app and running a build, accomplishes the same refresh.
  • eilas
    eilas almost 7 years
    "trashing the ~/Library/Developer/Xcode/DerivedData" did the trick for me, thanks!
  • Alix
    Alix over 6 years
    Do you mind posting your test project on github. I am trying to make framework. and I am getting the same sort of issue. classes and func are not accessible in the separate test project that I am creating.
  • Naresh
    Naresh over 2 years
    And also check SDK min. support version and your app main target support version.