Framework not found FBLPromises (Swift Package Manager) - swift

I've seen this problem listed elsewhere, but it always seems to be linked to a Cocoapods installation of Firebase. My problem is the opposite - trying to upgrade from pods to SPM has given me this problem when I try to compile:
ld: framework not found FBLPromises
I'm currently running Xcode 13.3 on a Mac Mini with an M1 chip, but the problem was present in earlier versions of Xcode.
Previously I had Disk (https://github.com/saoudrizwan/Disk) installed via SPM and Firebase/Messaging and Twilio (5.5.1) installed via Cocoapods. I ran pod clean and pod deintegrate, deleted all the Pod files etc and have installed Twilio and Firebase Messaging using SPM. This gives me the following Package Dependencies (and you can see that Promises 2.0.0 has been added successfully):
The top result I get when I look into this is FBLPromises Framework not found, and the second answer suggests adding arm64 as an excluded architecture, but doing that gives me further problems (warning and error below), and I'd rather not exclude an architecture blindly and then go down a rabbithole of trying to fix that when it might not be the solution to my original problem.
Warning and error when I try to exclude arm64 architecture:
None of the architectures in ARCHS (arm64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s) which is not in EXCLUDED_ARCHS (arm64).
error: Build input file cannot be found: '/Users/myName/Library/Developer/Xcode/DerivedData/project-exchrqebmyccatebeoxupvxpdsul/Build/Products/Debug-iphoneos/project.app/project' (in target 'project' from project 'project')

I've not checked to make sure I've not introduced other errors further down the line, but I think the problem was caused by Linker Flags being retained in the build settings.
I went to the Target -> Build Settings -> Linking and deleted everything under 'Other Linker Flags' (OTHER_LDFLAGS is how this is reflected in the project.pbxproj file according to my git diff).
File now compiles and runs successfully, if I find some subtle bugs later that might be caused by this I shall edit this answer accordingly!

Related

Why do my builds fail after installing a pod?

I installed a pod (which went fine) but when I try building my .xcworkspace it would fail, regardless of whether I imported the pod in the code or not.
This is the error I get:
error build: Building for iOS Simulator, but linking in object file built for iOS, file '.../Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' for architecture arm64
I've found what seems like the exact problem here. The solution proposed here is to update the library.
I tried
sudo xcode-select --switch /Library/Developer/CommandLineTools/
but what I got was
error: invalid developer directory '/Library/Developer/CommandLineTools/'
Do you want to try the same method as the image below?
Build Settings -> Architectures -> Excluded Architectures, arm64.

Illegal Instruction 4 error while running the unit tests on Xcode

I recently updated to Xcode 12.3 and did the workaround to run the carthage dependencies. The build is fine but when I run the tests, I get the Illegal Instruction 4 error. I assume that the arm architecture issue causes that issue. I use Quick and Nimble coming from carthage and these are used in testing. I have tried setting the excluding archs and validate archs to yes but none of them worked.
I cannot move the libraries from carthage to pods or spm because there are so many configurations in the libraries. Updating to a new Xcode version is such a pain especially if you are using carthage.
UPDATE:
I downloaded the carthage version of 0.37 and implemented the xcframeworks into the project. To run the dependencies for xcframeworks, I run the following command:
carthage bootstrap --use-xcframeworks --no-use-binaries --platform ios
If you can use Carthage 0.37.0 and are able to use XCFrameworks, then this answer might be valuable for you đź‘Ť In this vesion they added support for XCFrameworks and I find it quite nice to use. Especially since this popular workaround can finally be removed again.

Flutter Plugin containing static library (.a File) is not linked correctly

I have a Flutter Plugin, which for iOS uses a static library (.a file). If I add the plugin to my pubspec.yaml and install it via flutter pub get, it installs a pod, which I can see in my app`s XCode project, everything correct so far.
pubspec.yaml:
XXX_flutter:
git:
url: git#gitlab:XXX-solutions/app/flutter/plugin_XXX.git
ref: "develop"
However if I build the app, I get the following error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_XXX", referenced from:
objc-class-ref in XXX.o
ld: symbol(s) not found for architecture arm64
In the XCode workspace, in the Pods project, if I select the XXX pod, I can add the .a file manually to "Pod Project -> TARGETS XXX -> Build Phases -> Link Binary With Libraries". This would solve the problem, but I had to do it any time I do a flutter clean, pub upgrade, team member checks out project etc.. since the Pods are not under source control, so this solution is not good.
I tried to add the .a file to my app`s project "Link Binary With Libraries", but this didnt fix it. I have no idea how to solve this.
Note: The library is proprietary software, so it´s blacked out because I think the developers dont want to see problems issued with their software. The plugin itself is just Flutter wrappers for the library and is written by our team.
This is because the static lib you are using isn't compiled for arm64 devices, so you need to exclude this architecture from your build. See pic.
*Note: it's only on release, you may have issues excluding arm64 for debug if you have an M1/M2 mac and using simulators.
You can release to App Store for ios devices with arm64 excluded with no issue.
Alternatively, you could include a version of your static lib that is compiled for arm64 arc.

Swift for TensorFlow - dyld: Symbol not found: _$sSly7ElementQz5IndexQzcigTq

I'm trying to work through the model training workflow tutorial (https://www.tensorflow.org/swift/tutorials/model_training_walkthrough) but when running the code (it's a MacOS app) in Xcode 10.2 (on MacOS 10.14.4 ) I get the following error:
dyld: Symbol not found: _$sSly7ElementQz5IndexQzcigTq
Referenced from: /Users/Luke/Library/Developer/Xcode/DerivedData/ANN-ffxhvyujcitzkqfhbrwqjnpftijw/Build/Products/Debug/ANN.app/Contents/MacOS/../Frameworks/libswiftPython.dylib
Expected in: /usr/lib/swift/libswiftCore.dylib
in /Users/Luke/Library/Developer/Xcode/DerivedData/ANN-ffxhvyujcitzkqfhbrwqjnpftijw/Build/Products/Debug/ANN.app/Contents/MacOS/../Frameworks/libswiftPython.dylib
I've followed the official installation instructions (https://github.com/tensorflow/swift/blob/master/Installation.md):
Downloaded the latest release "swift-tensorflow-RELEASE-0.2"
Run the installer
Set the toolchain to "Swift for TensorFlow Release 0.2" created 02/03/2019
Set the Build System for shared and per-user to Legacy Build System
Set Swift Compiler - Code Generation -> Optimization Level to Optimise for Speed [-0]
added libtensorflow_framework.so and libtensorflow.so to Linked Frameworks
Added "/Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.2.xctoolchain/usr/lib/swift/macosx to Runpath Search Paths. $(inherited) and #executable_path/../Frameworks were already present in the list
added -lpython to Other Linker Flags
I found this to be quite helpful: https://github.com/tensorflow/swift/blob/master/Usage.md#mac-only-xcode
On macOS Catalina, Verify Code Signature for Swift for TensorFlow toolchains produces a code signature error. This prevents Xcode projects built using Swift for TensorFlow toolchains from running. To work around this issue, go to Project Target Settings > Signing & Capabilities > + Capability > Hardened Runtime and check Disable Library Validation.

xcode invalid archive in organizer

i get message during archive validation. i've tried most of solutions from other questions. but still failed. (It was ok when i submit it last time in xcode 4.02, then i get rejected. i edited some image and .m file(not project settings).
my project Build settings:
Architectures->standard (armv7) - $(ARCH_STANDARD_32_BIT)
Base sdk->Latest ios(ios 5.0)
valid Architectures armv6 armv7 arvm7f armv7k
Build active architecture only->no
ios deployment target: ios3.0
i've tried reinstalling xcode and make sure unix is checked, 5 times.
i've tried install back to xcode 4.02, but the same message as xcode 4.2
i've tried reinstall cocos2d
i've tried to set the llvm/gcc to gcc only
warning message 1:
Project Clean-Up Outdated settings should be updated.
when i click it. one is to set gcc to llve-gcc, another is to 'Enable compiler warning for missing Function Prototypes. ' I clicked cancel
warning message 2:
Check dependencies
[BWARN]warning: iPhone apps with a deployment target lower than 4.3 should include an armv6 architecture (current IPHONEOS_DEPLOYMENT_TARGET = "4.1", ARCHS = "armv7").
warning 3:
Validate /Users/lifesucks/Library/Developer/Xcode/DerivedData/FishvsBirdsLite-frctqlpldaogcjebgvxkvvmsehie/ArchiveIntermediates/FishvsBirdsLite/InstallationBuildProductsLocation/Applications/FishvsBirdsLite.app
cd "/Users/lifesucks/my app/Fish vs Birds/FishvsBirdsLite"
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv PRODUCT_TYPE com.apple.product-type.application
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation /Users/lifesucks/Library/Developer/Xcode/DerivedData/FishvsBirdsLite-frctqlpldaogcjebgvxkvvmsehie/ArchiveIntermediates/FishvsBirdsLite/InstallationBuildProductsLocation/Applications/FishvsBirdsLite.app
2011-06-14 01:30:10.948 Validation[8609:607] *** Warning: Defaulting to the standard codesign tool
warning: iPhone/iPod Touch: application executable is missing a required architecture. At least one of the following architecture(s) must be present: armv6 (-19033)
Unable to validate your application. - (null)
warning: There is no codesign_wrapper executable. Please reinstall the Xcode developer tools. (-19058)
Unable to validate your application. - (null)
the error message in organizer is:
the archive is invalid. /var/folders/H5/.../app.ipa does not exist.
I actually don't know why, but it works now. I reinstall back to xcode 4.0.2. then recreated a project, copied over all my classes. i assume that the problem is 'Architectures->standard (armv7)', in xcode 4.0.2 the Architectures is standard armv6/armv7, maybe it's because of cocos2d compatibility to the new version i don't know. anyway if you encounter the same problem, just install back to non-beta and create a new project (since the original setting of 'Architecture' will be modified to 'armv7 standard'. ) hope it helps.
This happened to me when I updated to Xcode 4.2. I went back to the latest non-Beta Xcode version to fix it. The key is, when uninstalling Xcode, you must do it via the following command in Terminal:
sudo /Developer/Library/uninstall-devtools –mode=all
This takes a few minutes. But when it's done, install the non-Beta Xcode (4.0.2 at this time), and then RESTART before using it. Worked for me.
Remove iphoneossimulator from supported platforms for the distribution/release build configuration. That is if you have it.
You cannot have that for distribution, it is only for your debug configurations.
Check the image below for distribution configuration (ignore release config).