DDPWNAGE
DDPWNAGE

Reputation: 1443

How do I have an iOS App and OS X App in the same project?

I've seen this question about whether or not it's possible to make an iOS App and a Mac OS X App in the same project, while I was trying to ask this. I'm not asking about whether or not it's possible. I had to delete and re-install Xcode (because I wanted to update and my MacBook Air's SSD is really low on space), and I came across this screenshot.

Screenshot

Besides the absolutely beautiful 3D scenery on the right side, I looked at the project structure on the left. They have OS X files in one group and iOS files in another.

How would I be able to make my project this organized? As in, how would I go about making a project where I can simply have OS X files and iOS files be simply two different groups of files in the same project, and work on each app almost synchronously?

Upvotes: 8

Views: 2912

Answers (3)

xue
xue

Reputation: 2475

Figure out how to do this, leave some screenshots in case it may help others.

I did the OSX App first, put the common code apart, then click file menu to create the target as iOS App.

enter image description here

Use the common code to build iOS App, Now you can already see the target has both OSX and iOS, remember to add the needed files in the Compile Sources and Resources.

enter image description here

Now you can both choose whether to run on iOS or OSX. Done!

enter image description here

Upvotes: 10

Michael Yang
Michael Yang

Reputation: 1433

You can add a Mac OS X target in the same project~Choose the file which should add to iOS target and which should add to mac os x target

Upvotes: 0

trojanfoe
trojanfoe

Reputation: 122391

The answer seems quite straight-forward. Xcode allows you to create groups in order to organize files. Each source file can belong to one-or-more targets, so it's just a case of putting all common, iOS-specific and OSX-specific files in their own groups and setting their targets.

- Source
    - Common
        - File1.m       Target: iOS and OSX
        ...
    - iOS
        - File2.m       Target: iOS
        ...
    - OSX
        - File3.m       Target: OSX
        ...

Upvotes: 4

Related Questions