How to fix undefined symbol errors in swift? - ios

Recently I got to work on a Swift project on a mac with a M1 chip.
This project uses the normal swift package manager but also has Moscapsule (https://github.com/flightonary/Moscapsule) manually installed. Therefore it gets compiled before all other dependencies and the app the package is used for.
If you compile and run the app on an iPad-Simulator you need to tell the Moscapsule target to compile for x86_64 architecture because it uses a x86_64 iPad simulator. This works absolutely fine.
Then I tried to compile and run the UI Tests for the app. Now the compiler failed to build the app because the compiler needs the Moscapsule framework compiled for arm64 architecture.
I thought: Ok no problem, then compile it for arm64 architecture. But then I get these errors:
The interesting thing to mention is that if I compile the app or the UI Tests for a real arm64 device (iPad Pro with M1 Chip) there is no problem at all.
Did one of you have a similar problem already and has a solution for me?
Thank you!

Related

iOS, Xcode 14+, Building a project for 64-bit architectures with Pods/SPM

I have inherited an old project with some old cocoapods dependencies that do no support arm64 devices. So when I go to import the module (whether it be pods or using Swift Package Manager) ... i.e.
import Module
i get the error: (Compile swift source files (arm64), No such module 'Module' found)
I know that there are past questions and answers for building/testing on a simulator and changing the build settings/valid archs/excluded archs) but I am actually trying to get to this to work on a device that has 64-bit architecture. The machine that I am working on is still Intel.(Not M1)
If the cocoapod library or swift package doesn't include support for 64-bit what workarounds are there (if any)?
It also looks like on Xcode 14.2(Mac OS Monterey 12.6.3), that the option of opening Xcode using Rosetta is no where to be found. Excluding certain archs in build settings and all other past solutions appear to not work.
Anyone have any suggestions?

Build iOS framework towards My Mac with Xcode 11.2 report errors

I upgrade my xcode recently.
When I build my iOS frameworks towards My Mac, most of them works fine. However one framework build failed. The error as follow:
My Mac doesn’t support any of XXX.framework’s architectures. You can add My Mac’s x86_64h architecture to XXX.framework’s Architectures build setting.
I have tried add x86_64h, x86_64, and arm64e to valid architecture, but it doesn't work.
I also tried to compare build settings between these frameworks, but failed to find out an solution.
Any suggestion to solve this problem?
I had the same issue, then I changed Valid Architectures to arm64 x86_64.
After this, I was able to build the framework and use it.

Unable to build Xcode Project: clang error: linker command failed

I have a Unity project which I have successfully built for Android without issue. When trying to build for iOS I am encountering an issue once the project is in Xcode.
Unity compiles without any errors and creates an Xcode project.
Upon opening the Xcode project I have NO simulators available. I can get these simulators by selecting ios in the Supported Platforms section, at which point simulators become available - originally Supported Platforms is set to iphoneos. This seems extremely odd behaviour to me, and suggests something larger going wrong.
After getting a simulator to select I get the following error when trying to compile/run/build:
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The full error is available on Pastebin (too large to post directly on here):
https://pastebin.com/3fYR8fE3
I'm really at a loss on what I can do. I have tried a number of things, including:
Building from Unity as Debug and Release
Building from Unity with 'Symlink Unity Libraries' on and off
Building from Unity with .Net 3.5 and .Net 4.* flavours
Manually adding the libiconv.2.dylib file in the linked frameworks tab as the .tbd equivalent
Setting the target minimum version of iOS to 9.0 (negates the need for libiconv.2.dylib entirely)
I am using latest versions of everything:
Unity 2018.2.17f1
Xcode 10.1
It seems like you have the library il2cpp built for another architecture, have you tried to change your target's "Build Settings > Build Active Architectures Only" to "No"?
However I made some researches and it seems that Unity for iPhone doesn't deploy on simulator. It only works on device or in the Unity editor. Check this link out

Getting errors compiling an iOS App Using CorePlot 1.5.1

So, I am trying to build and run an App on my iPhone 5 device. But "suddenly" (Was working fine until I ran archive to submit to iTunes connect) it is failing with errors. The app is using CorePlot graphing library and the error seems to be occurring in that library.
So, the error is
Text
ld: warning: ignoring file
path/to/libCorePlot-CocoaTouch.a,
file was built for archive which is not the architecture being linked
(armv7):
path/to/libCorePlot-CocoaTouch.a
I can understand the error. It basically says that the library was built not for armv7 architecture.
However, to confirm this I ran this terminal command against the static library.
lipo -info libCorePlot-CocoaTouch.a
and the result is,
Architectures in the fat file: libCorePlot-CocoaTouch.a are: armv7 armv7s i386 x86_64 arm64
I can't see a reason why this isn't running. The project compiles and runs on simulator but when I change to device it starts to fail.
What have I tried so far?
Seeking for solutions on Google - Failed
Cleaning project and running it again.
Quitting XCode and restarting it.
Shutting down Macbook and then restarting it.
Downloading CorePlot 1.5.1 source files and rebuilding the binary files.
After all above steps and many more. I have same error again and again. I don't know what am I done wrong.
Environment Specs:
MacBook Pro running OSX 10.9.2
XCode 5.1.1
Project > Build Settings > Architectures > Standard architectures (armv7, armvts, arm64)
Base SDK > Latest iOS (iOS 7.1)
iPhone 5 with iOS 7.1.1
If it helps, I am sharing the exact binary I am using right now with my app.
CorePlot Binary which is being used.
Any idea about what am I doing wrong? I know there is like a silly mistake somewhere. But not sure where. Any extra info please comment. I will provide it straight away. I was about to upload my App to iTunes connect.

XCode compile time error on simultor

I am trying to build my XCode project and this is what I get. The project runs fine on a device but fails to run on simulator.
Can someone please explain me why this is happening. I have tried removing this library from the project and add it again. It still fails to run on simulator.
Thanks in advance.
i386 is a reference to the Intel processor architecture used by your development machine (the actual iOS devices use ARM processors).
The error indicates that the library has not been built to include support for the Intel architecture. As the simulator runs on the desktop, it requires Intel support to run.
You should obtain a copy of the library that includes i386, or build it yourself.
Here's one way that can be done (for another library that required i386 support adding)
http://www.federicocappelli.net/2012/10/05/zbar-library-for-iphone-5-armv7s/
You need to find where CkoCrypt2 is defined in code and make sure it's being built for the simulator.
If "CkoCrypt" is part of a library or framework, then you need to also compile that library to work under a simulator as well.

Resources