After adding shared_preferences, I cannot build iOS simulator of Flutter - ios

After I added shared_preferences to pubspec.yaml, iOS sumulator never success to build.
I tried
flutter clean
upgrade cocoapods
pod install
pod uninstall
pod deintegrate
But none of them resolved this problem.
versions
~/i/fissus ❯❯❯ flutter --version master ✱
Flutter 0.10.1-pre.45 • channel master • https://github.com/flutter/flutter.git
Framework • revision bdc3dda5f2 (2 days ago) • 2018-10-15 15:03:02 -0700
Engine • revision 32f417db0d
Tools • Dart 2.1.0-dev.7.1.flutter-b99bcfd309
~/i/fissus ❯❯❯ dart --version master ✱
Dart VM version: 2.0.0 (Fri Aug 3 10:53:23 2018 +0200) on "macos_x64"
~/i/fissus ❯❯❯ pod --version master ✱
1.5.3
pubspec.yaml
name: fproject
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
rxdart: ^0.19.0
cupertino_icons: ^0.1.2
font_awesome_flutter: ^8.1.0
http: ^0.12.0
shared_preferences: ^0.4.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
fonts:
- family: Noto
fonts:
- asset: fonts/NotoSansCJKjp-Regular.otf
- asset: fonts/NotoSansCJKjp-Bold.otf
error message
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
ERROR: Invalid version /Users/ryu.ishikawa/issus/fissus/ios/./Podfile.lock
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
Could not build the application for the simulator.
Error launching application on iPhone XS Max.
Exited (sigterm)
memo
I've read this issue, but I cannot resolve this.
https://github.com/flutter/flutter/issues/10089

Sorry, this problem is not caused by Flutter.
GVM(a version management tool of go) overrides diff command.
So, diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null always failed.
$ cd /Users/#{your_user_name}/Library/Developer/Xcode/DerivedData/Runner-{some_hash}/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build
# there are some .sh file. one of them.
$ cat Script-527F3B8B313E5250A155F99B.sh
#!/bin/sh
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [ $? != 0 ] ; then
# print error to STDERR
echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2
exit 1
fi
# This output is used by Xcode 'outputs' to avoid re-running this script phase.
echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"
to fix
configure .zshrc or so on to use default diff command.

Related

CocoaPods could not find compatible versions for pod "UMCore"

🐛 Bug Report
Summary of Issue
When running pod install after following the steps to install unimodules by changing AppDelegate.h, AppDelegate.m and Podfile getting an error.
Environment - output of expo diagnostics & the platform(s) you're targeting
Expo CLI 4.0.13 environment info:
System:
OS: macOS 11.1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.15.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.8 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.0 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK:
API Levels: 26, 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 30.0.3
System Images: android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6514223
Xcode: 12.3/12C33 - /usr/bin/xcodebuild
npmPackages:
react: 16.13.1 => 16.13.1
react-dom: ^16.13.0 => 16.13.0
react-native: 0.63.4 => 0.63.4
npmGlobalPackages:
expo-cli: 4.0.13
Expo Workflow: bare
Reproducible Demo
The error is as follows:
[!] CocoaPods could not find compatible versions for pod "UMCore":
In Podfile:
UMCore (from `../node_modules/#unimodules/core/ios`)
UMPermissionsInterface (from `../node_modules/unimodules-permissions-interface/ios`) was resolved to 5.4.0, which depends on
UMCore
Specs satisfying the `UMCore (from `../node_modules/#unimodules/core/ios`), UMCore` dependency were found, but they required a higher minimum deployment target.
Steps to Reproduce
npm install --save react-native-unimodules
Follow steps here: https://docs.expo.io/bare/installing-unimodules/
pod install in the ios directory
Expected Behavior vs Actual Behavior
Expected behavior is that pod install works without any errors, but instead getting the error shown in the Reproducible Demo section.
This issue is coming because development target of library UMCore pod file is greater than the development target of your project. To solve this find pod file of the UMCore library and check the value of s.ios.deployment_target. If the value development target is greater than your project development target then set the same target value for your project development target.
To change the your project development target open project in xcode. From xcode general tab > Deployment Info. Here you can change.

'UserAgent.h' file not found flutter firebase iOS

I am working on flutter application with firebase, when i use the firebaseAuth plugin application give the following error
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Running pod install...
Running Xcode build...
Xcode build done. 131.2s
Failed to build iOS app
Error output from Xcode build:
↳
2020-02-28 16:05:06.832 XCBBuildService[68423:382033] Failed to remove:
/Users/apple/Library/Developer/Xcode/DerivedData/Runner- hfqwisipukhnqobtbsvjhfltdbgs/Build/Intermediates.noindex/XCBuildData/1be627f6c729f1a388e5fec96804d392-manifest.xcbuild: unlink(/Users/apple/Library/Developer/Xcode/DerivedData/Runner-hfqwisipukhnqobtbsvjhfltdbgs/Build/Intermediates.noindex/XCBuildData/1be627f6c729f1a388e5fec96804d392-manifest.xcbuild): No such file or directory (2)
2020-02-28 16:05:07.269 XCBBuildService[68423:382033] Failed to remove: /Users/apple/Library/Developer/Xcode/DerivedData/Runner-hfqwisipukhnqobtbsvjhfltdbgs/Build/Intermediates.noindex/XCBuildData/1be627f6c729f1a388e5fec96804d392-desc.xcbuild: unlink(/Users/apple/Library/Developer/Xcode/DerivedData/Runner-hfqwisipukhnqobtbsvjhfltdbgs/Build/Intermediates.noindex/XCBuildData/1be627f6c729f1a388e5fec96804d392-desc.xcbuild): No such file or directory (2)
* BUILD FAILED *
Xcode's output:
↳
/Users/apple/Library/Android/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.15.5+2/darwin/Classes/FLTFirebaseAuthPlugin.m:7:9: fatal error: 'UserAgent.h' file not found
#import "UserAgent.h"
^~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
i am using these libraries-
firebase_auth: ^0.15.5+2
firebase_storage: ^3.1.1
cloud_firestore: ^0.13.4
anyone have idea how to solve this error?, i have already done following things
flutter clean
deleted podfile.lock
deleted pods folder
pod deintegrate
pod repo update
pod install
but don't help me to solve this error
We were struggling with the same error. It seems it's a firebase_auth dependency bug (firebase_core v0.4.4+2).
First, run flutter clean, then change your dependencies on pubspec.yaml to
dependencies:
firebase_auth: 0.15.4
dependency_overrides:
firebase_core: 0.4.4
Hope it helps!

react native ios build succeeds but path to app bundle is wrong

When I run react-native run-ios build succeeds and created build folder under ios. But after build, when installation starts, get the below error. The project runs successfully when I run it through xcode. What I observed is that path beginning 'DerivedData' is wrong. Instead it should be 'build'. When I rename my 'build' folder to 'DerivedData' and re-run 'react-native run-ios' the whole process completes successfully but of course with the previous build.
How can I change the 'DerivedData' to 'build'?
This error occurred immediately after I upgraded from 0.59.9 to 0.60.0.
Error:
info Installing "DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app"
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
error Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
. Run CLI with --verbose flag for more details.
Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier DerivedData/Build/Products/Debug-iphonesimulator/mobileappname.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnSimulator (/Users/armaneker/WebstormProjects/mobileappname/node_modules/#react-native-community/cli-platform-ios/build/commands/runIOS/index.js:189:45)
at process._tickCallback (internal/process/next_tick.js:68:7)
React Native version:
System:
OS: macOS 10.15
Binaries:
Node: 10.15.3 - /usr/local/bin/node
npm: 6.13.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.0 => 0.60.0
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Steps To Reproduce
used rn-diff-purge to upgrade from 0.59.9 to 0.60.0
android worked correctly
react-native run-ios build succeeded but installation of
app failed
The solution is not obvious, react-native-cli is trying to guess what xcode build configuration is currently setup on your computer which is what is happening on the function getBuildPath()
function getBuildPath(configuration, appName, isDevice, scheme) {
let device;
if (isDevice) {
device = 'iphoneos';
} else if (appName.toLowerCase().includes('tvos')) {
device = 'appletvsimulator';
} else {
device = 'iphonesimulator';
}
let buildPath = `build/${scheme}/Build/Products/${configuration}-${device}/${appName}.app`; // Check wether app file exist, sometimes `-derivedDataPath` option of `xcodebuild` not works as expected.
if (!_fs().default.existsSync(_path().default.join(buildPath))) {
return `DerivedData/Build/Products/${configuration}-${device}/${appName}.app`;
}
return buildPath;
}
The trick is not to patch this file, but to first setup your xcode configuration correctly Xcode > Preferences > Locations (see picture)
and Xcode > Preferences > Locations > Advanced
Once this is done, you have to cleanup your build folder, otherwise, react-native-cli will still assume that xcode is not behaving as expected, which will keep on producing the same error.
cd ios && rm -rf build
you can now execute npx react-native run-ios and everything should be fine again.
It took me quite some time to figure this out, I think that react-native-cli should output more details on what is going on under the hood for people not to be blocked.
Problem solved. I had to edit a file inside #react-native-community.
If anyone else has the same problem solution is below.
File location:
-> file:
-> node_modules
-> #react-native-community
-> cli-platform-ios
-> build
-> commands
-> runIOS
-> index.js line 314
Change:DerivedData/Build/Products/${configuration}-${device}/${appName}.app
To:build/Build/Products/${configuration}-${device}/${appName}.app
Cheers.

react-native run-ios can not find any simulator

I have been facing an issue where 'react-native run-ios' can not start, regardless of the simulator I add to the --simulator argument.
XCode has the correct location for the 'command line tools'
I am always getting the error:
Could not find iPhone X simulator
Error: Could not find iPhone X simulator
at resolve (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/eric/.../swim/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/eric/.../swim/node_modules/react-native/local-cli/cliEntry.js:117:22)
react-native info
> React Native Environment Info:
> System:
> OS: macOS 10.14.2
> CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU # 2.90GHz
> Memory: 6.76 GB / 32.00 GB
> Shell: 3.2.57 - /bin/bash
> Binaries:
> Node: 10.15.0 - /usr/local/bin/node
> Yarn: 1.13.0 - /usr/local/bin/yarn
> npm: 6.4.1 - /usr/local/bin/npm
> SDKs:
> iOS SDK:
> Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
> IDEs:
> Android Studio: 3.1 AI-173.4819257
> Xcode: 10.1/10B61 - /usr/bin/xcodebuild
> npmPackages:
> react: 16.6.3 => 16.6.3
> react-native: 0.57.8 => 0.57.8
> npmGlobalPackages:
> create-react-native-app: 1.0.0
> react-native-cli: 2.0.1
> react-native-git-upgrade: 0.2.7
Update
It is fixed in v1.9.8.
Update cli is the easy solution
npm install -g react-native-cli#latest
This issue is fixed but not released yet.
https://github.com/react-native-community/react-native-cli/pull/274
So it can be solved temporarily to fix the file below.
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Change this line
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
to
if (!version.includes('iOS') && !version.includes('tvOS')) {
Do not forget apply this again when you reinstall packages.
I've found a temporary fix:
In the following file:
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
...change line 42 to:
if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('tvOS')) {
I tried like below
Open Xcode. Then Preferences -> Select Components in Tabs.
Then install any one(or more) of the available simulators on the list. Preferably the recent one at the top.
It solves the problem.
Try this script from Terminal
sed -i '' 's/startsWith/includes/g' node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Now run
react-native run-ios
Just do
npm install
Then it will show warnings, then fix them by using following command
npm audit fix
Here is additional temporary fix too. I am using Catalina.
I this file:
/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
Change line 42 to:
if (!version.includes('iOS') && !version.includes('tvOS')) {
Change line 52-53 from:
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
to:
simulator.isAvailable !== true
because the returned json list from command xcrun simctl list --json devices, the property isAvailable is boolean and didn't have property 'availability'.
Just modify the findMatchingSimulator.js in node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js.
First boot a Simulator then run xcrun simctl list --json devices and search the one with "state" : "Booted",.
Then add at the top in the findMatchingSimulator function:
return {
udid: <uuid from booted device>, // 'BFA2D7D0-AD49-472F-8279-585DDBBF9151'
name: <Name of the booted simulator>, //"iPhone X"
booted: true,
version: "com.apple.CoreSimulator.SimRuntime.iOS-13-1",
}
I solved it by replacing line number 62 in YourProjectFolder/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
This line
if (
simulator.availability !== '(available)' &&
simulator.isAvailable !== 'YES'
) {
With this one
if (
!simulator.isAvailable
) {
In some case there may be some different solutions for everyone just debug findMatchingSimulator.js file by putting console.log() so you'll know why it is not detecting simulator. In my case the xcrun simctl list devices --json command not providing simulator.availability and simulator.isAvailable is not string it's bool.
I printed the simulator list which command is returning through the following line
console.log(JSON.stringify(simulator.simulatorName));
console.log(simulator.isAvailable);
console.log('-------------------------------------------------------------');
The after running command react-native run-ios --simulator="iPhone SE" I got output in the terminal and fixed code according to console print. And my simulator was running.
try npm install --force if you don't want to break your app with npm audit fix

Exception while building a Flutter application

I am trying to build this Flutter app cloned from GitHub.
After I resolved all the dependency errors, I see the following failure :
FAILURE: Build failed with an exception.
s
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (26.1.0) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Gradle build failed: 1
I am stuck with this problem. Can someone help me out ?
The current versions of dependencies on my machine are as follows :
image_picker: ^0.4.10
google_sign_in: ^3.0.5
firebase_analytics: ^1.0.3
firebase_auth: ^0.5.20
firebase_database: ^1.0.4
firebase_storage: ^1.0.2

Resources