Vizllx
Vizllx

Reputation: 9246

mach-o, but wrong architecture AFNetworking 3.0

Anybody know about the error “mach-o, but wrong architecture” ? I have built a custom framework(which includes a few other SDK's inside it) & trying to integrate in the client project. I can use/access the custom framework’s methods in the client’s app when I am running in a simulator, but the app is getting crashed while running on the device . Any suggestions will be really helpful. Thanks

Here is the log:-

dyld: Library not loaded: @rpath/AFNetworking.framework/AFNetworking Referenced from: /private/var/containers/Bundle/Application/644C95E8-6CFD-48BB-861E-7BCECB08FE43/abc_client.app/Frameworks/XYZ_iOS.framework/XYZ_iOS Reason: no suitable image found. Did find: /private/var/containers/Bundle/Application/644C95E8-6CFD-48BB-861E-7BCECB08FE43/abc_client.app/Frameworks/XYZ_iOS.framework/Frameworks/AFNetworking.framework/AFNetworking: mach-o, but wrong architecture /private/var/containers/Bundle/Application/644C95E8-6CFD-48BB-861E-7BCECB08FE43/abc_client.app/Frameworks/XYZ_iOS.framework/Frameworks/AFNetworking.framework/AFNetworking: mach-o, but wrong architecture

Upvotes: 1

Views: 653

Answers (1)

Blazej SLEBODA
Blazej SLEBODA

Reputation: 9925

When building for the Cocoa platform, Elements allows you to choose to build for different CPU Architectures, depending on the target devices and operating system versions you wish to support. Elements allows the creation of so-called "Universal Binaries", or "Fat Binaries", that can include executable code for more than one platform (for example 32-bit and 64-bit). source

The error means that there are architectures which are missing in your framework.

List an architectures in a framework:

There are two terminal tools:

  1. file

file /path/to/MyFramework.framework/MyFramework source

Example output:

path/to//MyFramework.framework/MyFramework: Mach-O universal binary with 5 architectures
path/to//MyFramework.framework/MyFramework (for architecture x86_64):   Mach-O 64-bit dynamically linked shared library x86_64
path/to//MyFramework.framework/MyFramework (for architecture i386): Mach-O dynamically linked shared library i386
path/to//MyFramework.framework/MyFramework (for architecture armv7):    Mach-O dynamically linked shared library arm
path/to//MyFramework.framework/MyFramework (for architecture armv7s):   Mach-O dynamically linked shared library arm
path/to//MyFramework.framework/MyFramework (for architecture arm64):    Mach-O 64-bit dynamically linked shared library
  1. lipo

lipo -info /usr/lib/libiodbc.a source


  • When launching on a device a framework have to include arm64 or armv7 architecture
  • When launching on a simulator a framework must to include x86_64 architecture

Solution

  • Check if there is any modifications to architectures in Podfile
  • Check if there is any modifications to the project build settings for a architectures keys.

Upvotes: 1

Related Questions