Hi,
I can’t get a flake configured, which is compiling a flutter app for iOS.
Wen issuing flutter run
I get
Launching lib/main.dart on iPhone 15 Pro Max in debug mode...
Running Xcode build...
Xcode build done. 5.1s
Failed to build iOS app
with the error
Lexical or Preprocessor Issue (Xcode): 'UIKit/UIKit.h' file not found
/Users/patmuk/code/own/sherry/system/sherry/shell_flutter/ios/Pods/Target%20Support%20Files/wakelock_plus/wakelock_plus-prefix.pch:1:8
Basically the cocapod installed 3rd party lib can’t compile, as it does not find the UIKit.h from the iOS SDK.
My flake looks like this:
{
description = "Flutter toolchain. Installs all tools needed for flutter, with versions pinned for this project. Rust's own tooling handles the rust toolchain.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
android-nixpkgs.url = "github:tadfisher/android-nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, android-nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
android_sdk = {
accept_license = true;
};
};
};
androidCustomPackage = android-nixpkgs.sdk.${system} (
sdkPkgs: with sdkPkgs; [
cmdline-tools-latest
build-tools-30-0-3
build-tools-33-0-2
build-tools-34-0-0
platform-tools
emulator
#patcher-v4
platforms-android-28
platforms-android-29
platforms-android-30
platforms-android-31
platforms-android-32
platforms-android-33
platforms-android-34
]
);
pinnedJDK = pkgs.jdk17;
xcode_version = "15.3.0";
flutter_rust_bridge_codegen = import ./nix/flutter_rust_bridge_codegen.nix {
inherit pkgs;
};
in
{
devShells. default = pkgs.mkShell {
name = "My-flutter-dev-shell";
buildInputs = with pkgs; [
# packages needed for this project
flutter
cocoapods
# darwin.xcode_15_1
xcodes
# fastlane
# android-studio
pinnedJDK
androidCustomPackage
flutter_rust_bridge_codegen
# needed by rust
llvmPackages.bintools # use lld instead of ld (faster)
libiconv
darwin.apple_sdk.frameworks.CoreServices
# list of frameworks: https://github.com/NixOS/nixpkgs/blob/4fb6fe0206261ee4a5849ab06daad265478eac2c/pkgs/os-specific/darwin/apple-sdk/frameworks.nix
# needed by cocapods for 'UIKit/UIKit.h' file not found
darwin.apple_sdk.frameworks.Foundation
# darwin.apple_sdk.frameworks.SystemConfiguration
];
shellHook = ''
# installs or checks for the right xcode version
echo "installing xcode ${xcode_version}"
xcodes install ${xcode_version} --experimental-unxip
xcodes select ${xcode_version}
# GRADLE_USER_HOME=$HOME/gradle-user-home
# GRADLE_HOME=$HOME/gradle-home
'';
JAVA_HOME = pinnedJDK;
# ANDROID_HOME = "${androidCustomPackage}/share/android-sdk";
# ANDROID_SDK_HOME = "${androidCustomPackage}/share/android-sdk";
# GRADLE_USER_HOME = "/home/admin0101/.gradle";
# GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidCustomPackage}/share/android-sdk/build-tools/34.0.0/aapt2";
};
}
);
}
Note that I did not try to get a flutter build for Android running yet. The error I am getting there is that it tries to install the idk and fails, as it can’t write to the /nix/store … but first things first - getting the iOS build running
So, I am unsure what the problem is. If there a package missing, like " darwin.apple_sdk.frameworks.Foundation"? I could not find a “iOS UIKit” one though. Is that even the iOS SDK? Or the MacSDK?
Or is it a nix/store problem? As building in Xcode gives me this error message:
Target debug_unpack_ios failed: Error: Flutter failed to create a directory at "/nix/store/09v9fm2zq664rhdnbvyg2wr9j4j7ak2i-flutter-3.19.0-unwrapped/bin/cache/artifacts".
Is this ok to ignore or supposed to work? I know nix/store is read-only - I assume that flutter run
/flutter build ios
is doing it differently, but the env is not providing the iOS SDK, thus UIKit.h is missing for the 3rd party cocapod to be compiled …
Did anyone got it running? When looking for issues with ‘nix flutter’ I only find Android related problems (I am looking forward to … ).
Many thanks for reading through my wall of text!