Copy Xcode Project in 5 Easy, Safe Steps within 10 Minutes
Copy Xcode Project in 5 Easy, Safe Steps within 10 Minutes

Copy Xcode Project in 5 Easy, Safe Steps within 10 Minutes

Mazen Kilani
AppleCommunity

--

by Mazen Kilani AppsGym.com

Scenario

You want to copy an existing Swift Xcode project to be a template for a new project, utilising Xcode built-in referencing algorithms.

Audience

The article is for Swift developers who wish to create new Xcode projects, from a model / template project, easily and safely within a reasonable timeframe.

Prerequisites

The article applies to any Xcode project. However, we based this article on the AppsGym Books model app, as a practical example, which is published on Apple’s App Store (as 8Books). You can review the app and also download the complete Xcode project on AppsGym.com, free (no ads). Once downloaded, you can replicate the steps below to get familiarity with the approach, if needed.

Do NOT Duplicate Folder!

The first action not to be done is to copy/duplicate the folder and rename the project. This is prone to so many errors; it’s just not worth it. Follow the guidance below, and your new project will take only 10 minutes to perfection.

YouTube Video

We recommend viewing this video within the following group sequence, on the AppsGym YouTube Channel, but it’s perfectly fine to view it standalone with reference to this article.

  1. AppsGym Books Model App Tour
  2. AppsGym Books Xcode Project Tour
  3. Copy Xcode Project in 5 Easy, Safe Steps (this video)

Bird’s Eye View

Step 1: Create & Clean Your New Xcode Project

Launch Xcode and Create a New Project.

The new Project Navigator layout will be displayed

Move to Trash every file, so you will end up with a ‘clean’ slate: basically nothing!

This view is the result of all the ‘trashing’! You can keep the new project *.xcdatamodeld if you want to build it later (optional, as the model project uses a different xcdatamodeld). Now you are ready.

Step 2: Copy Model Project Folders & Files to Your Project

Copy the folders (e.g., Assets.xcassets) and files (*.swift) from the AppsGym Xcode Books project to your new project under the folder of your project name (do not copy the Base.Iproj, *.xcodeproj, *.entitlements or Tests files)

Select the following options for each copy operation

The new Project Navigator layout will be as follows (an exact copy of the AppsGym model project):

Step 3: Add Your Project Bundle Version and Build

Warning: If you leave empty, you will run into the ‘Failed to Install the Requested Application’ error!

Step 4: Remove Info.plist from Build Phases

Navigate to your project Build Phases: Copy Bundle Resources and remove (-) any info.plist file there (usually 2, remove both).

Warning: If you don’t remove the records, you will run into this error:

Multiple commands produce ‘/Users/mazenkilani/Library/Developer/Xcode/DerivedData/MyBooks-dppyqnfxvviffsfjwaiuumpfkaoj/Build/Products/Debug-iphonesimulator/MyBooks.app/Info.plist’:

Step 5: Add Your Project Cloud Capability

(If using iCloud, required for AppsGym Books)

Navigate to your project Signing & Capabilities, click add (+), search for Cloud, then add it. You will need to launch your CloudKit Dashboard later, but not now.

Run the Project

Run the project and the sample books table view will show.

Checks & Verifications

The checks and verifications below are optional, but highly recommended to proactively resolved any issues, without waiting for error messages when you run the project.

Check Your Target Membership

Go through each file and verify the Target Membership is selected (checked) for your project, and, if empty (not selected), then check the box. You will probably only need to do this for Assets.xcassets, so verify this first and randomly selected other files. The reason is Xcode copy may (sometimes) confuse the references. There is no cure or remedy for this. Verify and correct if needed.

Verify Your Storyboards

Xcode may not correctly assign the proper module to some storyboards, so verify and correct if in error. Start with Queries and Settings and correct, if needed, the Queries Table and the Settings App Info and Credits. However, check all the others.

Warning: If any is left in error (pointing to AppsGym module not your project) then you will encounter the Thread 1: “[<UITableViewController 0x7fcded721250> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key xxxxxxxxxxx.” when you run the app.

Discover & iCloud Setup

When you launch Discover and iCloud, you will see the Alert Message that their CloudKit Containers are not set up (image below). iCloud is covered in the AppsGym.com tutorials.

The article showed the complete 5 easy, safe steps to create a new Xcode project from an existing model/template project. Bookmark it for reference in future endeavours. Thanks for reading!

--

--

Mazen Kilani
AppleCommunity

I published 47 Swift iOS apps/games and 2 Flutter Android apps. I share complete Xcode projects, free (no ads), at AppsGym.com.