Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access a class from a different target with marked as "public"

Tags:

xcode

ios

swift

I created a new target and added a class with the access modifier "Public". But i can't see this class.

http://s23.postimg.org/ikqn0zlvu/Screen_Shot_2015_02_27_at_12_27_28.jpg

From the docs i read "public entities are intended for use as API, and can be accessed by any file that imports the module, e.g. as a framework used in several of your projects." So my guess is that im not importing the module/target?

https://developer.apple.com/swift/blog/?id=5 https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html

like image 229
Godfather Avatar asked Feb 27 '15 11:02

Godfather


1 Answers

public accessor control doesn't mean "public across target", it means public in "linked object files".

You need to select your FooClass.swift file and on the right in the File inspector, there is a Target Membership, you should check all the target that you want the file to be used.

like image 97
CarmeloS Avatar answered Nov 18 '22 12:11

CarmeloS