Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package_info broken on ios #20761

Closed
Rockvole opened this issue Aug 17, 2018 · 28 comments
Closed

package_info broken on ios #20761

Rockvole opened this issue Aug 17, 2018 · 28 comments
Assignees
Labels
c: crash Stack traces logged to the console p: package_info The PackageInfo plugin package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically

Comments

@Rockvole
Copy link

I read the package_info in my code which works fine on Android.
On the IPhone 6 Plus - 11.4 the code just gives a stack trace.
Code line which crashes :

PackageInfo packageInfo = await PackageInfo.fromPlatform();

Version of package_info is the latest ^0.3.2
Error is :

*** First throw call stack:
(
	0   CoreFoundation                      0x000000010660a1e6 __exceptionPreprocess + 294
	1   libobjc.A.dylib                     0x0000000105856031 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010664a0bc _CFThrowFormattedException + 194
	3   CoreFoundation                      0x000000010651d951 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
	4   CoreFoundation                      0x000000010651d7db +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
	5   package_info                        0x00000001051fe6a3 -[FLTPackageInfoPlugin handleMethodCall:result:] + 707
	6   Flutter                             0x0000000103aaa3e3 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 118
	7   Flutter                      <…>
@Rockvole
Copy link
Author

Rockvole commented Aug 17, 2018

[✓] Flutter (Channel master, v0.5.9-pre.29, on Mac OS X 10.13.6 17G65, locale en-CA)
    • Flutter version 0.5.9-pre.29 at /work/installs/flutter
    • Framework revision 5311dff1f4 (4 days ago), 2018-08-13 13:35:51 -0700
    • Engine revision e54bc4ea18
    • Dart version 2.0.0-dev.69.5.flutter-eab492385c

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
    • Android SDK at /Users/david/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4.1, Build version 9F2000
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 27.1.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Connected devices (1 available)
    • iPhone 6 Plus • AD0930B1-ED30-4370-ACCF-279F86A48CAD • ios • iOS 11.4 (simulator)

• No issues found!

@Rockvole
Copy link
Author

@goderbauer

@Rockvole
Copy link
Author

@Rockvole
Copy link
Author

I have found out how to reproduce this stack trace.
It seems to be related to the newly introduced :

version: 1.0.0+1

line in pubspec.yaml

If you comment out this line (or use an old project which does not have this line). Then you need to do a clean (I do it in XCode). You will get the stacktrace at the fromPlatform() line.

@cbracken
Copy link
Member

cbracken commented Aug 20, 2018

/cc @bparrishMines too

@Rockvole thanks for reporting this! Sounds like us failing to check for nil values before putting them into the NSDictionary.

@Rockvole
Copy link
Author

You are welcome :)

@zoechi zoechi added this to the Goals milestone Aug 21, 2018
@rtolar
Copy link

rtolar commented Oct 30, 2018

I also have this issue.
The workaround stated above (add a 'version' tag in the pubspec.yaml) also works for me.

When I first used this feature on Oct 9, 2018, it worked correctly.
On Oct 30, 2018 I noticed that it was causing an application crash.
While I had not changed the immediate code line that causes this crash:

PackageInfo packageInfo = await PackageInfo.fromPlatform();

I had done other code changes in the application, and flutter upgrades.

For me, the crash only presents on iOS (not Android), and only in debug mode.
Release builds don't crash.
Occurs in both iOS simulator (iPhone XS Max), and physical phone (iphone X).

*** First throw call stack:
(
	0   CoreFoundation                      0x000000010ff7e29b __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x000000010f51a735 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010fec88fc _CFThrowFormattedException + 194
	3   CoreFoundation                      0x000000010ffed5a1 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
	4   CoreFoundation                      0x000000010ff79d7b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
	5   package_info                        0x000000010eecb6a0 -[FLTPackageInfoPlugin handleMethodCall:result:] + 720
	6   Flutter                             0x000000010d6c59df __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 118
	7   Flutter                      <…>
Lost connection to device.


Richards-MacBook-Pro:myapp3 mylogin$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.10.1, on Mac OS X 10.14 18A391, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
[✓] Android Studio (version 3.2)
[✓] Connected device (2 available)

• No issues found!

@ralph-bergmann
Copy link
Contributor

I have problems to reproduce it :-(

When I comment out version: 1.0.3+3 in pubspec.yaml I get in ios/Flutter/Generated.xcconfig

// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/ralphbergmann/development/github/flutter
FLUTTER_APPLICATION_PATH=/Users/ralphbergmann/development/flutter/foo
FLUTTER_TARGET=/Users/ralphbergmann/development/flutter/foo/lib/main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
FLUTTER_FRAMEWORK_DIR=/Users/ralphbergmann/development/github/flutter/bin/cache/artifacts/engine/ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1

and if it is not commented out I get:

// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/ralphbergmann/development/github/flutter
FLUTTER_APPLICATION_PATH=/Users/ralphbergmann/development/flutter/foo
FLUTTER_TARGET=/Users/ralphbergmann/development/flutter/foo/lib/main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
FLUTTER_FRAMEWORK_DIR=/Users/ralphbergmann/development/github/flutter/bin/cache/artifacts/engine/ios
FLUTTER_BUILD_NAME=1.0.3
FLUTTER_BUILD_NUMBER=3

In both cases, the app runs on iOS and shows the values of FLUTTER_BUILD_NAME/FLUTTER_BUILD_NUMBER

$ flutter doctor -v
[✓] Flutter (Channel master, v0.10.2-pre.131, on Mac OS X 10.13.6 17G65, locale de-DE)
    • Flutter version 0.10.2-pre.131 at /Users/ralphbergmann/development/github/flutter
    • Framework revision 01c7081565 (10 hours ago), 2018-10-31 21:12:51 -0700
    • Engine revision c79faed71c
    • Dart version 2.1.0 (build 2.1.0-dev.8.0 bf26f760b1)

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

@ralph-bergmann
Copy link
Contributor

ralph-bergmann commented Nov 1, 2018

to test it I used the code from the package_info example with package_info version 0.3.2

@calebisstupid
Copy link

calebisstupid commented Dec 11, 2018

This is also broken for me. I am getting an immediate "Lost connection to device" when using the PackageInfo.fromPlatform(); call. No logs from flutter, I do get logs when running in Xcode:

2018-12-11 13:44:38.830823-0600 Runner[1590:860792] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]'

Edit to add: I am using this within a package I am generating. I have been able to reproduce it from a fresh package built from flutter create --org com.example --template=plugin hello by adding package_info: ^0.3.2 as a dependency and adding PackageInfo packageInfo = await PackageInfo.fromPlatform(); to the first line of playformVersion in hello.dart.

Edit 2: Just adding that I believe I got this fixed. The example project was not properly setting the flutter properties in the plist. I replaced the following with actual string values and it is working:

${PRODUCT_BUNDLE_IDENTIFIER)
${FLUTTER_BUILD_NAME)
${FLUTTER_BUILD_NUMBER)

I'll leave it to people much more familiar than myself to determine if this is a bug or I just don't know what I'm doing.

@HerrNiklasRaab
Copy link

HerrNiklasRaab commented Dec 21, 2018

Same Problem here!
Behavior exactly like @rtolar described.
@calebisstupid I added the flutter properties in the plist file, but it does not seem to fix the exception.

@amirh amirh added the p: package_info The PackageInfo plugin label Jan 3, 2019
@jonahwilliams
Copy link
Member

This also came up recently in my discussion with @matanlurey

@amirh amirh modified the milestones: Goals, Near-term Goals Jan 10, 2019
@cyanglaz
Copy link
Contributor

cyanglaz commented Jan 14, 2019

The crash on iOS has been fixed on package_info version 0.3.2+1
Closing the issue, if issue still persists after updating to 0.3.2+1, please reopen the issue and any additional details would be appreciated.

@cyanglaz cyanglaz self-assigned this Jan 14, 2019
@oliverbytes
Copy link

This is also broken for me. I am getting an immediate "Lost connection to device" when using the PackageInfo.fromPlatform(); call. No logs from flutter, I do get logs when running in Xcode:

2018-12-11 13:44:38.830823-0600 Runner[1590:860792] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]'

Edit to add: I am using this within a package I am generating. I have been able to reproduce it from a fresh package built from flutter create --org com.example --template=plugin hello by adding package_info: ^0.3.2 as a dependency and adding PackageInfo packageInfo = await PackageInfo.fromPlatform(); to the first line of playformVersion in hello.dart.

Edit 2: Just adding that I believe I got this fixed. The example project was not properly setting the flutter properties in the plist. I replaced the following with actual string values and it is working:

${PRODUCT_BUNDLE_IDENTIFIER)
${FLUTTER_BUILD_NAME)
${FLUTTER_BUILD_NUMBER)

I'll leave it to people much more familiar than myself to determine if this is a bug or I just don't know what I'm doing.

I got a similar issue with yours. Instead of manually changing the values of

> ${PRODUCT_BUNDLE_IDENTIFIER)
> ${FLUTTER_BUILD_NAME)
> ${FLUTTER_BUILD_NUMBER)

I just deleted the /ios folder and recreated it again by running flutter create . And now it's back to normal.

@herkulano
Copy link

@cyanglaz I still don't get the version and buildNumber on iOS, works fine on Android.

package_info: ^0.4.0

version == null
buildNumber == ''
18:49:12.455 8 info flutter.tools [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: Invalid argument(s)
18:49:12.455 9 info flutter.tools #0      _StringBase.+ (dart:core/runtime/libstring_patch.dart:261:57)
18:49:12.455 10 info flutter.tools #1      checkPackageInfo.<anonymous closure> (package:xxx/main.dart:19:27)
18:49:12.455 11 info flutter.tools #2      _rootRunUnary (dart:async/zone.dart:1132:38)
18:49:12.455 12 info flutter.tools #3      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
18:49:12.455 13 info flutter.tools #4      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
18:49:12.455 14 info flutter.tools #5      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
18:49:12.455 15 info flutter.tools #6      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
18:49:12.455 16 info flutter.tools #7      Future._complete (dart:async/future_impl.dart:473:7)
18:49:12.455 17 info flutter.tools #8      _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
18:49:12.455 18 info flutter.tools #9      _rootRunUnary (dart:async/zone.dart:1132:38)
18:49:12.455 19 info flutter.tools #10     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
18:49:12.455 20 info flutter.tools #11     _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
18:49:12.455 21 info flutter.tools #12     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
18:49:12.455 22 info flutter.tools #13     Future._propagateTo<…>

@cyanglaz
Copy link
Contributor

@herkulano are you checking it on a real device or simulator? Can we post your flutter doctor -v here?
Also, could you paste your code snippet here as well?

@herkulano
Copy link

@cyanglaz I'm using the simulator only.

void checkPackageInfo() {
  PackageInfo.fromPlatform().then((packageInfo) {
    print('--> appName: ' + packageInfo.appName);
    print('--> packageName: ' + packageInfo.packageName);
    print('--> version: ' + packageInfo.version);
    print('--> buildNumber: ' + packageInfo.buildNumber);
  });
}

void main() {
  checkPackageInfo();
  runApp(App());
}
➜ flutter doctor -v
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.4 18E226, locale en-US)
    • Flutter version 1.2.1 at /Users/Herc/SDKs/flutter
    • Framework revision 8661d8aecd (2 months ago), 2019-02-14 19:19:53 -0800
    • Engine revision 3757390fa4
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/Herc/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • ios-deploy 1.9.4
    • CocoaPods version 1.6.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 34.0.2
    • Dart plugin version 183.5901
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.33.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.25.1

[✓] Connected device (1 available)
    • iPhone Xʀ • C8750C6A-CD60-4A81-9FC9-8961D68843E3 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)

• No issues found!

@cyanglaz
Copy link
Contributor

Your code snippet works for me. Could you check if your iOS runner app has version and build number set up?
You can:

1. Launch XCode, open the project at /ios/Runner.xcworkspace
2. Select `Runner` project in the left panel
3. select `Runner` target in the left panel inside the middle section, select `general` tab
4. Check if `Version` and `Build` is set in the Identity section.

@herkulano
Copy link

@cyanglaz it's set to:

$(FLUTTER_BUILD_NAME)
$(FLUTTER_BUILD_NUMBER)

Screen Shot 2019-04-26 at 11 36 19

@cyanglaz
Copy link
Contributor

@herkulano Did you set version in your pubspec.yaml. Like version: 1.0.3+2 where 1.0.3 is FLUTTER_BUILD_NAME and 2 is FLUTTER_BUILD_NUMBER
hope that helps.

@herkulano
Copy link

@cyanglaz I ended up solving it by recreating the files and going through the changes with

flutter create .

@Koshub
Copy link

Koshub commented May 17, 2019

For my current project setup (several flutter version updates) I have out of sync flutter app iOS version with pubspec.yaml version automatically. Fixed by cleaning XCode build folder: XCode Menu -> Product -> (Holding Option Key) Clean build folder. Then rebuild flutter app.

@HugoHeneault
Copy link

HugoHeneault commented Mar 26, 2020

2020 update: Have tried it on iOS and build number seems to be updated without any issue... Am I the only one? 🤔
Maybe it's time to remove the warning on readme?

@maheshj01
Copy link
Member

2020 update: Have tried it on iOS and build number seems to be updated without any issue... Am I the only one? 🤔
Maybe it's time to remove the warning on readme?

I still see some issue with ios

@HugoHeneault
Copy link

@maheshmnj Which kind? Could you please share some logs?

@maheshj01
Copy link
Member

maheshj01 commented Apr 1, 2020

image
I have changed version code from +1 to 2 and when I fetch it in IOS. it still shows version code 1
tried @Koshub 's answer and did clean build folder in xcode still its same
its working in android though,also when I open this project in xcode it still shows build as 1
image

my flutter doctor -v shows this output

mac006@mac006s-mbp ios % cd ..
mac006@mac006s-mbp iborganic % flutter doctor -v 
[✓] Flutter (Channel master, v1.16.3, on Mac OS X 10.15.4 19E266, locale en-GB)
    • Flutter version 1.16.3 at /Users/mac006/Documents/flutter
    • Framework revision be3a4b37b3 (5 days ago), 2020-03-26 18:08:05 -0700
    • Engine revision b2bdeb3f0f
    • Dart version 2.8.0 (build 2.8.0-dev.17.0 1402e8e1a4)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/mac006/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] 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.9.1

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.43.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.8.1

[✓] Connected device (2 available)
    • Android SDK built for x86 • emulator-5554                        • android-x86 • Android 10 (API 29) (emulator)
    • iPhone 11 Pro Max         • 239ACB82-12EF-47BB-9285-B3597C525ACA • ios         • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

• No issues found!

@maheshj01
Copy link
Member

however when i manually change the build in xcode and rebuid the app it works :)

@lock
Copy link

lock bot commented Apr 15, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators Apr 15, 2020
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console p: package_info The PackageInfo plugin package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically
Projects
None yet
Development

No branches or pull requests