Reputation: 3633
In my test project, I created 2 targets like so:
Step 1:
Step 2:
Step 3:
Afterwards, I created TestClass1.swift
in "TestTarget1" and TestClass2.swift
in "TestTarget2":
// TestClass1
public TestClass1 {
public static var randomNumber: Int {
return Int.random(in: 1...100)
}
}
And in TestClass2
, I wish to access the random number generator in TestClass1
WITHOUT having to import target "TestTarget1", is this doable? e.g., by linking libraries, frameworks, etc.
You might wonder, "Why do you not want to import it?" It's very hard to explain, and I believe you don't really care, I just wonder if this is doable. Thank you!
Upvotes: 4
Views: 2347
Reputation: 15238
For each source file in your project, you can choose the targets in which it is included. It is called "Target Membership" in the File Inspector in the right sidebar.
Upvotes: 7