Zbar SDK - missing required architecture x86_64 - ios

I had one problem during building application in the recent Xcode 5.1. Compilation fails with "Undefined symbols for architecture x86_64" error.
I build my project with Valid Architecture: armv7, armv7s and arm64. After switch to the newest environment (Xcode) I rebuild libzbar.a library in the same architecture ( I have done it based on solution found at: Linker Error in Xcode-5)
Maybe somebody also had same problem and finally he had solved it, please share with solution:)

I had the same problem and I solved that way:
Remove the reference of folder ZBarSDK from your project.
Download the version for armv7, arm7s and armv64 from this link .
Replace the older folder for the new, (Save a copy in case )
Add the new folder into your project.
Clean the project and Build.
Let me know if it works for you.

Recompile ZBar for iphone 6
Steps
Download the source code (you must have Mercurial for mac):
Open Terminal and run following commands
a. hg clone http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar
b. cd zbar
c. hg checkout iPhoneSDK-1.3.1
d. open iphone/zbar.xcodeproj
In the xcode project edit the "libzbar" scheme and select Release in Build configuration
Go to Build Settings set following Architectures
a. Architectures - >Standard architectures(armv7,armv72,arm64)
b. Valid Architectures -> arm64,armv7 armv7s
Compile libzbar for device AND for simulator, here the configuration:
Find the compiled libzbar.a and go in the folder using Teminal.app,
In My Case : /Users/kappe/Library/Developer/Xcode/DerivedData/zbar-gyozyrpbqzvslmfoadhqkwskcesd/Build/Products
In this folder you you should have two sub folder Release-iphoneos and Release-iphonesimulator
using xcode command line tools build your universal lib:
lipo -create Release-iphoneos/libzbar.a Release-iphonesimulator/libzbar.a -o libzbar.a
Now you can use the libzbar.a created, both in device and simulator.
Ref: xcode 5.1 - Undefined symbols for architecture x86_64 (zbar)

Make sure your libzbar.a contains all the architectures you needed in your project. You may need following to build for device and simulator:
armv7 armv7s arm64 i386 x86_64
You can test this using following command:
xcrun -sdk iphoneos lipo -info libzbar.a

for me: xcode 6, iphone 6 works the fpauer's method!
the way:
Remove the reference of folder ZBarSDK from your project.
Download the version for armv7, arm7s and armv64 from this link .
Replace the older folder for the new, (Save a copy in case )
Add the new folder into your project.
Clean the project and Build.

I had same problem yesterday and I was finally able to build with 64-bit simulator.
After the link you tried, I replaced the library and all the header files. but it wasn't enough. Then I also unlink the libzbar.a from Link Binary With Libraries on Bulid Phases and re-add the library. Then it was working.
Let me know if it works for you.

I was on the ZBar train as well for quite a while dealing with these issues since they have not been updating the SDK. Luckily if your app only has to support iOS7 onwards (which most iOS users are on now!) there is now QR/Bar Code reading support in AVFoundation so you can build your own reader very easily. Check out this tutorial:
http://www.appcoda.com/qr-code-ios-programming-tutorial/
Then bask in the beauty that is a totally Apple supported QR Code reader!

Related

object file built for free standing (BlackBerry Dynamics iOS SDK)

I'm having trouble to build an external pre built dependency. It throws the following error:
In /Users/me/Projects/app/ThirdParty/GoodFiles/GD.framework/GD(nondga_helper.o), building for iOS, but linking in object file built for free standing, file '/Users/me/Projects/app/ThirdParty/GoodFiles/GD.framework/GD' for architecture arm64
One of the questions that really bothers me is that I don't have a real idea what "free standing" really means. I thought it had to do with being a fat binary, but after running lipo -thin arm64 GD -o GD (and verifying with -info that it really worked) in one of my build scripts I'm still seeing the same problem.
I also tried to exclude arm64 from the simulator and x86_64 from iOS builds in Excluded Architectures as mentioned elsewhere, but that didn't work either.
Removed the Xcode 12 reason. This already doesn't compile anymore in Xcode 11.
Hi there are new BB certification files you have to add along with the usual GD.Framework files. These are documented on Blackberry website
New Xcode build system
GD.framework
BlackBerryCerticom.xcframework
BlackBerryCerticomSBGSE.xcframework
Legacy Xcode build system
GD.framework
BlackBerryCerticom.framework
BlackBerryCerticomSBGSE.framework
https://docs.blackberry.com/en/development-tools/blackberry-dynamics-sdk-ios/8_1/blackberry-dynamics-sdk-ios-devguide/Steps-to-get-started-And-iOS/rqx1490022241984/Prepare-an-app-to-use-the-static-framework
Check:
Xcode > Preferences > Locations > Command Line Tools
In my case it was set to Xcode 12 after installing Xcode 12. There is NO Xcode 12 proof solution until mid December.

Build iOS framework towards My Mac with Xcode 11.2 report errors

I upgrade my xcode recently.
When I build my iOS frameworks towards My Mac, most of them works fine. However one framework build failed. The error as follow:
My Mac doesn’t support any of XXX.framework’s architectures. You can add My Mac’s x86_64h architecture to XXX.framework’s Architectures build setting.
I have tried add x86_64h, x86_64, and arm64e to valid architecture, but it doesn't work.
I also tried to compare build settings between these frameworks, but failed to find out an solution.
Any suggestion to solve this problem?
I had the same issue, then I changed Valid Architectures to arm64 x86_64.
After this, I was able to build the framework and use it.

Getting error in Paytm Payment Gateway while uploading app on appstore

Getting Module compiled with Swift 5.0.1 can not be imported by swift 5.1 error while i have added PaymentSDK Swift5. Then i tried PaymentSDK 5.1 framework not getting this error while uploading app to AppStore. Working perfectly on development mode.
Applied this solution
https://github.com/Paytm-Payments/Paytm_iOS_App_Kit/issues/37#issuecomment-533982199
https://github.com/Paytm-Payments/Paytm_iOS_App_Kit/issues/40#issuecomment-538249618
The error clearly mentioned about you are uploading with simulator framework, during upload your framework should not contain simulator frameworks x86_64, i386. When you do uploading add shell script that removes that architecture from release builds. Use this script in the build phase script.remove simulator architectures
Copy PaymentsSDK.framework in your Mac’s Downloads folder.
// Open Terminal and move to the Downloads folder of your mac.
cd /Users/<Your Mac's User Name Here>/Downloads
//Run these commands to strip the x86_64 and i386 builds from your binary.
lipo -remove x86_64 PaymentSDK.framework/PaymentSDK -o
PaymentSDK.framework/PaymentSDK
lipo -remove i386 PaymentSDK.framework/PaymentSDK -o
PaymentSDK.framework/PaymentSDK
//That’s it. Now you have stripped out all the unnecessary builds from your //binary.
Now-Again. Copy Payments.sdk from your Downloads folder and replace it from the previous binary.
// Now, it will be validated successfully without any issues.
You can integrate the latest SDK for iOS. The Github link for the SDK is https://github.com/paytm/Paytm_iOS_All_in_One_SDK. Its integration information is available on developer docs of Paytm.

iOS project fails to compile under xcodebuild for deployment target 7.0, but is fine for 6.0. Compiles for both under Xcode

I have an iOS project that has iOS 6.0 as a deployment target. It builds fine both under Xcode and xcodebuilder (necessary for CI). However the client now wants the project to only be available for users who have iOS7+ installed.
No problem, I'll just increase the deployment target number right? Wrong!
Under Xcode the project continues to compile just fine. Under xcodebuild however, the project fails to compile with lots of errors like this:
Undefined symbols for architecture armv7:
"std::string::_Rep::_S_empty_rep_storage", referenced from:
in drmNativeInterface
It's using Adobe Primetime and drmNativeInterface is part of that.
To help isolate the problem I've created a brand new, single-screen project and performed the following changes:
Added the drmNativeInterface framework and the two Apple-supplied dependencies that are required for the project to build in Xcode, MediaPlayer and AVFoundation to "Link Binary with Libraries". The Primetime documentation lists other dependencies as well but it makes no difference if I add those - these are the only 2 that are needed for a successful build under Xcode.
Replaced the valid archs "arm64 armv7 armv7s" with "armv6 armv7 armv7s" (even though drmNativeInterface apparently contains i386, x86_64, armv7s and arm64 slices, even Xcode won't compile the project unless I switch arm64 for armv6).
Set "Build Active Architecture Only" to NO for both configurations.
And finally, added "-lstdc++ -ObjC -all_load" to "Other Linker Flags".
Other than those few steps above, the project is stock single-screen: no code has been added.
Xcode will compile it but xcodebuild will not. For xcodebuild to compile it I have to switch the deployment target to 6.0 which defeats the client's request.
The CI xcodebuild command contains a few params but here's the minimised command I'm using for this test project:
xcodebuild -project "MyProject.xcodeproj" -scheme "MyProject"
I've tried adding FRAMEWORK_SEARCH_PATHS, HEADER_SEARCH_PATHS and ALWAYS_SEARCH_USER_PATHS params in case xcodebuild was simply unable to use the paths contained within the project file but that made no difference.
If I remove the drmNativeInterface framework from the project - leaving the 2 Apple-based dependencies alone - the project compiles just fine for both Xcode and xcodebuild. But obviously this isn't a solution because I need that framework!
Does anyone have any idea what could be causing this or how to fix it?
**NB: **
There are a lot of questions on SO where projects will build in Xcode and not in xcodebuilder, but I couldn't find any where a project will build in xcodebuilder just fine for one deployment target and not for another.
Thanks in advance.
Linking the libstdc++ library (in this case, libstdc++6.dylib to be exact) fixed the problem.
You lose the libstdc++6.dylib in Link Binary With Libraries
Just add it like :

How to export "fat" Cocoa Touch Framework (for Simulator and Device)?

With Xcode 6 we get ability to create own Dynamic Cocoa Frameworks.
Because of:
Simulator still use 32-bit library
beginning June 1, 2015 app updates submitted to the App Store must include 64-bit support and be built with the iOS 8 SDK (developer.apple.com)
We have to make fat library to run project on devices and simulators. i.e. support both 32 and 64 bit in Frameworks.
But I didn't find any manuals, how to export universal fat Framework for future integration with other projects (and share this library with someone).
Here is my steps to reproduce:
Set ONLY_ACTIVE_ARCH=NO in the Build Settings
Add support armv7 armv7s arm64 i386 x86_64 to Architectures (for sure)
Build Framework and open it in Finder:
Add this framework to another project
Actual result:
But in the end I still have problem with running project with this framework on devices and simulator at once.
if I take framework from Debug-iphoneos folder - it works on devices
and gets error on simulators: ld: symbol(s) not found for architecture i386
xcrun lipo -info CoreActionSheetPicker
Architectures in the fat file: CoreActionSheetPicker are: armv7 armv7s arm64
if I take framework from Debug-iphonesimulator folder - it works on simulators. and I have error on device: ld: symbol(s) not found for architecture arm64
xcrun lipo -info CoreActionSheetPicker
Architectures in the fat file: CoreActionSheetPicker are: i386 x86_64
So, how to create a dynamic framework that works on devices and simulators?
This answer related to Xcode 6 iOS Creating a Cocoa Touch Framework - Architectures issues but it's not duplicate.
Update:
I found a "dirty hack" for this case. See my answer below.
If someone knows more convenient way - please, let me know!
The actuality of this answer is: July 2015. It is most likely that things will change.
TLDR;
Currently Xcode does not have tools for automatic export of universal fat framework so developer must resort to manual usage of lipo tool. Also according to this radar before submission to AppStore developer who is framework's consumer also must use lipo to strip off simulator slices from a framework.
Longer answer follows
I did similar research in the topic (the link at the bottom of the answer).
I had not found any official documentation about distribution of so my research was based on exploration of Apple Developer Forums, Carthage and Realm projects and my own experiments with xcodebuild, lipo, codesign tools.
Here's long quote (with a bit of markup from me) from Apple Developer Forums thread Exporting app with embedded framework:
What is the proper way to export a framework from a framework project?
Currently the only way is exactly what you have done:
Build the target for both simulator and iOS device.
Navigate to Xcode's DerivedData folder for that project and lipo the two binaries together into one single framework. However, when you build the framework target in Xcode, make sure to adjust the target setting 'Build Active Architecture Only' to 'NO'. This will allow Xcode to build the target for multiple binarty types (arm64, armv7, etc). This would be why it works from Xcode but not as a standalone binary.
Also you'll want to make sure the scheme is set to a Release build and build the framework target against release.
If you are still getting a library not loaded error, check the code slices in the framework.
Use lipo -info MyFramworkBinary and examine the result.
lipo -info MyFrameworkBinary
Result is i386 x86_64 armv7 arm64
Modern universal frameworks will include 4 slices, but could include more: i386 x86_64 armv7 arm64
If you don't see at least this 4 it coud be because of the Build Active Architecture setting.
This describes process pretty much the same as #skywinder did it in his answer.
This is how Carthage uses lipo and Realm uses lipo.
IMPORTANT DETAIL
There is radar: Xcode 6.1.1 & 6.2: iOS frameworks containing simulator slices can't be submitted to the App Store and a long discussion around it on Realm#1163 and Carthage#188 which ended in special workaround:
before submission to AppStore iOS framework binaries must be stripped off back from simulator slices
Carthage has special code: CopyFrameworks and corresponding piece of documentation:
This script works around an App Store submission bug triggered by universal binaries.
Realm has special script: strip-frameworks.sh and corresponding piece of documentation:
This step is required to work around an App Store submission bug when archiving universal binaries.
Also there is good article: Stripping Unwanted Architectures From Dynamic Libraries In Xcode.
I myself used Realm's strip-frameworks.sh which worked for me perfectly without any modifications though of course anyone is free to write a one from scratch.
The link to my topic which I recommend to read because it contains another aspect of this question: code signing - Creating iOS/OSX Frameworks: is it necessary to codesign them before distributing to other developers?
This is not so clear solution, but there is only way, that I find:
Set ONLY_ACTIVE_ARCH=NO in the Build Settings
Build library for simulator
Build library for device
Open in console Products folder for your framework (you can open it by open framework folder and cd .. from there)
Run this script from Products folder. It creates fat Framework in this folder. (or do it manually as explained below in 3. 4.)
Or:
Combine these 2 Frameworks using lipo by this script (replace YourFrameworkName to your Framework name)
lipo -create -output "YourFrameworkName" "Debug-iphonesimulator/YourFrameworkName.framework/YourFrameworkName" "Debug-iphoneos/YourFrameworkName.framework/YourFrameworkName"
Replace with new binary one of the existing frameworks:
cp -R Debug-iphoneos/YourFrameworkName.framework ./YourFrameworkName.framework
mv YourFrameworkName ./YourFrameworkName.framework/YourFrameworkName
Profit: ./YourFrameworkName.framework - is ready-to-use fat binary! You can import it to your project!
For project, that not in Workspaces:
You can also try to use this gist as described here. But it seems, that it not works for projects in workspaces.
#Stainlav answer was very helpful but what I did instead was to compile two versions of the framework (one for the device and one for simulator) and then added the following Run Script Phase to automatically copy the precompiled framework required for the running architecture
echo "Copying frameworks for architecture: $CURRENT_ARCH"
if [ "${CURRENT_ARCH}" = "x86_64" ] || [ "${CURRENT_ARCH}" = "i386" ]; then
cp -af "${SRCROOT}/Frameworks/Simulator/." "${SRCROOT}/Frameworks/Active"
else
cp -af "${SRCROOT}/Frameworks/Device/." "${SRCROOT}/Frameworks/Active"
fi
This way I don't have use lipo to create a fat framework neither the Realm's strip-frameworks.sh to remove the unnecessary slices when submitting to the App Store.
basically for this i found very good solution. you just need to follow these simple steps.
Create a cocoa touch framework.
Set bitcode enabled to No.
Select your target and choose edit schemes. Select Run and choose Release from Info tab.
No other setting required.
Now build the framework for any simulator as simulator runs on x86 architecture.
Click on Products group in Project Navigator and find the .framework file.
Right click on it and click on Show in finder. Copy and paste it in any folder, I personally prefer the name 'simulator'.
Now build the framework for Generic iOS Device and follow the steps 6 through 9. Just rename the folder to 'device' instead of 'simulator'.
Copy the device .framework file and paste in any other directory. I prefer the immediate super directory of both.
So the directory structure now becomes:
Desktop
device
MyFramework.framework
simulator
MyFramework.framework
MyFramework.framework
Now open terminal and cd to the Desktop. Now start typing the following command:
lipo -create 'device/MyFramework.framework/MyFramework'
'simulator/MyFramework.framework/MyFramework' -output
'MyFramework.framework/MyFramework'
and that's it. Here we merge the simulator and device version of MyFramework binary present inside MyFramework.framework. We get a universal framework that builds for all the architectures including simulator and device.
My Answer cover the below points:
Make framework which works for both simulator and Device
How to export “fat” Cocoa Touch Framework (for Simulator and Device both)?
Undefined symbols for architecture x86_64
ld: symbol(s) not found for architecture x86_64
Steps 1: First build your frameworks with Simulator target
Steps 2: After success of simulator building process, now build for your framework with device target selection or Generic iOS Device selection
Step 3: Now select your framework target and for that Under "Build Phases" select "Add Run Script" and copy the below script code)
Step4: Now finally, build again and your framework is ready for both simulator and device compatibility. Hurray!!!!
[Note: We must have both compatible framework ready before final step4 (simulator and device architecture compatible, if not please follow above steps 1 and 2 correctly)
See the reference image:
Put below code into shell area:
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
# Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# Step 5. Convenience step to copy the framework to the project's directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
# Step 6. Convenience step to open the project's directory in Finder
open "${BUILD_DIR}/${CONFIGURATION}-universal"
I just want to update this great answer by #odm. Since Xcode 10, the CURRENT_ARCH variable doesn't reflect the build architecture anymore. So I changed the script to check the platform instead:
echo "Copying frameworks for platform: $PLATFORM_NAME"
rm -R "${SRCROOT}/Frameworks/Active"
if [ "${PLATFORM_NAME}" = "iphonesimulator" ]; then
cp -af "${SRCROOT}/Frameworks/Simulator/." "${SRCROOT}/Frameworks/Active"
else
cp -af "${SRCROOT}/Frameworks/Device/." "${SRCROOT}/Frameworks/Active"
fi
I also added a line to clear the target directory before copying, because I noticed that additional files in subdirectories wouldn't be overwritten otherwise.

Resources