4

Trying for several days to build my flutter project in iOs (flutter build IPA) and I always seem to receive the same errors :

     "_objc_msgSend$setIOSHasWarnedLocationServicesOff:", referenced from:
      +[LocationAuthorization run:onCancel:] in TSLocationManager(LocationAuthorization.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

There are a lot of them so I won't be putting all of them here but they're all related to _objc_msgSend$ and TSLocationManager.

I tried to add "-lc++" to Other Linker Flags in Build Settings (Runner Target)., related to this issue https://github.com/facebookarchive/pop/issues/25 but it still failing with more than 100 _objc_msgSend$ issues. I have frankly tried so many things and I'm quite out of clues.

Something I remarked is that when I build from Xcode (Product -» Build), it builds fine when I choose the Destination Device iPhone SE 3rd GEN, but I get the errors when the destination device into my physical device (which is plugged into my Mac).

When I hit flutter build IPA, it always fails.

2 Answers2

9

^_^

First you can update your xcode to version14.0 above.

And the real reason is Apple Clang new optimization scheme._objc_msgSend stup support is not support on xcode13.

If you don't want upgrade your xcode version . You can follow next steps to change your private framework.

I guess you compiled a framework in xcode14 and then used it in xcode13

hh , now i saw you reply , make sure my answer

i'm using Xcode 13.4.1 and it's not having ARCHS_VALID as a build setting @editix – 
Bertrand Gélinas
 22 hours ago 

By default, the clang in Xcode 14 will generate target files that cannot be understood by earlier native linkers.

In the future, it will be recommended to use Xcode14 and above for application package.

If you have private framework build by Xcode14.

  • Just add -fno-objc-msgsend-selector-stubs to your framework project target build settings other c flags, and build again, replace new framework to your other xcode project

  • or in your framework project chaneg your podspec file add xcconfig other c flags -fno-objc-msgsend-selector-stubs

  • or your own script build framework , you can before call xcodebuild command add a change , like thisxcodebuild -project xxx.xcodeproj build OTHER_CFLAGS="-fno-objc-msgsend-selector-stubs "

jackson
  • 219
  • 1
  • 3
  • Thanks a lot it works! You have just ended a 2 weeks headache :D. Turns out when i "tried" to update to xcode14 from appStore (2 weeks ago), it failed, but still has installed some xcode14 component like _objc_msgSend. Since i tried to add -fno-objc-msgsend-selector-stubs in xcode13 and it did not work, i installed xcode 14 and now it works :) – Bertrand Gélinas Oct 14 '22 at 14:17
  • -fno-objc-msgsend-selector-stubs used on Xcode14 and above. – jackson Oct 17 '22 at 06:48
  • 1
    The problem is TSLocationManager framework . Has been complie by xcode14 ,and do not use ` -fno-objc-msgsend-selector-stubs` . So that framework has objc_msgSend stubs in TSLocationManager.o file . If you want use in xcode13 . You should build the framework with other_c_flags `-fno-objc-msgsend-selector-stubs` in xcode14 . And then you can get a framwork without objc_msgSend stubs .And it run successful – jackson Oct 17 '22 at 06:50
0

click on your target > build settings > VALID_ARCHS > and add the following :

arm64 arm64e armv7 armv7s x86_64

enter image description here

in case you didn't find the VALID_ARCHS do the following:

1- Click on the plus sign under the Build Settings.

2- Choose "Add user-defined settings" and it will add NEW_SETTING to you.

3- Rename the "NEW_SETTING" to "VALID_ARCHS" and add the following builds:

arm64 arm64e armv7 armv7s x86_64

if nothing fixed your issue please follow this you may find working answer:

Undefined symbols for architecture arm64

editix
  • 322
  • 2
  • 14