I would personally try and extract those files into a package or a framework and then use that package or framework in both of your files.
But there may be a less beautiful alternative. You can drag your files to Build Phases
under Compile Sources
of your target project.
So if you have a file MyFile.swift
in Project A
but want to also use it in Project B
do the following:
- Select
Project B
in your navigator
- Select
Build Phases
tab
- Extend a section
Comple Sources
- Drag
MyFile.swift
from navigator to Compile Sources
- Deselect "Copy items if needed" and confirm (Use whatever other options you want)
This will now show the same file under both of the projects in navigator. It looks as if it was a copy of a file but it is the same file; by changing one you are changing the other.
You can do the same with resources but remember to drag them under Copy Bundle Resources
instead of Compile Sources
.
But again think about creating local packages as they are also made in few clicks.
- File -> New -> Package
- Name it and select your framework under
Add to:
- Drag your files to package and add
public
for what you need to expose
- Select your target project in navigator
- Open
General
tab
- Under
Frameworks, Libraries, and Embedded Content
select +
button
- Click your package and add it
- Remember to use
import <#PackageName#>
in source code to use your package