Creating multiple projects in one Xcode project

🎯 Challenges which we face with single project.

  • Consider a situation that you have one application that will be published in various countries with some different features but also it have some same features. Instead of keeping duplicate work, you can work similar feature as framework and you can use it in your app.
  • One more use case is :- If you’re working in a big team / your app is very big, it’s better to keep separate project for each work. It helps for CI/CD integration to alert particular team about issues. I’m explain more about this in my next blog.

How can you create a multiple project in one Xcode project?

*.xcworkspace:-

  • An Xcode workspace always exists in your project. It may be external to an .xcodeproj, or embedded within one.
  • A workspace is just a list of contained projects. there is no other metadata in it.
  • Xcode workspaces are directories with the .xcworkspace extension that is present as packages
  • Workspace is responsible for dependencies between projects
  • Each workspace contains bellow 3 files. The important file is contents.xcworkspacedata.
1. xcworkspace folder contains these project 2. Data in contents.xcworkspacedata with empty workspcae

*.xcodeproj:-

  • like workspace, an Xcode project is a bundle containing one or more files.
  • The most important and only required file is the project.pbxproj file.
  • Project is responsible for the source code.

Steps involved in adding multiple project:-

  1. Create Simple xcode project as follows.
  • Create xcode project by Select File -> New -> project -> app -> give name for the project(e.g Test) -> select destination to save project
  • Now Your app folder look like this
  • Open your xcode project where you need to add -> Select File -> New -> project -> Framework-> give name for the framework(e.g NextScreen) -> select your project where you need to add project under Add to
  • Now your project look like this which has one Test xcodeproject and a NextScreen framework
  • Create swift file which acts as plugin between the framework and project :- Select File -> New -> Swift File -> name the file(e.g NextScreenPlugin) and save under framework folder.
  • Select your project -> Select Build Phase -> Click on + button under Dependencies. -> add your framework there(I’m using NextScreen as framework)
  • Expanded project folder looks like below
  • In this Example i’ve a viewcontroller with button in Test app. Tapping on that button will take user to next screen which is present in my framework
  • Add code for pushing view controller in NextScreenPlugin as
  • Import framework into the app and call required method
  • Now run your code. your app look as bellow

How to use xcworkspace for adding multiple project:-

  1. Create a folder where you want to store your project.
  2. Select File -> New -> Workspace.

--

--

--

iOS Developer in walmart

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

📈 Unit Testing in Swift: The Fundamentals

SwiftUI | Email/Password Signup Using Firebase

Firebase and SwiftUI logo with an iPhone login page

SwiftUI, Is it ready for my next project?

7 Must have iOS14 Homescreen Widgets (November 2020)

Adding SwiftUI view to UIKit project and interacting with it

Sign in With Apple Using Firebase Auth SDK and SwiftUI 2

Phone

Xamarin Tips: Xamarin.iOS Binding with SecKey API

Implementation of Page-Object-Model (POM) to XCUITest (Native iOS Testing) with Swift

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Manasa M P

Manasa M P

iOS Developer in walmart

More from Medium

Create Your Own UIActivityIndicatorView in iOS using Swift

Adding Statsig to iOS

iOS: Table Views, Image Views, App Bundles & More…

Build an iOS app with NotificationCenter