Skip to content

clang: error: linker command failed with exit code 1 (Cocoapods issue) #42

@sjmcdowall

Description

@sjmcdowall

Description:

Every once in a while -- after adding a new package (sometimes) or clearing some cache, our application refuses to build on iOS simulators/debug .. and sometimes takes a few tries on production release builds .. with a build error about nothing finding trying to link

OneSignalNotificationServiceExtension

What appears to be happening is that this Ld is premature and all the other Pods needed and listed haven't been compiled yet .. so the ld fails because Flutter puts them all together.. here is the snippest from the fails:

               /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -syslibroot /Applications/Xcode.app/Contents/Developer/Plat
forms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/package_info -filelist /Users/sjm/Library/Developer/Xcode/De
rivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/package_info.build/Objects-normal/x86_64/package_info.LinkFileList -o /Users/sjm/work/mm
/mms4/mobile/build/ios/Debug-iphonesimulator/package_info/libpackage_info.a

           === BUILD TARGET OneSignalNotificationServiceExtension OF PROJECT Runner WITH CONFIGURATION Debug ===

           Check dependencies

           Create product structure
           /bin/mkdir -p /Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/OneSignalNotificationServiceExtension.appex

           ProcessInfoPlistFile /Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/OneSignalNotificationServiceExtension.appex/Info.plist OneSignalNotificationServiceExtension/Info.pl
ist
               cd /Users/sjm/work/mm/mms4/mobile/ios
               export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/sjm/Developme
nt/flutter/bin:/Users/sjm/.fastlane/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:."
               builtin-infoPlistUtility /Users/sjm/work/mm/mms4/mobile/ios/OneSignalNotificationServiceExtension/Info.plist -expandbuildsettings -format binary -platform iphonesimulator -o /Users
/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/OneSignalNotificationServiceExtension.appex/Info.plist

           PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/sjm/Library/Developer/Xcode/DerivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Runner.build/Debug-
iphonesimulator/OneSignalNotificationServiceExtension.build/Script-7206A2BF19E0D481309F4ACF.sh
               cd /Users/sjm/work/mm/mms4/mobile/ios
               /bin/sh -c /Users/sjm/Library/Developer/Xcode/DerivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/OneSignalNotificationSe
rviceExtension.build/Script-7206A2BF19E0D481309F4ACF.sh

           Ld /Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/OneSignalNotificationServiceExtension.appex/OneSignalNotificationServiceExtension normal x86_64
               cd /Users/sjm/work/mm/mms4/mobile/ios
               export IPHONEOS_DEPLOYMENT_TARGET=10.0
               export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/sjm/Developme
nt/flutter/bin:/Users/sjm/.fastlane/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:."
               /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimul
ator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/device_info
-L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/flutter_secure_storage -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/local_auth -L/Users/sjm/work/mm/mms4/mobil
e/build/ios/Debug-iphonesimulator/location -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/onesignal -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/open_file -L
/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/package_info -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/path_provider -L/Users/sjm/work/mm/mms4/mobile/build/i
os/Debug-iphonesimulator/shared_preferences -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/uni_links -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/url_launche
r -F/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator -F/Users/sjm/work/mm/mms4/mobile/ios/Pods/../.symlinks/flutter/ios -F/Users/sjm/work/mm/mms4/mobile/ios/Pods/OneSignal/iOS_SDK/O
neSignalSDK/Framework -filelist /Users/sjm/Library/Developer/Xcode/DerivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/OneSignalNotifica
tionServiceExtension.build/Objects-normal/x86_64/OneSignalNotificationServiceExtension.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Fram
eworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/../../Frameworks -mios-simulator-version-min=10.0 -dead_strip -Xlinker -object_path_lto -Xlin
ker /Users/sjm/Library/Developer/Xcode/DerivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/OneSignalNotificationServiceExtension.build/Objects-normal/x86_64/OneSignalNotificationServiceExtension_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -fapplication-extension -ObjC -ldevice_info -lflutter_secure_storage -llocal_auth -llocation -lonesignal -lopen_file -lpackage_info -lpath_provider -lshared_preferences -luni_links -lurl_launcher -framework Flutter -framework OneSignal -framework SystemConfiguration -framework UIKit -framework UserNotifications -ObjC -framework OneSignal -framework SystemConfiguration -framework UIKit -framework UserNotifications -e _NSExtensionMain -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/sjm/Library/Developer/Xcode/DerivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/OneSignalNotificationServiceExtension.build/OneSignalNotificationServiceExtension.appex-Simulated.xcent -lPods-OneSignalNotificationServiceExtension -Xlinker -dependency_info -Xlinker /Users/sjm/Library/Developer/Xcode/DerivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/OneSignalNotificationServiceExtension.build/Objects-normal/x86_64/OneSignalNotificationServiceExtension_dependency_info.dat -o /Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/OneSignalNotificationServiceExtension.appex/OneSignalNotificationServiceExtension
           ld: warning: directory not found for option '-L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/location'
           ld: library not found for -llocation
           clang: error: linker command failed with exit code 1 (use -v to see invocation)

           === BUILD TARGET path_provider OF PROJECT Pods WITH CONFIGURATION Debug ===

           Check dependencies

           Libtool /Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/path_provider/libpath_provider.a normal x86_64
               cd /Users/sjm/work/mm/mms4/mobile/ios/Pods
               export IPHONEOS_DEPLOYMENT_TARGET=8.0
               export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/sjm/Development/flutter/bin:/Users/sjm/.fastlane/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:."
               /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -L/Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/path_provider -filelist /Users/sjm/Library/Developer/Xcode/DerivedData/Runner-fmfgxmbciwytkiaoztfoxtepvsaw/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/path_provider.build/Objects-normal/x86_64/path_provider.LinkFileList -o /Users/sjm/work/mm/mms4/mobile/build/ios/Debug-iphonesimulator/path_provider/libpath_provider.a

I can include the total flutter run -v output somewhere (it's lengthy) if you tell me where..

I am not sure why it's do an clang thing THEN in the middle of the project builds?? I think that's the culprit ..

Environment

  1. 1.0.3
  2. pub and then followed the instructions

Steps to Reproduce Issue:

  1. Install the OneSignal Flutter SDK using pub into your project
  2. Add a TON of pubspec.yaml dependencies .. lots of which have Pod things..
  3. flutter clean ; flutter run -d XXXX (simulator)

The odd thing is that the first time we run we may get 5/6 "ld" errors.. but each run after reduces that. Sometimes we get 0 and once it's zero we're good again until the next "flutter upgrade" or something that adds a pod .. then all hell breaks loose again . :(

I have this reproducible right now -- can't fix actually ..

Here is our pubspec.yaml file:

name: MissionMode
description: Flutter MissionMode Mobile

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.4.5

environment:
  sdk: '>=2.0.0-dev.68.0 <3.0.0'

dependencies:
  charts_flutter: ^0.5.0
  device_info: ^0.3.0
  dynamic_theme: ^1.0.0
  fluro: ^1.3.4
  flutter_secure_storage: ^3.1.1
  flutter_typeahead: ^0.4.0
  # get_version: ^0.0.6
  graphql_flutter: ^1.0.0-alpha.10
  flutter_html: ^0.8.2
  http: ^0.12.0
  icons_helper:
    git:
      url: git://github.com/sjmcdowall/icons_helper
  # image_picker: ^0.4.10
  local_auth: ^0.3.0
  location: ^1.4.0
  native_widgets: ^0.1.1+1
  open_file: ^1.1.1
  package_info: ^0.3.2
  page_view_indicator: ^0.3.0+1
  path_provider: ^0.4.1
  rxdart: ^0.18.1
  scoped_model: ^1.0.1
  shared_preferences: ^0.4.2
  uni_links: ^0.1.3
  url_launcher: ^4.0.1
  uuid: ^1.0.3
  intl: ^0.15.7
  onesignal: ^1.0.0

  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/images/background.png
    - assets/images/MissionMode_Logo.png
    - assets/images/MissionMode_Full_logo_white.png
    - assets/images/MissionMode_Full_logo.png
    - assets/images/MissionMode_Logo.png
    - assets/images/triangle-bg.png
    - assets/images/Envelope-PNG-File-354x279.png
    - assets/images/wand-1024_1280.png
  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.
  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages

Here is the Podfile from /ios

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  pods_ary = []
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) { |line|
      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
      plugin = line.split(pattern=separator)
      if plugin.length == 2
        podname = plugin[0].strip()
        path = plugin[1].strip()
        podpath = File.expand_path("#{path}", file_abs_path)
        pods_ary.push({:name => podname, :path => podpath});
      else
        puts "Invalid plugin specification: #{line}"
      end
  }
  return pods_ary
end

target 'Runner' do
  # SJM -- For Swift plugins
  # use_frameworks!

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')

  # Flutter Pods
  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
  if generated_xcode_build_settings.empty?
    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
  end
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
      symlink = File.join('.symlinks', 'flutter')
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
    end
  }

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('.symlinks', 'plugins', p[:name])
    File.symlink(p[:path], symlink)
    pod p[:name], :path => File.join(symlink, 'ios')
  }
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignal', '>= 2.9.3', '< 3.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.0'
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

This is rather a show stopper for us right now as we're stuck ..

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions