Skip to content

flutter build ios --release may use a debug Flutter.framework by mistake #37850

Closed

Description

@bailleul-dev

When I submit my application to Testflight I get the following error from Apple.


ITMS-90338: Non-public API usage - The app references non-public symbols in Frameworks/Flutter.framework/Flutter: _ptrace. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed. For further information, visit the Technical Support Information at http://developer.apple.com/support/technical/


Best regards.

[✓] Flutter (Channel master, v1.8.4-pre.104, on Mac OS X 10.14.5 18F203, locale en-GB)
    • Flutter version 1.8.4-pre.104 at /Users/laibullle/flutter
    • Framework revision 61ede615c0 (2 days ago), 2019-08-06 03:51:25 -0400
    • Engine revision a665c6fbd4
    • Dart version 2.5.0 (build 2.5.0-dev.1.0 8cd01287b4)


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/laibullle/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.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.6.1

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

[✓] Connected device (1 available)
    • macOS • macOS • darwin-x64 • Mac OS X 10.14.5 18F203

• No issues found!

Activity

  1. stuartmorgan-g commented on Aug 8, 2019

    @stuartmorgan-g
    Contributor

    ptrace should only be compiled into debug builds; did you submit a debug build to Apple?

  2. bailleul-dev commented on Aug 8, 2019

    @bailleul-dev
    Author

    No, I did not explicitly submited any debug flag or something like that.

    I fixed the issue in recreating my project from flutter stable, now it works.

  3. sjindel-google commented on Aug 8, 2019

    @sjindel-google
    Contributor

    @laibulle: I have double-checked that _ptrace is not referenced by release builds of Flutter.framework. Perhaps you copied the build after running flutter run, which creates a debug build by default?

    The issue may re-appear the next time you upgrade Flutter if you're not using a release build.

  4. bailleul-dev commented on Aug 8, 2019

    @bailleul-dev
    Author

    Yes I think I missed flutter build ios --release

  5. Theunodb commented on Aug 16, 2019

    @Theunodb

    I'm having this issue as well. I made sure to clean everything and to run the correct build command.

    Steps i took:
    (In terminal)

    1. flutter clean
    2. flutter build ios --release
    3. Open xcode and select archive (I tried this by selecting clean in xcode before archiving, and just selecting archive without cleaning.)

    Got a message from apple stating invalid binary.

    The email stated:
    ITMS-90338: Non-public API usage - The app references non-public symbols in Frameworks/Flutter.framework/Flutter: _ptrace.

    ` [✓] Flutter (Channel master, v1.9.1-pre.57, on Mac OS X 10.14.6 18G87, locale
    en-ZA)
    • Flutter version 1.9.1-pre.57 at /Users/td0810/flutter
    • Framework revision 5a4d3cd (2 hours ago), 2019-08-16 01:57:36 -0400
    • Engine revision c29c9bc
    • Dart version 2.5.0 (build 2.5.0-dev.2.1 e35e8833ee)

    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/td0810/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: /Users/td0810/Library/Application
    Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/183.5692245/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.

    [!] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    ✗ CocoaPods installed but not initialized.
    CocoaPods is used to retrieve the iOS and macOS platform side's plugin
    code that responds to your plugin usage on the Dart side.
    Without CocoaPods, plugins will not work on iOS or macOS.
    For more info, see https://flutter.dev/platform-plugins
    To initialize CocoaPods, run:
    pod setup
    once to finalize CocoaPods' installation.

    [✓] Android Studio (version 3.4)
    • Android Studio at /Users/td0810/Library/Application
    Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/183.5692245/Android
    Studio.app/Contents
    • Flutter plugin version 38.2.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build
    1.8.0_152-release-1343-b01)

    [✓] IntelliJ IDEA Ultimate Edition (version 2019.2)
    • IntelliJ at /Users/td0810/Applications/JetBrains Toolbox/IntelliJ IDEA
    Ultimate.app
    • Flutter plugin version 38.2.4
    • Dart plugin version 192.6262.13

    [!] Connected device
    ! No devices available
    `

  6. sjindel-google commented on Aug 17, 2019

    @sjindel-google
    Contributor

    That's very strange. I cannot reproduce this issue.

    Can you please try the following:

    1. Select the Archive you uploaded to Apple in Finder.
    2. Right click => show package contents
    3. Products => Applications
    4. Right click on your App icon => open Terminal window here
    5. Run this command in the terminal:
    nm <App Name> | grep ptrace
    

    What output do you get?

  7. Theunodb commented on Aug 19, 2019

    @Theunodb

    I followed the steps above. Couldn't find ptrace anywhere. Not sure why apple would still reject it. I switched to stable and managed to submit fine. Will switch back to master for the next release and try everything again. Thanks for your help anyway.

    PS. This is the content of the package that failed:

    https://gist.github.com/zanderso/6b1d7ee6180d752df17c63dfd3b6fe39

  8. sjindel-google commented on Aug 19, 2019

    @sjindel-google
    Contributor

    @Theunodb I'm sorry for my earlier mistake, could you actually provide the output of nm Frameworks/Flutter.framework/Flutter (in the archive uploaded to Apple) instead?

  9. Theunodb commented on Aug 20, 2019

    @Theunodb

    Sorry for the delay. Running that command gave me:
    U _ptrace U _ptrace

  10. sjindel-google commented on Aug 20, 2019

    @sjindel-google
    Contributor

    @Theunodb That's the problem. Release-builds of Flutter.framework do not have that symbol, I've confirmed locally.

    It appears that somehow you're still uploading a debug build.
    An easy way to check that is to run the App from within Xcode (before Archiving it) and look for the "Debug" banner on the top-right (assuming you haven't done anything to remove it).

  11. zanderso commented on Aug 20, 2019

    @zanderso
    Member

    It sounds like @Theunodb may have hit a bug in which flutter build ios --release uses a debug Flutter.framework by mistake. I will reopen and adjust the issue to reflect this.

  12. changed the title [-]ITMS-90338: Non-public API usage: Frameworks/Flutter.framework/Flutter: _ptrace[/-] [+]flutter build ios --release may use a debug Flutter.framework by mistake[/+] on Aug 20, 2019
  13. added
    a: annoyanceRepeatedly frustrating issues with non-experimental functionality
    on Aug 20, 2019
  14. 85 remaining items

  15. barrettbreshears commented on Dec 18, 2019

    @barrettbreshears

    Just thought I would add my doctor output since this is happening on the stable branch with v1.12.13

    `Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-US)

    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 11.3)
    [✓] Android Studio (version 3.5)
    [✓] VS Code (version 1.41.0)
    [✓] Connected device (1 available)

    • No issues found!`

  16. jmagman commented on Dec 18, 2019

    @jmagman
  17. barrettbreshears commented on Dec 19, 2019

    @barrettbreshears

    I was able to fix my environment. I think this must have been an update issue for me. I selected v1.9.1+hotfix.6 and then went back to latest stable channel. cleaned my build and removed my pods folder. just uploaded to app store and got the "The following build has completed processing: and ready for test flight email" . That was a huge pain, I was under a deadline and it sucks when the tools are working.

    Is there any way we could get a document on the best way to remove and reinstall flutter if your system gets messed up?

  18. matte5031 commented on Jan 19, 2020

    @matte5031
  19. jmagman commented on Jan 21, 2020

    @jmagman
  20. rajathk commented on Jan 28, 2020

    @rajathk

    Any update on this? I have tried -

    flutter clean
    rm -rf ios/Flutter/Flutter.framework
    flutter build ios --release

    I have upgraded the flutter SDK too but no luck.

  21. uzumaki258 commented on Feb 6, 2020

    @uzumaki258

    In flutter 1.9.1 hot fix 5
    I can do Product > Scheme > Edit Scheme > Run > Build Configuration: Release
    And it work.
    But in Flutter 1.12.13 it not work anymore.
    Let me try this
    rm -rf ios/Flutter/Flutter.framework

  22. ch-muhammad-adil commented on Feb 20, 2020

    @ch-muhammad-adil

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.1 19B88, locale en-PK)

    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
    [✓] Android Studio (version 3.5)
    [✓] Connected device (1 available)

    I am using stable version and I am facing same issue,

    I have tried above solutions but nothing is working for me.

  23. izinin commented on Jul 29, 2020

    @izinin

    It is sad to see this issue cannot be fixed for 2 years :( -- last year i also struggled to push my release build to Apple app store. I found quickest workaround -- just copy release Flutter.Framework to debug Flutter.Framework and then follow releasing procedure

    > mv ~/flutter/bin/cache/artifacts/engine/ios ~/flutter/bin/cache/artifacts/engine/ios-RESTOREME
    > cp -r ~/flutter/bin/cache/artifacts/engine/ios-release ~/flutter/bin/cache/artifacts/engine/ios
    

    make sure you use correct paths -- i have Flutter in my home directory ~/flutter
    i hope it will help you

  24. jmagman commented on Jul 29, 2020

    @jmagman
    Member

    I'm not sure why this is still happening. By default Archive uses the Release build configuration. You can see that yourself in Xcode with Product > Scheme > Edit Scheme then Archive
    Screen Shot 2020-07-29 at 10 43 45 AM

    On every build, run, test, archive, etc. there's an Xcode build phase that runs the xcode_backend script that lives in the Flutter SDK. It's responsible for compiling your dart code.
    You can see this under your Runner target build settings > Build Phases > Run Script
    Screen Shot 2020-07-29 at 11 00 43 AM

    That script decides which version of the Flutter framework to copy and embed in the app:

    # Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name
    # This means that if someone wants to use an Xcode build config other than Debug/Profile/Release,
    # they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build.
    local build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")"
    local artifact_variant="unknown"
    case "$build_mode" in
    *release*) build_mode="release"; artifact_variant="ios-release";;
    *profile*) build_mode="profile"; artifact_variant="ios-profile";;
    *debug*) build_mode="debug"; artifact_variant="ios";;

    So on archive, $CONFIGURATION will be Release (or you have flavors set up and FLUTTER_BUILD_MODE is release), build_mode will be release and artifact_variant will be ios-release.

    Then it figures out where the framework will be copied from:

    local framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/${artifact_variant}"

    At this point framework_path should be $FLUTTER_ROOT/bin/cache/artifacts/engine/ios-release.

    Then the script scorch earths the framework. derived_dir is ${SOURCE_ROOT}/Flutter (so ios/Flutter from your top-level Flutter project directory) at this point. It rm -rfs the framework at ${SOURCE_ROOT}/Flutter/Flutter.framework, then re-copies it from $FLUTTER_ROOT/bin/cache/artifacts/engine/ios-release to ${SOURCE_ROOT}/Flutter. (This defeats Xcode's app delta attempts, and is partially why iOS compile and install times are slow--this framework is very large due to bitcode).

    RunCommand rm -rf -- "${derived_dir}/Flutter.framework"
    RunCommand cp -- "${flutter_podspec}" "${derived_dir}"
    RunCommand cp -r -- "${flutter_framework}" "${derived_dir}"

    Then it calls into dart to compile your app code.

    After the source is compiled, xcode_backend.sh is invoked again in the last Thin Binary build phase to thin, strip bitcode (if needed) embed, and codesign the Flutter.framework and your compiled dart App.framework.

    Screen Shot 2020-07-29 at 11 10 48 AM

    The script first rsyncs the previously copied Flutter.framework from the Run Script build phase into your app's framework directory. flutter_ios_engine_folder is that same ${SOURCE_ROOT}/Flutter directory where we copied the framework earlier. xcode_frameworks_dir is ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH} which is your Runner.app/Frameworks directory:

    RunCommand rsync -av --delete --filter "- .DS_Store/" --filter "- Headers/" --filter "- Modules/" "${flutter_ios_engine_folder}/Flutter.framework" "${xcode_frameworks_dir}/"

    Note: If you are using any Flutter plugins, they will link against whatever version is in Flutter/Flutter.framework before all the above logic, and CocoaPods handles that, not Flutter's tooling. That dependency runs before the Runner target's build phases, so the above copying happens after all that so it shouldn't matter

    If you add export VERBOSE_SCRIPT_LOGGING=1 to the top of the script build phases right before the xcode_backend.sh call, you can play along at home and see the framework copy happen in your own build logs in the Report Navigator:
    Screen Shot 2020-07-29 at 11 24 28 AM

    Maybe someone reproducing this can tell us where this logic is falling down and copying $FLUTTER_ROOT/bin/cache/artifacts/engine/ios/Flutter.framework instead of $FLUTTER_ROOT/bin/cache/artifacts/engine/ios-release/Flutter.framework

  25. added
    P2Important issues not at the top of the work list
    on Aug 18, 2020
  26. victorykong commented on Jun 17, 2021

    @victorykong
  27. github-actions commented on Jul 31, 2021

    @github-actions

    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.

  28. locked as resolved and limited conversation to collaborators on Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: annoyanceRepeatedly frustrating issues with non-experimental functionalitya: buildBuilding flutter applications with the toolcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.toolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions