3

I have an existing Flutter project which has been working fine for two years. But now all of a sudden, when I try to build or run it on iOS, it always gets stuck on Running Xcode build... .

flutter build ios --debug
Running "flutter pub get" in MyApp...                           0.6s
Building org.example.myapp for device (ios)...
Automatically signing iOS for device deployment using specified development team in Xcode project: 36U5A9XK2Z
Running pod install...                                              1.6s
Running Xcode build...                                                  
(This is taking an unexpectedly long time.)       ⣻

Before this would only take 1-2 minutes, and now I've tried waiting up to 2 hours, so obviously something is very wrong. Other existing apps build just fine.

I have tried "the usual suspects":

  • flutter clean.
  • Delete ~/Library/Developer/XCode/DerivedData.
  • Restart the computer.
  • Delete podfile.lockand run pod install again.
  • Removed some "difficult" plugins (i.e. everything Firebase-related and all Swift-based plugins).

Nothing seems to help. Same thing happens if I try to run the app from within XCode or IntelliJ. Version info below.

Flutter 1.22.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7891006299 (7 weeks ago) • 2020-12-10 11:54:40 -0800
Engine • revision ae90085a84
Tools • Dart 2.10.4```

XCode 11.1
OSx 10.15.1
Magnus
  • 17,157
  • 19
  • 104
  • 189
  • 1
    When you build your "iOS" folder via XCode, does it successfully build? – rickimaru Jan 27 '21 at 08:21
  • @rickimaru No, it also gets stuck somewhere in the middle. I forgot exactly what it says and I can't test it right now, but the progress indicator at the top starts counting up, but then gets stuck after a while. – Magnus Jan 27 '21 at 08:27
  • 1
    Can you try observing the build log in XCode's "Report navigator". To display this, go to "View > Navigators > Reports". Also, have you tried updating the plugins in your pubspec.yaml? – rickimaru Jan 27 '21 at 08:34
  • @rickimaru Hmm, there's a constant flow of `shlock: open(/Users/my_old_user/flutter/bin/cache/shlock96531): Permission denied`. `my_old_user` is another user account on this MacBook, which I don't use any longer. So obviously something is pointing to the wrong folder, but what could be causing it? – Magnus Jan 27 '21 at 08:38
  • 1
    Can you try running `which flutter` in your terminal? – rickimaru Jan 27 '21 at 08:42
  • @rickimaru `which flutter: /Users/magnus/dev/flutter/bin/flutter`, which is correct. – Magnus Jan 27 '21 at 08:47
  • Can you try running `flutter pub cache repair`. Just to make sure, please run `flutter clean` first. – rickimaru Jan 27 '21 at 08:49
  • Try `flutter build ios --debug --verbose`, this may give you some clue – Dmytro Rostopira Jan 27 '21 at 11:34
  • 1
    @rickimaru It turned out there were 3 incorrect hardcoded paths in `ios/Runner.xcodeproj/project.pbxproj`, pointing to `/Users/my_old_user/flutter/bin`. After changing those paths to the correct Flutter location, it started working. Since this is a 2 year old Flutter project, I think I'll just recreate it "from scratch", since I seem to remember having lots of trouble with hardcoded values back in the day, and the way Flutter generates projects has changed a lot since then. Thanks for pointing me in the right direction! – Magnus Jan 27 '21 at 13:58
  • @MagnusW Glad to hear you solved your problem. Good luck! :D – rickimaru Jan 27 '21 at 14:12

1 Answers1

0

You could try deleting the ios folder on the project and generate an iOS build again by running flutter create --platforms=ios [PROJECT_PATH]. That should generate an iOS project from your Flutter code. After that, you could try running flutter build ios again.

Omatt
  • 8,564
  • 2
  • 42
  • 144