29

I copied my project in a running state but the copied project doesn't work for me although the actual project is running fine. When I build my copied project it gives me the following error:

enter image description here

I have cleared the cache and the derived data but the build still fails.

Does anyone have an idea what might cause this issue? Thanks in advance.

ejuhjav
  • 2,660
  • 2
  • 21
  • 32

13 Answers13

34

If you are using CocoaPods, open yourProject.workspace instead of yourProject.xcodeproj.

budiDino
  • 13,044
  • 8
  • 95
  • 91
16

If you're working with SPM, deleting the .build folder and re-running swift build solves the issue for me.

kanobius
  • 756
  • 9
  • 12
12

Did you try to remove the cache ?

rm -rf /Users/abdulrehman/Desktop/StudentMentor/DerivedData/ModuleCache/DLJPQMLQI1Q/

(I might have wrong copied your file path. So feel free to type it manually if there is nothing to remove at this path)

Acrasia
  • 201
  • 1
  • 8
  • 2
    I'm using relative (path) for my Derived Data in preferences -> location. So just "rm -rf DerivedData/" in my project directory did the trick. Xcode 9.2 – FlimFlam Vir Feb 21 '18 at 21:50
6
  • Goto your project folder
  • Delete the contents inside the DerivedDataXcode folder.
  • Clean the project
  • Run.
Nazik
  • 8,696
  • 27
  • 77
  • 123
  • 1
    WORKED for me so far – Glenn Tisman Oct 13 '19 at 14:00
  • 1
    Thanks -- that worked. I wasn't using CocoaPods: I'd merely moved the project from one directory to another. I tried doing a "Build Clean Folder" which didn't work. You might imagine that this would nuke the DerivedData, but it doesn't! Manually deleting the DerivedData does the job. – Dave Jewell May 04 '21 at 12:38
4

I had the same error, but the reason turned out to be having different iOS versions specified as Podfile's platform :ios and as my project's deployment target.

villapossu
  • 2,737
  • 4
  • 18
  • 19
2

SwiftShims is a module defined in the standard library. It shouldn't be missing. I think it's because your DerivedData path changed, and now the compiler can't find its cache anymore.

2

You may get this error if you rename the project directory.

For your reference, I was using Flutter, so

flutter clean

It was solved with.

ytyng
  • 575
  • 6
  • 8
1

I had the same issue...and after a lot of trial and error, the following worked for me..

  1. Open your Xcode Workspace File -> Project_name(directory option on left) -> build settings -> Excluded Architectures -> Select 'Any iOS simulator SDK' and type arm64 in front of that ( for both build and release).

  2. Repeat the same procedure for pods

  3. Go to VS code and delete pod-lock and pod folder

  4. open podfile and Paste the following code right above "target 'name-tvOS' do" in podfile.

    post_install do |installer| flipper_post_install(installer) installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end end

(Note: some of the code body form above may already be there. In that case replace that part with this.)

  1. Save it and run 'pod install' in your project's terminal.

  2. go back to xcode and clear build (Cmd+Shift+K) and then build your project (Cmd+B)

Hopefully it will build without any issues.. Happy Coding!

Arish
  • 390
  • 3
  • 5
0

I have once encountered for a private local pod, which somehow Cocoapod set the lib product name as eg. "MyLib-6c4b1003" -- with a prefix in hex.

This random hex somehow changed, but the project Other Link Flags still using the old one. I did the search to find out the references to the old hex and deleted them, run pod install and the right name will be used.

I still cannot understand why there is this random hex in the prefix, but seems like Cocoapods setting up of the project could reference to the wrong one.

samwize
  • 25,675
  • 15
  • 141
  • 186
0

I had a similar issue when I wanted to remove Alamofire from Cocoapods. then it needs to delete something:

target -- Build Settings -- Other Swift Flags

This junk of code worked for me.

Zim84
  • 3,404
  • 2
  • 35
  • 40
reed
  • 1
  • 1
0

It happened to me when I was running the release version and switched back to the Debug version with Product > Scheme > edit schemes.

Deleting derived data didn't help.

But simply doing Product > Clean Build Folder and restarting XCode fixed the issue.

Raphael Pinel
  • 2,352
  • 24
  • 26
0

In case you see this error in the preview canvas and the diagnostics "mtime changed":

'/var/folders/kv/t_w2wdds3m1_0lr02hcp3dgw0000gn/C/clang/ModuleCache/12TRQXIDQ8QQD/SwiftShims-2TTN5UXQBRCCQ.pcm' was built: mtime changed

Delete all .pcm files in that folder and hit try again. The folder on your machine will be different. Copy the location and run:

rm <paste path here>/*.pcm
Berik
  • 7,816
  • 2
  • 32
  • 40
0

You can delete your Derived Data from Terminal by this simple command:

  rm -rf ~/Library/Developer/Xcode/DerivedData/*
Mani
  • 3,394
  • 3
  • 30
  • 36