Flutter build is iOs - Error (Xcode): Undefined symbol: _objc_msgSend$ - ios

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.

^_^
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 "

click on your target > build settings > VALID_ARCHS > and add the following :
arm64 arm64e armv7 armv7s x86_64
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

Related

linker command failed with exit code 1 when building Unity project in Xcode

Im trying to build an iOS application developed with Unity. The app builds and runs just fine on Android as an apk or aab.
When building for iOS I get no errors in Unity and the Unity-iPhone.xcodeproj and Unity-iPhone.xcworkspace are built. I open the Unity-iPhone.xcworkspace and make sure the signing of the app is well and all.
But when trying to archive the project i get these errors :
(these errors appears during the building of the UnityFramework and are associated with it)
ld: warning: Could not find or use auto-linked library 'swiftCoreMIDI'
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1
Undefined symbol: _swiftoverride_class_getSuperclass(swift::TargetMetadata<swift::InProcess> const*)
Undefined symbol: swift::swift51override_conformsToSwiftProtocol(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, llvm::StringRef, swift::TargetProtocolConformanceDescriptor<swift::InProcess> const* (*)(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, llvm::StringRef))
Additionnal informations :
Im using Unity 2019.3.6f1 and I made sure to go in the iOS Resolver settings and checked the "Podfile Generation", "Auto Install Cocoapod Tools in Editor" and "Use project settings" to true as well as setting the Cocoapods Integration to "Xcode Workspace - Add Cocoapods to the Xcode workspace"
I also make sure to open the Unity-iPhone.xcworkspace and not the Unity-iPhone.xcodeproj.
I use Xcode 12.0.1 with Swift 5.3 and Im targeting iOS 10.0
My version of cocoapod is 1.8.4.
Things I have tried :
Adding the "swiftCoreMIDI" library to the list of Frameworks and Libraries and/or the list Link Binary With Libraries in the UnityFramework's build phase.
Adding DEAD_CODE_STRIPPING = NO to the build settings of the target UnityFramework.
Installing Xcode 5.0 and using it from the toolchain menu of Xcode to build.
In Unity's player settings, setting the Architecture to Universal, ARM64 and ARMv7.
Using "Symlink Unity libraries" in Unity's build options
Reduce/Increase the build target to 8.0 / 12.0
And many other things that I cant recall at the moment... (been stuck on this for days)
none of these attempts removed or changed the errors.
As I understand the problem is that a library inside the UnityFramework is trying to call some functions in the "swiftCoreMIDI" library but cannot access them. But i cant figure out why adding the library to the list of Frameworks and Libraries in the general panel and/or the list Link Binary With Libraries in the UnityFramework's build phase doesnt solve the problem.
Thanks in advance for any ideas or suggestions.
I finally found the solution, it was linked to the UnityFramework target in Xcode. I had to remove some architectures that are not concerned by my build: i386 and x86_64. In addition, I updated the Library Search Paths to include $(SDKROOT)/usr/lib/swift.
To execute those actions automatically, you can add those lines in a PostProcessBuild file in your Unity project:
var projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
var proj = new PBXProject();
proj.ReadFromFile(projPath);
// Update the Library Search Paths of the whole Xcode project
proj.AddBuildProperty(proj.ProjectGuid(), "LIBRARY_SEARCH_PATHS", "$(SDKROOT)/usr/lib/swift");
// Get the UnityFramework target and exclude the unwanted architectures
var unityFrameworkGuid = proj.TargetGuidByName("UnityFramework");
proj.SetBuildProperty(unityFrameworkGuid, "EXCLUDED_ARCHS", "i386");
proj.AddBuildProperty(unityFrameworkGuid, "EXCLUDED_ARCHS", "x86_64");

SDL2 iOS app: Entry point (_main) undefined for architecture armv7

I built a small game using SDL2, SDL2_ttf, and SDL2_mixer. I ported it to Xcode and was able to run it with the iOS simulator just fine. I successfully built all of the SDL2 libraries with the target set to "iOS Device" and imported them into the Frameworks directory of my project. However, when I tried to archive the project with the target set to "iOS Device" I get the following error:
ld: entry point (_main) undefined. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is this issue casued b7 the SDL libraries I'm trying to link to or is it something else entirely?
I bet the SDL lib doesn't contain a valid armv7 slice but your app is being built for arm7 and arm64.
Check the SDL build settings and make sure that the 'valid architectures` include armv7

Unable to link GoogleAnalytics 3.01 with XCode 5 (missing required architecture x86_64)

I have built my App (targeted for iOS7) and now want to apply Google Analytics as the last step before submission. What I did:
Downloaded GA for iOS 3.01
Imported content of /GoogleAnalytics/Library/ into group "GoogleAnalytics"
Imported libGoogleAnalyticsServices.a into group "GoogleAnalytics"
Added Build Phases and swapped build phase libGoogleAnalytics_debug.a with libGoogleAnalyticsServices.a
Added code block #include "GAI.h" to my -Prefix.pch-file.
Initialize the [GAI sharedInstance] in my AppDelegate.
I have attached screenshots of the setup in the bottom of this post.
When I try to build (either device or simulator, both 32bit), I get the following linker errors:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GAI", referenced from:
objc-class-ref in FTVAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How do I solve this?
UPDATE 1
I also get the warning
ld: warning: ignoring file .../libGoogleAnalyticsServices.a, missing required architecture x86_64 in file .../libGoogleAnalyticsServices.a (3 slices)
ld: warning: ignoring file .../SDWebImage.framework/SDWebImage, missing required architecture x86_64 in file .../SDWebImage.framework/SDWebImage (3 slices)
UPDATE 2
This error only occurs when building for 64bit. I had accidentally set "Build Only for active architectures" to NO, when this changed to YES, I was able to build yet again. This means that the App now does NOT work on iPhone 5S - which is still a problem.
You're not doing anything wrong. I'm pretty sure google has not yet provided a arm64 version of their libGoogleAnalyticsServices.a, which is really annoying ...it has been weeks since the public the release of Xcode 5GM.
For now, I guess only build for armv7, armv7s or remove google analytics until they get their head out of their pants.
UDATE: Finally fixed https://developers.google.com/analytics/devguides/collection/ios/resources
Select this option in the Architecture section in "Build Settings" and your code will run on iPhone 5S, I had the same trouble.
Good news everyone, fixed by the 3.03 release:
64-bit support is now available in v3.03 of the Google Analytics
Services SDK for iOS. (Source)
I see on first screenshot that your project has 2 targets.
Are you sure that libGoogleAnalyticsServices.a added to both targets?
Linked frameworks may differ from target to target, so it's most common error this way...
Also try remove GA from project, then Clean, then Clean Build Folder, then restart Xcode and add GA again =) Yesterday this helped me =)

linker command failed with exit code 1 xcode4.5

I updated my iphone4s and xcode to the latest yesterday. And I'm trying to debug my app on my phone since my application uses hardware communication.
I'm using a third party library from Redpark(the company provides Dock to RS232 wire.)
While compiling, it gives an error
ld: file is universal (2 slices) but does not contain a(n) armv7s slice:/Users/...../libRscMgrUniv.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone know how to solve this except waiting for Redpark to update there library?
You can simply disable the compilation of armv7s in your Build Settings, by replacing the $VALID_ARCHITECTURES (which evaluates to armv7 armv7s now) value by the explicit value armv7.
Thus your application will only build for armv7 and not armv7s, so will not be fully optimized for the new iPhone5, but it will still run on iPhone 4 and 5 anyway (the armv7s processor of the iPhone 5 can execute armv7 applications, it is just not as optimized as with armv7s processor dedicated instructions)
I did another search and found two solutions work for me.
Dafna
1. Go to Target Setting -> Build Settings -> Build Active Architecture Only -> change to NO.
2. Still in Build Settings -> Valid Architecture -> delete armv7s.
They both work for me. If you have the same problem, definitely try this first.

Apple Mach-O Linker Error armv7s & libGoogleAdMobAds.a

I've just upgraded my app to run on the new iPhone5 simulator, however when I try to build it for my iPhone 4S device, I get this Apple Mach-O Liner error.
ld: file is universal (3 slices) but does not contain a(n) armv7s
slice: /Users/Darren/Documents/Dev stuff/My
App/GoogleAdMobAdsSDKiOS-5.0.5/libGoogleAdMobAds.a for architecture
armv7s clang: error: linker command failed with exit code 1 (use -v to
see invocation)
Can someone shed some light on what this error it and how to fix it?
I am using adWhirl with AdMob.
Thanks
EDIT ---
I am also getting this error in another project for the file libfacebook_ios_sdk.a
The same answer as I gave in this thread:
If you want to remove the support for any architecture, try this:
Project -> Build Settings -> remove the architecture from "valid architectures"
You can use this as a temporary solution until the library has been updated. You have to remove the flag from your own project.
iPhone5's cpu is A6(armv7s).
The existing Admob sdk does not support it.
We have to wait for admob to update the sdk.
Update to Admob 6.2.0 or later.
See this post: http://googleadsdeveloper.blogspot.com/2012/09/migrating-to-admob-v62-for-ios.html.
Also, include the AdSupport framework and remove the -all_load flag.
You've got to use the -ObjC flag however.
This works for me, finally!!
Try this:
This article copy an armv7 lib code as an armv7s and build into the original lib. so xcode will see that lib has an armv7s code/arch
http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/

Resources