简体   繁体   中英

How to share files between two xcode projects in workspace?

I learnt about Xcode workspace .I know how to share the static library but i want to share the files between two xcode projects in workspace and is it possible to run multiple targets at a time?Can you provide me the information of how to do this.

Thanks in advance

Sharing files between projects in the same workspace is easy, even if the projects are on the same level (no subprojects):

Assume you want to share constants between Project1 and Project2 , and these constants are defined in a file SharedConstants.swift , which is defined in Project1 .
In order to be used in Project2 , it must be compiled there.

Thus, activate in the project navigator Project2 , select the target and open the Build Phases tab.
Open there Compile Sources by tapping the little triangle left.

Tap the + button below the listed sources for this target. This will show you a list of files of Project2 . There you cannot select your shared constants, because they do not belong to this project.
However left bottom is a button Add other…
Tapping it will open a standard file selection window where you can select SharedConstants.swift from Project1 .

After tapping Open , a 2nd window opens with a Destination: Copy items if needed checkbox.

Important: Do not check this box!

If you would check it, a copy of SharedConstants.swift would be used in Project2 , and any changes that you make in Project1 would not be visible in Project2 . Instead, it you uncheck it, only a reference to SharedConstants.swift in Project1 would be used in Project2 , and any changes will affect both projects.

To share the files you can probably use the bundles

Targets are manipulated with Schemes in Xcode 4, you can launch several targets in the same time if you select the different destinations (with OS X you can probably have the same destination :) )

You'll see a little triangle below the stop button indicating that you can long-press it to select which operation should be terminated: Xcode中

You can switch the console with the popover at the Debug area where you see the target name and icon - that's a button.

You can drag Xcode projects into other Xcode projects to nest them.

More info here:

How should I manage dependencies across projects in an Xcode workspace?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM