How can code using a framework class run without the framework? - ios

I'm running an app that uses EAAccessoryManager, which should only be available via the ExternalAccessory framework. Yet it compiles and runs without ExternalAccessory being included in the list of frameworks to link. Nor is it loaded into Xcode by any other targets. How is this possible? I'm mystified.
I'm curious because I have another project that loads a static library that also references EAAccessoryManager, and in that case, the app won't compile, exiting with the error Undefined symbols for architecture i386. This is more what I expect. What can account for the difference?

Could be a linker build setting rather than a link build phase.

In Build Settings, in the “Apple LLVM 5.1 – Languages – Modules” section, “Link Frameworks Automatically” is enabled:
This is a new feature I never noticed before discovered while reading this post on #import (thanks #RhythmicFistman for the hint!). When I change that setting to “No”, I get the linker errors I expect.

Related

Undefined symbols for architecture x86_64: xcode 9 Swift 4

I create app that uses Huawei SDK written in Objc with updated docs in Oct 2017. But when I add framework to project, this shows me stange error. I have stack on this problem couple days, I have tried everything from similar problems, but nothing helped for me.
Framework added correctly(header file, link binary with libraries) autocomplition works well and shows the methods when trying to use SDK.
Already tried: change/edit/update
Valid architecture: arm, armv, armv7, armv7s, i386, x64_86
Clean Derived date and achieves
Restart OS
Change swift version: Shows another error
Checked ObjC bridging header
Pod update/install
Framework search path
SOLUTION:
Launch on real device=)
Looks like your HWMobileSDK.framework is not a fat framework. You'll either need to find a fat framework, or a second build of the framework that's compiled for the simulator (x86_64). I couldn't find any reference to that framework online, so it looks like it's not publicly available. If you got this from Huawei directly, you should ask the person you're in contact with there. Either they don't provide a version of the library for the simulator and you'll need to develop using a device only, or you need another version of the library.

Xcode -" ld: framework not found" happening on a framework not included directly

A bit of story:
I created a framework called, Notifications, that allows our iOS applications to use one of our new backend service. I created the framework in Swift, and included it in our main application which is written in Obj-C. This was working great until one of my colleauges updated the main application to allow us use Swift in the main application.
I am now getting the following error:
ld: framework not found ISO8601 for architecture x86_64
This is a rather interesting error as the Notifications framework uses ISO8601, and it is included in the Notifications framework. The main application does not reference this framework at all.
Yes, I did check to make sure ISO8601 has has the x86_64 architecture, and all included frameworks, and the Notifications framework also has all the required architectures.
I looked at the build settings and they appear to be all in line with building the project as expected.
For me the only difference appears to be enabling Swift in the main app. I have cleaned, deleted derived data, and various build settings trying to get it working.
Any thoughts or ideas for fixes would be greatly appreciated.

Using pre compiled dylib in iOS8+ or building dynamic framework out of dylibs?

I'm trying to use a fat dylib I've made that contains the latest version of tbb with code for all architectures I may be targetting (armv7, arm64, i386 and x86_x64)
Since iOS8 using dylib(s) is meant to be possible, in fact one of the error messages I found googling was the following one:
ld: embedded dylibs/frameworks are only supported on iOS 8.0 and later
Which seems to suggest that embedding dylibs is actually possible and we aren't only restricted to the new so called dynamic frameworks, yet, when I try to run my project I get the following:
dyld: Library not loaded: #rpath/libtbb.dylib
Referenced from: /Users/user/Library/Developer/CoreSimulator/Devices/B4DCFF3E-10B2-4C01-953F-BD26D14300E7/data/Containers/Bundle/Application/8C84A844-97FC-4993-A37E-A456C4E2240F/TestTBB.app/TestTBB
Reason: image not found
I thought it would be due to the dylib not being automagically copied into the app being built so I added it to the "Copy Bundle Resources" section in the projects "Build Phases" and I've since made sure that the libtbb.dylib is in fact being copied into the app and yet I keep getting the message saying that it can't be loaded.
I've tried using the "Embedded Binaries" section under "General" but it seems to be restricted to using only the new framework types.
Is there anything I might be missing?
As you may have noticed I'm trying to use TBB which comes with its own build makefiles that generates dylibs, I'm assuming that if it does it's because dylibs can be used, legally since the iOS8+ update.
I have seen ways of getting dylibs to load, but these aren't the ones that Apple would accept in their AppStore, I'm trying to do this for an app that is currently on the AppStore and I have no plans of getting it removed or not accepted after an update so I'd like to go with whatever the new "legal" way is to get dylibs loaded. My app is targetting iOS9.2+ since the latest update so this shouldn't be an issue.
All I can find are ways to get dynamic frameworks loaded but no info about actual dylibs even though the error message clearly states that they could be used.
Alternatively, is there a way to build a dynamic framework out of existing dylib files?
Thanks in advance.

zxing in xcode 4.5 and ios 6

As many of you noticed; zxing does not work in latest xcode (4.5/ios 6)
Here is use case:
checkout latest version from trunk (as some fixes were already added)
create single view application in xcode 4.5 with ios 6.0
use README to add dependencies, paths etc (just follow step by step)
add zxingcontroller call to class (renamed to mm)
Compilation fails both for simulator and device
It shows 31 error like this one:
Undefined symbols for architecture i386:
"std::string::c_str() const", referenced from
all 31 errors are similar, difference is in symbols name
May be somebody knows how to solve it with this use case?
p.s. if you have app from previous Xcode, it works. Problem is only if you create new app in Xcode 4.5
The issue you have encountered seems to be C++ standard library related.
Actually, whenever you see linker failures in relationship with standard library objects (e.g. std::string), you should check the project settings on all linked libraries and the app-project itself. They usually need to match!
The original ScanTest (which builds ZXingWidget as a subproject) uses the following settings and those need to match your App build-settings if you use the library as is.
For making sure, I created a brand-new project using Xcode 4.5. That project uses ZXingWidget as a prebuilt library but not as a subproject - I dont like subprojects for stuff that is not my own - though this specialty wont influence the results.
The important setting is C++ Standard Library - make sure that is set towards Compiler Default
Little clarification
Actually, you do not need to use C++ Standard Library, you may as well use LLVM C++ standard library with C++11 support. But you will have to use that exact same library in all projects, sub-projects and libraries that link with your project. So if you insist on using the more recent version of that library (C++11 support), then you will have to build the ZXing library with those settings as well.
Last but not least, make sure your Architectures and Valid Architecture settings are matching over all projects and sub projects (fixing the common armv7s linker issue).
First, make sure your Architectures setting is set towards armv7 armv7s within all projects. Then also edit the project settings of all projects towards Valid Architecture armv7s armv7.
You might also want to switch the "Other Warning Flag" -Werror off. Seems to be necessary in Xcode versions > 4.5 (LLVM compiler > 4.1).
It works for me, have you enabled -lstdc++ in your list of Other Linker Flags in the Build Settings tab of the project target? It sounds like it is not recognizing the c++ symbols needed for zXing to build. If this is the case, the above advice should help.

Ho can I use adMob library for iOS without using -all_load linker flag

I'm adding adMob provide by google to my iOS app and I'm stuck on this part of the installation:
Add -all_load under Other Linker Flags in the project build info
If I add that flag, then another third party library breaks giving me the error message:
ld: duplicate symbol _vw_chartype_table_p in /Users/josh/ Projects/app/libs/libvt_universal.a(vw_ctype-3279EF26D0C25F3A.o) and / Users/josh/Projects/app/libs/ libvt_universal.a(vw_ctype-34AB9EC0B46D954C.o) for architecture i386
Is there any way to use the adMob library without using -all_load? For example, I've tried -force_load $(SOURCE_ROOT)/adMob/libGoogleAdMobAds.a
but
ld: file not found: /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
The reason Google suggests using -all_load is that they are using categories in their code, and Objective-C libraries with categories are not properly loaded by the llvm linker (well that was the case in 4.3 xcode, not sure about 4.4 with the newer clang).
So, I guess if you are brave you can try to just remove the all_load flag. It should build fine. If the bug is NOT fixed, what will happen is when you run your code, it will crash, since none of the categories the library uses will have been loaded. This might be a good thing to do in any case, as your project should build, and if it does not you can fix those problems first.
What I do suggest you do is use -force_load, which has llvm load the categories in the adMob library (among other things). To use it you MUST have a fully qualified path (ie starts at '/') to the library. Obviously if you use Terminal and run:
ls -l /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
its going to fail. So enter the proper path - hard coded - for now to just see if you can get the project to first build, then run. If it does you can later figure out what is the appropriate $(VAR) to use to find it inside your project.

Resources