Justin Dosaj
Justin Dosaj

Reputation: 587

Flutter iOS build is stuck on "Running Xcode Build"

I recently got a mac to be able to test the iOS applications I made with Flutter/Dart. But when trying to transfer all my files to a Mac and try to test it, it gets on "Running Xcode Build."

I am importing 2 things in my pubspec.yaml file:

dependicies:
  flutter:
    sdk:
      cupertino_icons: ^0.1.2
      firebase_admob: ^0.9.0+10

In my podfile, which I was told to download on the google admobs documentation I have

pod 'Google-Mobile_Ads_SDK"

My Flutter Doctors reads:

[flutter] flutter doctor -v
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-US)
    • Flutter version 1.12.13+hotfix.5 at /Users/priscilla/Desktop/Temp/flutter
    • Framework revision 27321ebbad (5 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/priscilla/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /usr/bin/java
    ✗ Could not determine java version

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.4

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • 754DF0BD-203E-4A0A-B785-E92D4B1D9C38 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

! Doctor found issues in 2 categories.

And the change to my info.plist is: (The actual app ID is in my code, just didn't want to post it here)

<key>GADApplicationIdentifier</key>
<string>[APP_ID]</string>

If I were to create a new Flutter project from scratch, the given code runs perfectly fine. It is just when I try to import the files the project on my windows PC to my Mac.

I think a solution would be to create a new Flutter project and while creating import my files, but I am not sure how to do that. So at the moment, I created a new Flutter project, deleted all the files that comes loaded initially, then replaced them with my project files.

Upvotes: 41

Views: 40644

Answers (7)

bentalla
bentalla

Reputation: 71

First edit your Podfile and add this :

        pod 'FirebaseFirestore',
        :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git',
        :tag => 'IOS_SDK_VERSION'
target 'Runner' do
      use_frameworks!
      use_modular_headers!
       // ADD FOLLOWING To  your PodFile : 
      ***pod 'FirebaseFirestore',
        :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git',
        :tag => 'IOS_SDK_VERSION'***
        //On this date 22-Nov_2024 IOS_SDK_VERSION = "11.2.0"
    
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
      target 'RunnerTests' do
        inherit! :search_paths
      end
    end

after do :

cd /ios
pod setup
pod install

and finaly run

Upvotes: 0

I was running on Android Studio and I got the same problem, I fixed by simply opening XCode

Upvotes: 1

Sharon A
Sharon A

Reputation: 2625

If your build is stuck on Running Xcode build..., try the solution below:

cd Project Folder >

rm -R build

rm .dart_tool

rm .packages

rm -Rf ios/Pods

rm -Rf ios/.symlinks

rm -Rf ios/Flutter/Flutter.framework

rm -Rf ios/Flutter/Flutter.podspec

pod cache clean --all

cd ios > pod deintegrate

pod setup

arch -x86_64 pod install cd ..

flutter clean -v

flutter pub get

flutter clean && flutter run

If the above fails, clone the project again and flutter run.

Upvotes: 2

Agung
Agung

Reputation: 13813

in my case, I use Firebase Firestore.

it doesn't stuck actually, but it takes waaaay too long to build in Xcode. don't forget to improve iOS build times as per the official documentation in here (don't forget to pick Dart Flutter as the language), and then scroll to find the optional section about how to Improve iOS & macOS build times by including the pre-compiled framework.

Currently, the Firestore SDK for iOS depends on code that can take upwards of 5 minutes to build in Xcode. To reduce build times significantly, you can use a pre-compiled version by adding this line to the target 'Runner' do block in your Podfile:

please open that documentation to improve the build time, because the code maybe updated.

the code will be like this

target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => 'x.xx.x'
  # ...
end

after adding that 1 line on your iOS podfile, don't forget to do flutter clean before rebuild the project. the second time you build the project it should be faster

NOTE:

if there is an error, then please ensure the tag in pod :tag => 'X.X.X' from the code in documentation is suitable with your cloud_firestore package version. sometimes the official documentation is not updated like the issue in here

Upvotes: 43

Gal Rom
Gal Rom

Reputation: 6471

In My Experience, this first build indeed takes a long time - but after you run it once - the build time is reasonable.

Upvotes: 0

iOS(Build) IPA building was taking around 14456.14 Sec i.e (more than 4 hrs) after updating to the below version it was reduced to 2143.3 Sec i.e. (less than 40 mins)

  1. Changed From:

    environment:
    sdk: ">=2.7.0 <3.0.0"
    

    Changes To:

    environment:
    sdk: '>=2.12.0 <3.0.0'
    
  2. Change the whole project to Null-safety

    Please follow https://dart.dev/null-safety/migration-guide

Upvotes: 1

Srinadh
Srinadh

Reputation: 566

I had removed the external devices specifically external monitors attached to Mac. Then made the build.

My build time came from 10min on average to 0.5 to 2 min max.

Upvotes: 23

Related Questions