Apps failed to build when embed in workspace - ios

I have 3 projects:
my custom developed framework 'XXX.framework' (that have dependency on 3rd party 'YYY.framework'). Both frameworks have different versions for real devices and for simulator, thus they differ by arch they build for
2 demo apps in Objc-C 'DemoObjC.app' and Swift 'DemoSw.app' that use my 'XXX.framework'.
I linked my custom 'XXX.framework' to those 2 demo apps which separately build and run normally.
But when I embed 3 projects into workspace to work on all of the projects at same time in one window, I face with strange behaviour. Sometimes I can't run apps on device or simulator. By that I mean sometimes it builds and runs normally, but then without any changes it fails. Or it can run normally for simulator but not for real device, but after XCode relaunch it might happen that it already can run for device but not for Simulator.
I tried to clean project, delete DerivedData, relaunch XCode, and reboot, but it helps only for several successful runs, after that I still get unexpected behavior.
For example, in workspace I try to run 'DemoObjC.app' on device and I get
ld: warning: ignoring file /Path_Here/SIMULATOR/YYY.framework/YYY,
missing required architecture arm64 in file /Path_Here/SIMULATOR/YYY.framework/YYY, (2 slices)
Undefined symbols for architecture arm64:
<List of files that can't be find>
I can't understand why it fails on SIMULATOR when I run it on device? Project and target are seems to be configured fine because separate projects build and run normally.
Or here is error when I try to run on simulator:
ignoring file /Path_Here/NOT_A_SIMULATOR/YYY.framework/YYY,
missing required architecture x86_64 in file /Path_Here/NOT_A_SIMULATOR/YYY.framework/YYY (2 slices)
Undefined symbols for architecture x86_64:
Same issues in XCode 8.2 and 8.2.1
Any glues what is wrong? I lean toward that it is XCode related issue.

Related

Undefined symbols for architecture x86_64: "_RCTSetLogFunction" in React Native when compiling iOS

I'm revamping an old app written in react-native (which had no changes from ~2018) to its latest versions. I migrated from react-native 0.59 to the latest 0.64
To do so, I got help from the react-native migration help tool.
I also had to update my dependencies to work with auto-link and cocoa pods. I'm fairly new to mobile and react native (my background is on web with plain react), so there might be something obvious that I'm missing.
But, while android compiles and works successfully on my Mac, I can't make the compilation to work with iOS.
As the title says, I'm getting the following error:
Undefined symbols for architecture x86_64:
"_RCTSetLogFunction", referenced from:
-[MetronomeWalletTests testRendersWelcomeScreen] in MetronomeWalletTests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is happening in the test project, not in the main project (or however it is called).
Things I've tried
I enabled dead code stripping as this issue suggests in both the main and the test project, for debug and release, in the "targets" section.
I also tried disabling that same setting, as this issue suggests
I tried cleaning and rebuilding
I tried adding Javascript.framework to the linked libraries
If I understand correctly, this error takes place in the phase "Link {projectName}Tests (x86_64)"
None of these have worked. I've run out of ideas.
Environment:
Mac pro with Big Sur 11.3.1 (I'm also new to Mac in general, so let me know if anything might be missing)
RN version: 0.64.2
Xcode version: 12.5.1
I get this error building both from the console and from xcode
It looks like this issue has been fixed for newly scaffolded projects. I was also facing this issue when upgrading an existing React Native project from 0.59.10 to 0.65, with the caveat that it was only happening when building in Release mode (e.g. when archiving the project in Xcode).
The solution for me is outlined in this PR - the gist is to wrap any usage of RCTSetLogFunction inside an #ifdef DEBUG block, to prevent it being run in Release mode.
I realise this might not answer the original question but I thought I'd post it here in case its helpful to anyone else.

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

Custom framework fails to load in iOS simulator (wrong architecture)

I'm trying to build a Cocoa Touch Framework for iOS8 which will eventually be embedded in apps and submitted to the App store so it's important that the release build contains ONLY armv7 but the debug build must run in the simulator too. As such, I've been following this tutorial and I'm hitting upon a runtime error when trying to run an application in the simulator with the framework embedded:
dyld: Library not loaded: #rpath/TestFramework.framework/TestFramework
Referenced from: /Users/jay/Library/Developer/CoreSimulator/Devices/97715157-EABB-4F38-8CA0-62768358DDD6/data/Containers/Bundle/Application/4856FC75-6C5B-4F7E-91A9-70CA1863D130/Test.app/TestFramework
Reason: no suitable image found. Did find: /Users/jay/Library/Developer/CoreSimulator/Devices/97715157-EABB-4F38-8CA0-62768358DDD6/data/Containers/Bundle/Application/4856FC75-6C5B-4F7E-91A9-70CA1863D130/Test.app/Frameworks/TestFramework.framework/TestFramework: mach-o, but wrong architecture
However, when I browse to the framework binary it's complaining about
(/Users/jay/Library/Developer/CoreSimulator/Devices/97715157-EABB-4F38-8CA0-62768358DDD6/data/Containers/Bundle/Application/4856FC75-6C5B-4F7E-91A9-70CA1863D130/Test.app/)
and run xcrun lipo -info TestFramework I get the output Non-fat file: TestFramework is architecture: i386 so I'm kinda lost at where to go now. It runs fine on an actual iOS device.
Based on the question and your comments, the most likely cause of this is that you are building your framework for 32bit and linking it into a 64bit application. If that's not the case, please provide the entire text of your crash log.
You should build your framework 4way-fat:
i386/iphonesimulator
x86_64/iphonesimulator
armv7/iphoneos
arm64/iphoneos
In order to make it 4-way fat, you'll need to manually lipo-together your i386/x86_64 sim build with your armv7/arm64 device build. Building 4-way fat with two different (from Xcode's perspective) platforms is not supported by Xcode.
New in Xcode 11: You can use an xcframework to support these kinds of scenarios! No more lipo hacks required. You can find the details in WWDC 2019 Session 416
In my case, I was using a custom framework containing views that I use in the Interface Builder and I got this error on the Interface Builder build phase.
Running pod install fixed it.

Xcode 6 Error - "Missing Required Architecture i386" When Building for iOS Simulator

I have created a custom Objective-C framework. I would like to import it into any given iOS project and use its provided functionality on both the iOS Simulator and an actual device. To import the framework, I link it using the Build Phases > Link Binary With Libraries setting in the app's target. I'm then able to import it into one of my classes with this statement:
#import <CustomFramework/CustomFramework.h>
I can instantiate my framework's classes just fine, but when I try to run my project on a device, I get the following error message:
dyld: Library not loaded: #rpath/CustomFramework.framework/CustomFramework
Referenced from: /var/mobile/Applications/A61E882D-481A-4C0B-B4FD-69F5D24968BF/TestApp.app/TestApp
Reason: image not found
And if I try to run it on the simulator, I get a different error message:
ld: warning: ignoring file /Users/user/Desktop/CustomFramework.framework/CustomFramework, missing required architecture i386 in file /Users/user/Desktop/CustomFramework.framework/CustomFramework (2 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CustomFramework", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This occurs when I instantiate a class from the framework. If I import the framework but don't actually use it, my app builds successfully. It just errors whenever I instantiate a class from the framework for some reason.
To get the app to build on a device, I followed this SO answer. Instead of linking the framework, I added a new Copy Files phase in the target's Build Phases setting, set the Destination to Framework, and added my framework.
That works great; however, I'd like to test my app on the iOS Simulator as well. When I try to run my app on the simulator, I still get the "missing required architecture i386" error. I've tried the solutions proposed at just about every related SO topic I could find, and nothing has helped me resolve this issue.
Please note that I am trying to use my custom framework in a new Xcode project, so none of the app/build settings have been changed from their defaults.
How can I fix this error so that I can run my app on both the iOS Simulator and a device with my framework included in the project? Any insight would be greatly appreciated!
The issue was that the framework was not compiled for the iOS Simulator's architecture, which is i386. Xcode only compiles a framework for the target architecture, so if I built the framework for the iOS Simulator, it wouldn't work on a device, and if I built the framework for a device, it wouldn't work on the iOS Simulator.
I created my framework from scratch with help from this tutorial: http://www.raywenderlich.com/65964/create-a-framework-for-ios
The multi-architecture build script is what allowed my framework to run on both the iOS Simulator and a device.
I encountered this same problem with Xcode 7.1 when trying to build for the simulator.
Someone else said it worked for them under Xcode 8.2.1, so I tried building/running there and it worked. I didn't have to change targets or anything in my project.
So try upgrading your Xcode if you can, you will presumably get additional bug fixes as well.

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.

Resources