1

I have an iOS app which I need to build a supporting app for macOS. I was hoping to share code between them, specially the DataModel.

As the iOS app was using Pods, there was already a workspace.

I pulled in the macOS project into the workspace, and I can see all its files with no problem. But I don't seem to be able to figure out how to 'use' the class files from the iOS project in the macOS project. Would it have anything to do with Modules?

Or should I just make a new Target that is a macOS application?

I'm using Xcode 8.3.3 at the moment, and the projects are in Swift.

asked Jun 13, 2017 at 9:00

1 Answer 1

1

Select the source files you want to use and tick the "Target Membership" for your macOS target in the Inspector:


Update:

To use common code in different projects, make an extra project for your common code which builds as a Framework and include this framework in the iOS and in the macOS.

This tutorial might be helpful.

answered Jun 13, 2017 at 10:57
Sign up to request clarification or add additional context in comments.

2 Comments

So don't add the macOS project and just make a new Target in the iOS project?
Misunderstood than. Sorry. Updated answer.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.