iOS conditional link static library - ios

I have a fat static library compiled for armv7 and i386. In my iPhone/iPad project everything works fine, but i can only install my application on armv7 device so iPhone 3gs and up...
There is a way to run my project on armv6 so i can install it on an ipod touch and an old iphone version (also if i disable the use of armv7 library).
I try this:
#ifdef _ARM_ARCH_7
... //include and use of armv7 library
#else
... //not include armv7 library
#endif
but when i compile my project i have link error...
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ failed with exit code 1
So there is a way to run my app on all kind of device but link a specific library when compiling for armv7???
Thanks for help!

You need to weak-link that library. Open up build settings and find Other Linker Flags. You need to add two entries, the first is "-weak_library", the second is the path of the library file (you may need to hunt through what's being passed to the linker to find what this is).
They need to be in that order as this list is turned into parameters to the linker in the order they're presented.

Related

Integrate AppLovin With swift xcode 6.4

I want to integrate AppLovin With Xcode 6.4 and swift. I am Following the steps which are given in Documentation. I have added Headers and libAppLovinSdk.a Library in my project. Then I have added all the frameworks which are needed and added AppLovin SDK key into info.plist file. Then I have initialized ALSdk.initializeSdk() in Appdelegate.h file and I have added Bridging file in my project. Then I wrote -Objc in "Other Linker Flags"
I am getting this error
ld: 150 duplicate symbols for architecture i386 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
EDIT:
This is the error log.
Based on the linker errors (duplicate symbol _llvm.embedded.module) as well as the fact that you're using an older Xcode version, it may likely be a conflict/mismatch between the target/compiler of your project and the dependency. This isn't inherent to AppLovin, but can happen if the static library you're using is far too new or old for your Xcode version.
One possible occurrence of this is that we started compiling the library with Bitcode support, and I wouldn't be surprised if older versions of LLVM don't play nice with that.
I'd recommend pulling the latest version of libAppLovinSdk.a, and if at all possible, building using Xcode 7+.
Additionally, if you're using some dependency manager like Cocoapods or Carthage, you may have better luck directly (manually) integrating, given that they are maintained by third parties with no involvement from us.
You are initializing SDK at wrong place. At the time of didFinishLaunchingWithOptions: call, application has not been fully prepared. Try initializing it in method:
-(void)applicationDidBecomeActive:(UIApplication *)application
Also include -ObjC flag. It should solve duplicate symbols issue.

Can't compile Aviary on iOS since SDK 4.4

I can't run my app only on the iOS Simulator since I updated to Aviary SDK 4.4.
I can run the app on my iPhone and iPad.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: 30 duplicate symbols for architecture x86_64
The framework and the bundle are visible in "Link binaries with Libraries" and "Bundle ressources".
The Framework search path is OK in build settings.
It looks like the Aviary framework was managed twice ?
I leave/restart Xcode, clean the app in iOS simulator, clean target and destroy DerivedData without success.
Very strange I have no problems in the real devices.
I got this problem resolved. Here is how:
Solution
Do not use #import <AviarySDK/AviarySDK.h>, instead of that, import the classes that you're using directly. Like: #import <AviarySDK/AVYPhotoEditorController.h> etc.
Reason
The reason I believe lies in the newly introduced AVYPhotoEditorCompatibility.h, which is by default included in <AviarySDK/AviarySDK.h>.
I think here is the problematic code that is using typedef with const
typedef AVYPhotoEditorPremiumAddOn AFPhotoEditorPremiumAddOn AVY_PREMIUM_ADDON_NAMESPACE_DEPRECATED_ATTRIBUTE;
AVY_PREMIUM_ADDON_NAMESPACE_DEPRECATED_ATTRIBUTE AFPhotoEditorPremiumAddOn const AFPhotoEditorPremiumAddOnNone = AVYPhotoEditorPremiumAddOnNone;
AVY_PREMIUM_ADDON_NAMESPACE_DEPRECATED_ATTRIBUTE AFPhotoEditorPremiumAddOn const AFPhotoEditorPremiumAddOnHiRes = AVYPhotoEditorPremiumAddOnHiRes;
AVY_PREMIUM_ADDON_NAMESPACE_DEPRECATED_ATTRIBUTE AFPhotoEditorPremiumAddOn const AFPhotoEditorPremiumAddOnWhiteLabel = AVYPhotoEditorPremiumAddOnWhiteLabel;

Xcode error: file was built for archive which is not the architecture being linked (x86_64)

I have a iOS Xcode project that builds and runs fine in Simulator and device. However, I have a new feature that requires using a static library (built for ARM architecture only) - which means that it builds & runs fine on device but for simulator I get this error -
ld: warning: ignoring file libXYZ.a, file was built for archive which is not the architecture being linked (x86_64): libXYZ.a
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_XYXClass", referenced from: objc-class-ref in MyAppClass.o
I understand the issue but I still want to be able to build & run the app in Simulator (perhaps by excluding or disabling the new feature in Simulator which requires the static library).
I have tried the following project settings so that the app can build for Simulator as well -
Setting 'Architectures' to $(ARCHS_STANDARD_INCLUDING_64_BIT)
Setting 'Build Active Architectures only' to NO
Nothing has worked. Any thoughts how I can build for Simulator? Thanks!
The easiest solution is probably just build the static archive with intel slices (against the iOS Simulator SDK) in addition to the arm ones such that it is 4-way fat (i386+x86_64/iOS Simualtor and armv7/arm64/iOS).
If that is not possible, please explain why that is not possible for you and file a radar at http://bugreport.apple.com, so we can address whatever problem is preventing you from building your static archive.
If you want to proceed without using the static archive in the iOS Simulator build, you will need to avoid using the XYXClass in the simulator. You can do this by doing something like:
#include <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR
// Do sim-specific fallbacks
#else
// Do stuff with XYXClass
#endif
Note that the "warning: ignoring file libXYZ.a ..." message is not fatal. It's just a warning that you can ignore. The fatal part is your use of the XYXClass which doesn't have an implementation in x86_64.

Undefined symbols for architecture armv7 - route-me library, ad hoc only

I have read through all of the other questions related to this topic, and can not find my answer. My project is using route-me. It builds just fine for the simulator, and for a connected iPad. The archive for ad hoc will not build. I had successfully produced an ad hoc archive - and installed it - prior to implementing route-me. My error is:
Undefined symbols for architecture armv7:
"_ApplicationVersion", referenced from:
-[RMWebTileImage startLoading:] in libMapView.a(RMWebTileImage.o)
"_ApplicationNameFromBundle", referenced from:
-[RMWebTileImage startLoading:] in libMapView.a(RMWebTileImage.o)
ld: symbol(s) not found for architecture armv7
My library is properly linked - it builds for simulator and iPad error free. I do have
[RMMapView class];
in the view controller that is displaying the map. Prior to having that line, my app would crash if installed from the archive with iTunes - although it would not crash if installed from Xcode. Now the archive will not build at all. (But I still believe the above line has put me on the right path).
I have tried every solution that might apply that I have been able to find here. If I remove the references to RMWebTileImage.h and RMWebTileImage.m - I get the same errors, except then it makes sense. But when I add the references back in, I still get the error, as if the files were not even referenced.
Any help would be appreciated.
It looks like the static library of route-me does not have the armv7 symbols. Check the build settings of the library and make sure the architectures build settings are set to build for armv6 and armv7.
You also always can use lipo -info on your static library to see all the included architectures.
If you are linking the Debug configuration, this is mostly set to build for active architectures only. Make sure the projects build settings are identical to the route-me project settings.

libOmnitureAppMeasurement-iPhoneSimulator.a not linking with iOS4 project

I have a Universal Project for iPad and iPhone running iOS 4.0. xCode 4.x
I follow the steps to include the above library into a new project.
I am getting the following error during linking:
We are getting,
“_OBJC_CLASS_$_OMAppMeasurement”
Ld: symbol not found for architecture i386.
I have other static library in the same project and those are working fine. In addition, I also try messing with Other Linker Flag, Header Search Path, Library Search Path. No luck.
Any idea?
EDIT:
Turns out it is a binary issue, instead of using the binary from developer.adobe.com, I was pointed to another binary and that worked OK for xCode 4.x.
The Omniture omappmeasurement libraries are shipped as separate binaries for the separate architectures, so you have to switch between them as you switch between the simulator and devices. You can join the binaries together with lipo:
lipo -create libOmnitureAppMeasurement-iphoneos-armv6.a libOmnitureAppMeasurement-iphonesimulator-i386.a -output libOmnitureAppMeasurement.a
Then add libOmnitureAppMeasurement.a to your project with 'Add Files to "..."...' in the usual way.
NOTE:
If you download them from this forum post you'll find that libOmnitureAppMeasurement-iphoneos-armv6.a contains both armv6 and armv7 code, and libOmnitureAppMeasurement-iphoneos-armv7.a contains armv7 only. Hence using the 'armv6' version above.
I got new libraries from here https://developer.omniture.com/en_US/gallery/app-measurement-for-ios and they work well on simulator and devices.
You will need to create an account to be able to download it.
These libraries are not any more supported by Apple as they use "uniqueIdentifier".

Resources