leancodepl / patrol

Flutter-first UI testing framework. Ready for action!
https://patrol.leancode.co
Apache License 2.0
873 stars 131 forks source link

Undefined symbol: _GCDAsyncSocketManuallyEvaluateTrust #2255

Closed BenjiFarquhar closed 2 months ago

BenjiFarquhar commented 3 months ago

Steps to reproduce

I can't run my app on iOS anymore (not even just the tests, the actual main app doesn't run).

Actual results

In the debug console:

Error (Xcode): Undefined symbol: _GCDAsyncSocketManuallyEvaluateTrust

Error (Xcode): Undefined symbol: _OBJC_CLASS_$_GCDAsyncSocket

Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)

The full error in Xcode is is for the job "Link Patrol (arm64)". Note that "Link Patrol (x86_64)" works. When i run pod install i always have to run arch x86_64 pod install. Is my pod setup outdated?

The pertinent part of the error:

Undefined symbols for architecture arm64:
  "_GCDAsyncSocketManuallyEvaluateTrust", referenced from:
      patrol.TCPSocket.startTLS(config: patrol.TLSConfig) -> () in TCPSocket.o
  "_OBJC_CLASS_$_GCDAsyncSocket", referenced from:
       in TCPListener.o
ld: symbol(s) not found for architecture arm64

The full error:

Ld /Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/Pods.build/Debug-development-iphonesimulator/patrol.build/Objects-normal/arm64/Binary/patrol normal arm64 (in target 'patrol' from project 'Pods')
    cd /Users/benjaminfarquhar/dev/vepo_front_end/ios/Pods
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios14.0-simulator -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk -Os -L/Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-development-iphonesimulator -L/Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Products/Debug-development-iphonesimulator/patrol -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/lib/swift -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib -F/Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-development-iphonesimulator -F/Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Products/Debug-development-iphonesimulator/patrol -F/Users/benjaminfarquhar/development/flutter/bin/cache/artifacts/engine/ios-release/Flutter.xcframework/ios-arm64_x86_64-simulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -F/Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Products/Debug-development-iphonesimulator/CocoaAsyncSocket -iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/Developer/Library/Frameworks -filelist /Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/Pods.build/Debug-development-iphonesimulator/patrol.build/Objects-normal/arm64/patrol.LinkFileList -install_name @rpath/patrol.framework/patrol -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/Pods.build/Debug-development-iphonesimulator/patrol.build/Objects-normal/arm64/patrol_lto.o -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -debug_variant -fobjc-arc -fobjc-link-runtime -fprofile-instr-generate -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/Pods.build/Debug-development-iphonesimulator/patrol.build/Objects-normal/arm64/patrol.swiftmodule -framework CFNetwork -framework CocoaAsyncSocket -framework Security -framework UIKit -weak_framework XCTest -framework Flutter -framework Foundation -framework UIKit -Xlinker -no_adhoc_codesign -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/Pods.build/Debug-development-iphonesimulator/patrol.build/Objects-normal/arm64/patrol_dependency_info.dat -o /Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/Pods.build/Debug-development-iphonesimulator/patrol.build/Objects-normal/arm64/Binary/patrol

ld: warning: ignoring file '/Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-development-iphonesimulator/CocoaAsyncSocket.framework/CocoaAsyncSocket.tbd': tapi error: missing required architecture arm64 in file /Users/benjaminfarquhar/Library/Developer/Xcode/DerivedData/Runner-fthfjngncvusindjscndkyoymshq/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-development-iphonesimulator/CocoaAsyncSocket.framework/CocoaAsyncSocket.tbd
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
Undefined symbols for architecture arm64:
  "_GCDAsyncSocketManuallyEvaluateTrust", referenced from:
      patrol.TCPSocket.startTLS(config: patrol.TLSConfig) -> () in TCPSocket.o
  "_OBJC_CLASS_$_GCDAsyncSocket", referenced from:
       in TCPListener.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If i try to run it in Xcode I get the same errors, but they are under the Patrol folder:

Screenshot 2024-07-07 at 8 47 54 AM

Patrol version

patrol: ^3.9.0

Patrol Doctor output

Patrol Doctor output ``` Patrol doctor: Patrol CLI version: 2.8.1 Flutter command: flutter Flutter 3.22.2 • channel stable Android: • Program adb found in /Users/benjaminfarquhar/Library/Android/sdk/platform-tools/adb • Env var $ANDROID_HOME set to /Users/benjaminfarquhar/Library/Android/sdk iOS / macOS: • Program xcodebuild found in /usr/bin/xcodebuild • Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller ```

Flutter Doctor output

Flutter Doctor output ``` [✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-GB) • Flutter version 3.22.2 on channel stable at /Users/benjaminfarquhar/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (4 weeks ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/benjaminfarquhar/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/benjaminfarquhar/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) [✓] IntelliJ IDEA Community Edition (version 2023.2.2) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart [✓] VS Code (version 1.91.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.92.0 [✓] Connected device (5 available) • Benji’s iPhone 13 mini (mobile) • 00008110-001119123C7B801E • ios • iOS 17.5.1 21F90 • iPhone 15 Pro (mobile) • 71C2F283-7754-4947-83DB-338111A5D7E8 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127 [✓] Network resources • All expected network resources are available. • No issues found! ```
BenjiFarquhar commented 3 months ago

Should we even be needing patrol pods and doing build steps for patrol when running the non-test version of our app?

I seem to have fixed it anyway.

I think i was missing the CocoaAsyncSocket (7.6.5) pod completely, which is a necessary pod for patrol.

Something I did added this to the podspec.lock:

PODS:
  - CocoaAsyncSocket (7.6.5)

I think it was pod deintegrate and then deleted podspec.lock and ran pod install --repo-update.

I also needed this in target.build_configurations.each do |config| of the podfile:

      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'

I already had it in installer.pods_project.build_configurations.each do |config|, but that wasn't enough.

Now my whole pod_install is:

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end

  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'

      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',
        'PERMISSION_CAMERA=1',
        'PERMISSION_PHOTOS=1',
        'PERMISSION_LOCATION=1',
      ]
    end
  end
end

Unrelated but I fixed my having to add arch -x86_64 to pod install by uninstalling cocoapods and then reinstalling them with homebrew (i think it got the latest version of cocoapods which fixed it).

zoskar commented 2 months ago

Hi @BenjiFarquhar I'm glad that you managed to fix your problem. If you want us to review this scenario we would need you to provide reproducible example. We cannot proceed without it.

bartekpacia commented 2 months ago

Should we even be needing patrol pods and doing build steps for patrol when running the non-test version of our app?

https://github.com/leancodepl/patrol/issues/681

github-actions[bot] commented 2 months ago

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it. Feel free to open a new issue with all the required information provided, including a minimal, reproducible sample. Make sure to diligently fill out the issue template. Thanks for your contribution.

github-actions[bot] commented 2 months ago

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it. Feel free to open a new issue with all the required information provided, including a minimal, reproducible sample. Make sure to diligently fill out the issue template. Thanks for your contribution.

github-actions[bot] commented 2 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.