ARCHS[#]: unbound variable in Xcode 12 - ios

Our iOS project is built successfully in Xcode 11. However, on Xcode 12, it shows an error like this:
PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/NgoHoangLien/Library/Developer/Xcode/DerivedData/BeneKitten-asctqxwawireafgebpjujkfxjvcg/Build/Intermediates.noindex/BeneKitten.build/Debug-iphoneos/BeneKitten\ Dev.build/Script-6F989132ECCA2B13FEF9458F.sh (in target 'BeneKitten Dev' from project 'BeneKitten')
cd /Users/NgoHoangLien/Project/Benekitten-iOS
/bin/sh -c /Users/NgoHoangLien/Library/Developer/Xcode/DerivedData/BeneKitten-asctqxwawireafgebpjujkfxjvcg/Build/Intermediates.noindex/BeneKitten.build/Debug-iphoneos/BeneKitten\\\ Dev.build/Script-6F989132ECCA2B13FEF9458F.sh
sent 1868986 bytes received 70 bytes 3738112.00 bytes/sec
total size is 1868525 speedup is 1.00
/Users/NgoHoangLien/Project/Benekitten-iOS/Pods/Target Support Files/Pods-BeneKitten Dev/Pods-BeneKitten Dev-frameworks.sh: line 144: ARCHS[#]: unbound variable
Command PhaseScriptExecution failed with a nonzero exit code.
I followed guides on the internet to make "arm64" for EXCLUDED_ARCHS. Delete VALID_ARCHS. But it still cannot compile. I hope you the senior engineers, experts like you can help me.

Note :- React native developers
After wasting couple of hours only solution that worked for me was
Open VSCode and go to directory ios/App/App.xcodeproj/project.pbxproj that file
and perform a search EXCLUDED_ARCHS
EXCLUDED_ARCHS = arm64;
and delete everyline containing EXCLUDED_ARCHS

For Xcode 12.3, when there is no VALID_ARCHS property, follow below steps:
Build Settings -> Build Active Architecture Only -> Debug -> Yes
Add "arm64" in "Excluded Architectures" in build settings of both project and pods project, to run the app in simulator. Remove it while making build on device or archiving the app.

You may try below steps:
In Main Project(Not TARGETS), Go to build settings and add Simulator-iOS 14.0 SDK with value arm64 inside Excluded Architecture and repeat the same for the Pod project too.
Delete VALID_ARCHS from your Main project and Pod project both.(You may open the project file in editor to delete this) [You already did this ✅ ]
Upgrade all Pods to the latest version available.
Last, Clean Project and Re-Build.

I got this error in my React Native app and finally found the issue and the fix.
Initially I added the arm64 for all 4 like this in Build Settings -> Architectures -> Excluded Architecture. And this was my issue.
But it should be like this. Only for Any iOS Simulator SDK in both Debug and Release.
Then my error fixed.
I think this will help you. Happy coding!

In my case for Xcode 13.1, Here's what I did:
Build Settings -> Build Active Architecture Only -> Debug -> No (both project and pods project)
Remove the "arm64" in "Excluded Architectures" in build settings of both project and pods project.
I was running on my real device if you try with simulator you might need to do the opposite

In our case, we needed to add x86_64 to VALID_ARCHS to build on simulator.

Make sure that in your
Project -> build settings -> Excluded Architecture
and
Pods -> build settings -> Excluded Architecture
The same values.
In my case, this soap is due to in Project architecture was arm64 but in Pods nothing
Just remove arm64 from Excluded Architecture if you start Archive or installing on real device

All the answers here are probably wrong for your project, and have the potential of breaking your project. You can only remove excluded archs completely if all your pods use xcframework and are ready for the arm64 simulator architecture.
The correct answer is to remove excluded archs from directly to the right of "Debug" and "Release", and add arm64 for excluded arch for "Any iOS Simulator SDK" only:
Adding arm64 as an excluded arch directly to the right of "Debug" and "Release" will exclude arm64 for the physical iOS device, and all physical iOS devices are arm64, hence why the build cannot be packaged.

The Build Settings editor no longer includes the Valid Architectures build setting (VALID_ARCHS), and its use is discouraged. Instead, there is a new Excluded Architectures build setting (EXCLUDED_ARCHS). If a project includes VALID_ARCHS, the setting is displayed in the User-Defined section of the Build Settings editor. (15145028)
-> https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes
It works for me by removing VALID_ARCHS lines on my project.pbxproj

you need to open this page and delete excluded architectures inside debug and release section if it is default arm64 delete it!
clean your project (cmd + shift + k)
clean derived data (dev.cleaner)
and restar your mac

I've got the same issue here.
I want to launch the application either on a connected device or on a simulator. And I get the error ARCHS[#] unbound variable trying to use the simulator.
Steps to fix the issue:
Choose the architecture either x86_64 for the simulator or arm64 for the device picture 1
Check VALID_ARCHS list contains the target architecture picture 2
Launch pod install command (the step propagates the right architecture to the pod-generated Xcode projects)
Build and launch the application

In build-settings, set VALID_ARCHS to $(ARCHS_STANDARD).

i had the same issue once we converted to XCFramework,
fixed by(still not for debugging and only for archiving)
1.build active architecture only - YES
2.remove arm64 from excluded architecture( if it was given)
3.valid_archs - arm64 (only arm64 )
after that i am able to build successfully on "any device"

Related

CocoaLumberjack.h file not found?

Actually my project does compile for an iPhone 6s but not for any iOS simulators. When I want to build for a simulator I get two build time errors.
Errors
'CocoaLumberjack/CocoaLumberjack.h' file not found
and
failed to emit precompiled header
'/DerivedData/Project/Build/Intermediates.noindex/PrecompiledHeaders/Bridging-Header-swift.pch'
for bridging header
'/Users/Development/ProjectMobile/Views/Project-Bridging-Header.h'
What have I tried yet?
pod deintegrate, clear Build, delete "DerivedData", pod install and pod update
open Project.xcworkspace instead of Project.xcodeproj
keep target iOS version in podfile and deployment target the same (iOS 12)
check "Framework Search Paths" at targets build settings 1
check "Header Search paths" 2
I am not 100% sure if the paths are correct. And I am wondering that Xcode can't find Cocoalumberjack.h, because I can find it under /Pods/CocoaLumberjack/Sources/CocoaLumberjack/Supporting Files/CocoaLumberjack.h.
Questions
Are these paths probably incorrect?
What else could be the problem?
I am happy for every serious answer!
(1) Framework Search Paths
(2) Header Search paths
Xcode couldn't build the project for an iOS simulator because there was no valid CPU architecture set for the simulator (respectively for the Mac).
Under Project > Targets > User-Defined > VALID_ARCHS there were just armv7, armv7s and arm64 architectures set.
I added x86_64 architecture to the VALID_ARCHS and it works fine now.

Xcode 6.3 missing required architecture arm64 [duplicate]

Just upgraded to Xcode 5.1, getting the following error:
ignoring file
...Dependencies/SalesforceNetworkSDK/libSalesforceNetworkSDK.a,
missing required architecture arm64 in file
...Dependencies/SalesforceNetworkSDK/libSalesforceNetworkSDK.a (3
slices)
If I turn off build active archs only and remove arm64 from valid archs I get:
Build/Products/Debug-iphoneos/libPods.a, file was built for archive
which is not the architecture being linked (armv7)
According to apple's release note, see the following note point.
Note:
Be aware of the following architectures issues when opening your
existing projects in Xcode 5.1:
When building for all architectures, remove any explicit
architectures setting and use the default Standard Architectures
setting. For projects that were previously opted-in using “Standard
Architectures Including 64-Bit”, switch back to the “Standard
architectures” setting.
When opening an existing project for the first time, Xcode 5.1 may
display a warning about the use of the Xcode 5.0 architectures
setting. Selecting the warning provides a workflow to revise the
setting.
Projects not able to support 64-bit need to specifically set the
architectures build setting to not include 64-bit.
So you've to set architecture as below to support libs architecture.
Reference from this post.
Update: From May 15, you've to take build from 5.1.1, see this post.
Don't know previous iOS but Setting Build Active Architecture Only to YES in iOS 8 did the trick.
I ended up getting my project to build by (1) turning off build active archs only (2) removing arm64 from valid archs and (3) making sure that the Pods project was building for only armv7 and armv7s.
Also worth noting here, that at the time of writing this edit, Salesforce mobile SDK was not available for arm64
I just changed the Debug from Yes to No,
Build Settings -> Architectures -> Build Active Architecture Only -> Debug -> NO.
This one fixed my error.

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 :

Xcode 5.1 - No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386)

After updating to Xcode 5.1, I can no longer build my project for the 64-bit simulator, receiving this error:
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).
These are my target build settings:
I tried changing "Build Active Architecture" to No, as well as adding "i386" to the "Valid Architectures", unfortunately neither worked.
Thanks for any suggestions!
What you need to do is just set the ONLY_ACTIVE_ARCH to NO (at least works for me). Below is a screenshot for it:
EDIT:
As far as I know (please point it out if there's something wrong, thanks), if you set ONLY_ACTIVE_ARCH to YES, it means the Xcode will only build for the active architecture (which refers to the device that's active in Xcode currently). Seems Xcode's default setting is set Debug to YES, so it won't build binaries for other architectures when you only want to build for a special device that connected to your Mac.
The reason failed to build might be that, the project does not support the architecture of the device you connected. So the best solution is to add the right architecture for your device. Below is a list for architectures & the devices that support:
ARMv8/ARM64: iPhone 6, iPhone 5s, iPad Air, Retina iPad Mini
ARMv7s: iPhone 5, iPhone 5c, iPad 4
ARMv7: iPhone 3GS, iPhone 4, iPhone 4S, iPod 3G/4G/5G, iPad, iPad 2, iPad 3, iPad Mini
ARMv6: iPhone, iPhone 3G, iPod 1G/2G
So why "set the ONLY_ACTIVE_ARCH to NO" works? Because the device can still run the binary that built for all architectures you added (pass the build), but will lose some performance. This's just a quick solution, but not best.
Note: The more architectures you added, the bigger the binary will be generated. So it's good to choose right architectures for your project. ;)
I had the same error message after upgrading to XCode 5.1. Are you using CocoaPods? If so, this should fix the problem:
Delete the "Pods" project from the workspace in the left pane of Xcode and close Xcode.
Run "pod install" from the command line to recreate the "Pods" project.
Re-open Xcode and make sure "Build Active Architecture Only" is set to "No" in the build settings of both the "Pods" project and your own project.
Clean and build.
Add arm64 to the target's valid architectures. Looks like it adds x86-64 architecture to simulator valid architectures as well.
If you are using CocoaPods, the most likely problem is because your Pods project Build Settings for Build Active Architecture Only is set to Yes for Debug.
The solution is simple. Change it to No.
Similarly, change to No for your application project.
I had similar issue. Got it solved by changing "Architecture" to "$(ARCHS_STANDARD_32_BIT)" in Build Settings for Project.
Now, you have to select Standard architectures (armv7, arm64) - $(ARCHS_STANDARD) since apple recommends apps to be build on 64-bit architecture. Click : Apple document
Add:
Architectures: $(ARCHS_STANDARD_INCLUDING_64_BIT)
Valid architectures: arm64 armv7 armv7s
Just in case, for anyone still encountering the issue despite following the above, check that the simulator you are running is also the supported one. I had mine specified to arm7 and arm7s but was trying to run the app on a 64 bit simulator.
To avoid having "pod install" reset only_active_arch for debug each time it's run, you can add the following to your pod file
# Append to your Podfile
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
Just add arm64 in valid architecture.i hope it will work for you.
My problem was that the Pods project was targeting OS X, despite my Podfile having platform :ios. I'm using cocoapods 0.35.0.rc2.
To fix it, select the Pods project in the project navigator, and check that the Pods PROJECT node (mind you, not the Pods target) is targeting iOS. That is, the architectures build settings should be:
Architectures: $(ARCHS_STANDARD)
Base SDK: iOS 8.1
Supported Platforms: iOS
Valid architectures: $(ARCHS_STANDARD)
I also wanted to build all architectures, so I added the following to the Podfile:
post_install do | installer |
installer.project.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
I had to add the following i386 and x86_64 to Valid Architectures. I'm running Xcode 7.2 and targeting iOS 8+. I already had armv7, armv7s and arm64 in there and that was working in Xcode 6.4.
I faced the same problem when running my app on iPad using xcode 5.1. It got resolved by removing armv7s from 'valid architectures' and setting the 'build active architectures only' value to No. Both these fields can be found in your app->targets->build settings->architectures.
I arrived at this question due to a problem with command line build for simulator in Xcode 7.2. In case anyone else gets here with the same issue, I will share the solution I found:
Apparently there is a bug in Xcode 7.2 that causes xcodebuild to fail when trying to build for simulator. The solution is to specify the option "-destination", e.g:
xcodebuild -project TestBuildCmd.xcodeproj -scheme TestBuildCmd -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' build
Update
The above example command will build a binary including the graphics for iPhone 6 only. If the binary is run on other simulators, the iPhone 6 graphics is scaled to the platform. A better workaround which contains all graphics for all platforms is to specify the parameter PLATFORM_NAME=iphonesimulator, for example:
xcodebuild -project TestBuildCmd.xcodeproj -scheme TestBuildCmd -sdk iphonesimulator -arch i386 PLATFORM_NAME=iphonesimulator build
Try removing all previous architectures (i.e. remove the ARCHS_STANDARD setting) at the same time as you add i386 to the Architectures. This should change the active architecture to i386. I encountered a similar issue when I tried to build for armv7 by default, but it kept trying to build for arm64. I changed ARCHS_STANDARD to ARCHS_STANDARD_32_BIT, and this changed the active architecture chosen.
In acrhiecture - sometimes to support 6.0 and 7.0 , we exlude arm64
In architectures - > acrchitecture - select standard architecture arm64 armv7 armv7s.
Just below in Valid acrchitecture make user arm64 armv7 armv7s is included.
This worked for me.
I solved this problem using #Kjuly's answer and the specific line:
"The reason failed to build might be that, the project does not support the architecture of the device you connected."
With Xcode loaded it automatically set my iPad app to iPad Air
This caused the dependancy analysis error.
Changing the device type immediately solved the issue:
I don't know why this works but this is a very quick answer which saved me a lot of fiddling around in the background and instantly got the app working to test. I would never have thought that this could be a thing and something so simple would fix it but in this case it did.
I found that it was necessary to enter the architecture names by hand:
I don't know why this was necessary, i.e. why these values were not inherited from Xcode itself. But as soon as I did this, the problem went away.
In Valid architectures: Select each entry (release, debug) and build and press backspace. It should work

Zbar SDK - missing required architecture x86_64

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!

Resources