iOS unzip library and arm64 archiecture - ios

I'm trying to unzip .zip files on iOS.
I tried ZipArchive but got lots of linking warnings about undefined architectures for arm64.
I suppose I could remove the arm64 architecture from XCode, but Apple must have started including it in iOS Xcode project templates by default for a reason, and I don't know enough about the ins and outs of that so don't particularly want to remove it in case it causes headaches in the future.
So I tried ZZipArchive which builds and runs but was failing to open the file, which when I traced through the code I found the failing function was called ZOPEN64(). Surprise surprise it has 64 in its name, can't be a coincidence.
I don't see the point in trying another iOS unzip library as they all seem to be wrappers around minizip etc. and thus will have the same fundamental issues.
Is anybody using an unzip library with iOS 7 AND the latest XCode beta?
What are the consequences of removing the arm64 architecture out of the project if that's the only way for now to get unzip up and running?

To answer your question, the ramifications of removing arm64 from the architectures is that some classes of application will perform slower on devices with 64-bit capable processors (right now just iPhone 5s) than they would with arm64 builds enabled.
Note: at this point arm64 is required for all applications.

Related

My swift static framework is doesn't work in OC file with iphone simulator

I have made a static framework that mix of Swift and OC, and it includes Architectures: "armv7 i386 x86_64 arm64".
it also includes all .swiftmodule file:
it works well with real device or in swift file for real device and simulator.
but only when i use framework's swift class in the Objective-C file and target device is iphone simulator, it will give me an error:
the BaseNavigationController(write in swift), BaseViewController(write in OC) are my framework classes, only the swift class doesn't work, the BaseNavigationController is a subclass of UINavigationController with 'open' level access control, and the framework '-Swift.h' file has generated oc interface.
Why does it report an error?I checked my project carefully,but no exception found。
my xcode version is: Version 11.5 (11E608c), and project build_setting's swift version is 5.0.
The issue here is very likely in the build script that is used.
The issue here might be that after using lipo to merge the framework built for devices(armv7 & arm64 architectures) and simulators(i386, x86_64) architectures, you should also copy contents of the BaseCore-Swift.h generated for the simulator to the one generated for armv7 & arm64 architectures.
Objective-C requires symbols to be defined for i386 and x86_64 architectures in the BaseCore-Swift.h file for Swift classes to work. This file can be found within the Headers folder after you perform a build.
You could simply use the cat command to perform this copy within your build script if you have one.
The issue here is not that architectures for the simulator are not included, but that the symbols are not defined in the BaseCore-Swift.h file for simulator architectures so Objective-C can pick them up.
Please feel free to comment or ask additional queries.
If doing the above solves your issue, please mark this as accepted :)

Xcode Warning: Ignoring file libxml2.2.dylib, built for unsupported file format which is not the architecture being linked

I have been given the task of adding a few features to an iOS app. I checked out the source on SVN to be greeted with over 100 warnings (argh), thankfully I'm down to the last one, which is:
(The blocked out bits are the client name...).
I believe this warning is saying something along the lines of: 'this XML library is not compatible with the OS architecture that is being linked on the build'.
With the next release, we are supporting only iOS5 and iPhone 4 and above (rather than lower versions of iOS and older iPhones).
So do I change the link architecture? What is the link architecture? How do I change the architecture? Or am I completely on the wrong track?
May be worth mentioning that I am running the latest Xcode, I've added the framework from the Xcode list (link binary with libraries).
EDIT
I only get the message when building from the simulator. It doesn't cause any harm, just winds me up!
Thanks in advance.
Do not link against libxml2.2.dylib, instead link against libxml2.dylib. Linking against that should ensure you are always linked against the correct implementation for your architecture.
As a general rule, in your applications link to the generic version of a library rather than a specific version. In this case this means libxml2 rather than libxml2.2 .
You are linking to a (symlink to a) dynamic library which at runtime will automatically point to the correct implementation for the current OS version and architecture. Linking to the specific version of a library does not guarantee this, and you can end up linking to a something that only has a single architecture. Thus, during development if you link to libxml2.2.dylib when targetting the simulator you may be linking against something that is i386, then when you target a device it can't find the correct architecture (because it's trying to use i386 for armvWhatever, which is exactly what you are telling it do).
If you're trying to use libxml2.2, it's already available in Xcode. Instead of getting it from an outside source (Apple wouldn't let you use a dynamic library anyway), add it in Xcode to your frameworks, and then link it by adding /usr/lib/libxml2/ in Header Search Paths. Don't link your project with a dylib that's not Apple provided or else your app will get rejected. Also, the architecture i386 isn't the architecture for iOS, as iOS uses the armv7 and armv7s architectures for the newer versions of their devices, which is why you are getting the architecture warning.
Basically the difference between libxml2.2 and libxml2 is that libxml2.2 points to a specific version/implementation of libxml whereas libxml2 is a shortcut/symlink that points to the latest version AND correct architecture of libxml2 that XCode can find. Therefore when adding a framework like this, you should always add the 'general version' (the symlink) of it (libxml2) rather than the 'specific version' of it (libxml2.2) because of the exact issue you're seeing.
Hope this helps!
That says you're linking to something built for 386 not arm.
You will either need a different dylib to link to or go into project settings and change the arch. ( if you are building the dylib)
Probably to include arm7 or similar.

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.

iOS project builds for armv6 when armv7 is specified (target is iOS 5.1)

I get a long list of errors that spit out (for every source file I have) linker errors to the .o files (stemming from said sources). The error for every one basically resolves to this:
CompiledSource.o, file was built for i386 which is not the architecture being linked (armv7)
Except that the issue is actually warning, technically. However, at the end of compilation/linking phase the project refuses to build with a simple Linker command failed with exit code 1 error.
I've been spending the past 2 hours trying to figure this one out.
In Targets->ProjectName->Architectures->Valid Architectures I have both armv6 and armv7 selected. I ALSO have my build target set for iOS 5.1.
In my Targets->ProjectName->Build Phases->Copy Bundle Resources, I have all of my resources added (I assume this is where resources such as image and nib/xib files are added).
Is there anything I can do about this? I've tried cleaning the project, removing all files from DataDerived folder in XCode root, and even cleaning out /var/folders. Admittedly, this project hasn't been touched since at the very latest 2011.
I should note that I'm pretty new to iOS stuff (as well as Xcode). Unfortunately, this project is under an NDA as well so I can't reveal too much info. However, if anyone has any questions I will answer the best I can.
Are you sure its an iOS application? Because that sounds like its linked to a custom framework that got build for i386 (OSX-intel) which would probably never work on iOS.
Did you try to Product->Clean? or [alt] Product->Clean Build Folder ?
Maybe have a look at some example code from apple and see how these iOS projects are struktured.

Mach-O Linker error

I am building ipad application in XCode 4. For that, i added some outside frameworks in my project. The code work fine in simulator but showing 24 Mach-O Linker error.
I searched for this topic and get various different reasons for this error but not getting the right one.
Any suggestion will be of great help.
Most likely the library you are using has not been built for arm. For a library to work in the simulator, it must be compiled for i386 architecture. To work on the device, it must be compiled for armv architecture.
To work for both, you need what is called a "fat" binary that contains versions compiled for each of the above. If you don't have that, you will receive the linker errors.
To find out what architectures the library is compiled for, use the following command:
lipo -info mylibrary

Resources