Converting an non ARC project to ARC error - iphone

When I converting my iPhone project to Objective - c ARC I am getting the same error all the time:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo: can't figure out the architecture type of: /Users/user/Library/Developer/Xcode/DerivedData/TestApp-fktzngidcyimjibgdosyphgbuzpe/Build/Intermediates/TestApp.build/Debug-iphoneos/TestApp.build/Objects-normal/armv7/TestAppCommand /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo failed with exit code 1
Please can someone advice me how can I resolve this?

If you are using 3rd party libraries that don't support ARC you should just add this flag to the files in question in your build phases/compile sources (prevents ARC on only those files). This should help you determine if your code is the issue or the library you are using (if that's the case).
-fno-objc-arc

Try to use this one
I solved this issue by changing the value of the Valid Architecture found in Project > Build Settings Architectures from the default "armv6 armv7" to "armv7". Hope this helps.

Make sure that you added the -fno-objc-arc flag to each implementation file (.m file).
And then clean the project (Project menu -> clean) and build again. I have sometimes had to clean and build twice when doing this in class. Seems like a little bug.

Related

error: unable to spawn process (Argument list too long) in Xcode Build

I am getting this error:
"error: unable to spawn process (Argument list too long)
** ARCHIVE FAILED **
The following build commands failed:
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(1 failure)
Exitcode =65 "
I went through this link:
Xcode export localization throws error "Argument list too long"
This article provides a good temporary solution of the problem stating to reduce the path hierarchy. But this does not seem to be an appropriate approach. Can anyone provide me with a different approach to the solution for this problem?
In my case, it was about custom configurations in .xcconfig files.
My config files were including Pods configurations like:
// Development.xcconfig
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.debug (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.release (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.release (development).xcconfig"
// Production.xcconfig
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.debug (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.release (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.release (production).xcconfig"
This produced the error you mentioned, when I added Firebase pods into my Podfile.
So to make this compile again I had to:
remove all inclusion (#include ...),
set them explicitly in the Project -> Info -> Configuration, as follows:
Quick tip:
If you don't want manually setting up corresponding target configurations (those with red icon), mark them as None and run pod install. This will automatically change it for you.
A few days ago I faced a similar challenge. I want to provide details and share my research with SO community.
First of all I found this thread and I followed the link in the asked question.
And yes, thats right, the answer marked in the link is correct, but the solutions to this problem did not suit me.
Problem
In my case, I had this problem when I changed the folder hierarchy in my project to be more convenient and suitable for me.
#oOEric option did not suit me, because according to the rules, the hierarchy of groups in Xcode should coincide with the hierarchy of folders in the system.
But I've already had about 1680 swift files to compiling.
The problem was that I had too long path to the compiled files and their number was too large.
Research
Then I start research and found swift jira with the same bug.
Here some links:
Main
Linked Issue 1
Linked Issue 2
Linked Issue 3
Bug on Open Radar
But here I didn't find some solutions for me.
Most of all I was pleased with this response of the swift developers.
Again, this is an Xcode-side issue, not a Swift-side issue. Commenting here won't make the Xcode engineers work any faster!
(We're not all the same people at Apple.)
Okey, after this answer, I was finally convinced that if it is an Xcode bug, then the solution should be sought in Xcode.
Solutions
Temporary solution
You need to move your project higher in the hierarchy of your system.
I choose this one, because I have really big project and the use of other solutions will require more than one day from me.
In my case, I conducted an experiment and calculated that the length of the path to the project should be no more than 50 characters.
But this is a temporary solution. If your project grows further, you will have to shorten the path or use other solutions.
Cocoa Touch Framework target
This solution is suitable for files that do not use dependencies.
First of all you need to add Cocoa Touch Framework as a target to you main project.
This target should be added automatically to Embedded Binaries and Linked Framework and Libraries.
After this you need to find some files without dependencies and change target membership to your "TestTarget".
Don't forget classes, properties, methods, enums, protocols from cocoa touch framework should have open or public access.
And don't forget clean your DerivedData folder.
Modular iOS
This solution has a more integrated approach.
If you want to use any dependencies in your Cocoa Touch Frameworks you should go to this guide and make more complex refactoring for your big project!
Link to solution
I think this is the best solution.
I hope this big answer will help someone!
I solved this by setting build system to Legacy build system
in file-> workspace setting -> select workspace setting
I solved this by reducing the hierarchy of groups in Xcode.
e.g. original files at project_name/project_name/About/Model/Text
I removed the groups "Model", "Text" and moved files under project_name/project_name/About/
I made simple script for temporary fix that problem. https://github.com/gregoryvit/flatter
It simply move all swift files in Xcode project to root group.
Error - unable to spawn process (Argument list too long)
There are many reason for this error. Some of these are mentioned below:
Your project might have many swift files (say more than 2000)
Most of the Swift source files may be deeply nested inside directories
Many of these files have absolute paths with more than 150 characters (eg. /Macintosh HD⁩/⁨Users⁩/jayprakashnd⁩/⁨mySampleProject/Module1…)
Xcode swift complier takes the absolute paths of all source files while so compiling, the ARG_MX limit is reached and build fails.
This has been fixed in Xcode 11 wherein a flag is used to set unlimited number of swift files.
Solutions:
Switch to Xcode 11 and add USE_SWIFT_RESPONSE_FILE to YES in build settings - User Defined Section
If you cannot switch to Xcode 11 then take a new checkout of your project in Macintosh HD⁩ ▸ ⁨Users⁩ directory with folder name as minimal as possible.
Solution 2 worked for me like a charm!
It happened to me when I use Xcode 11 beta version using Live Preview. Then I solved it by restarting Xcode after that error has gone.
I have fixed this issue, moving my folder of My Xcode project to the mac root and changing my name Folder to less characters.
Terminal: cd /
Change name folder to BX (example).
xcode11
-build setting
-user-defined
-add setting: USE_SWIFT_RESPONSE_FILE
-setValue: YES
Doing this you enable xcode to have more files than is allowed. But im not sure if this always solve the problem.
I have changed build type to legacy and it also resolved problem for me, both locally and on our CI builder. For me it was caused during checking Podfile.lock and Manifest.lock. Probably this could be skipped in our pipeline since we are always installing pods on CI.
If you faced this issue on your Flutter project while building in Release mode (or Archive) check out my this answer: https://stackoverflow.com/a/61446892/5502121
Long story short:
set your build system to New Build System in File > Project Settings…
remove ios and build_ios folders
run flutter create . to init new ios module
run pod install
run flutter pub get
check your Xcode build config (it should be Release mode and General iOS Device)
and you're good to go
I have the same problem. I fix it using a temporary solution, however that work for me.
My solution is to change the Derived Data folder to a directory with a shorter path.
The Steps is as the following:
Xcode -> File -> Workspace Settings... -> Select Custom Location for Derived Data and give a shorter path as the location.

'Convert to latest Swift Syntax' breaks the build even when there are no changes

My project is in objective-c with just one tableviewcontroller in swift. I downloaded the Xcode-beta today which prompted me to 'Convert to latest Swift Syntax'. After I follow the steps it shows me that there are no changes. I do not see any changes in the proj file either but it has errors. Please note that I do not see the errors when I choose not to covert to latest swift syntax - the app builds and runs fine in this case.
Any idea why it is breaking?
Here are the errors -
cannot parse the debug map for "app name" No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
the other errors are that it is not able to find the swift file. The swift class was initiated in the objective-c class.
Switch ENABLE_BITCODE to NO in project build settings helped me.
Product -> Clean helped in my case.
I had an issue similar to this, and I fixed it by changing the build phases/ compile sources in the project :
I had added in new sources that needed to be compiled earlier in the project, and after i deleted the files, when I tried to build the project it said it was missing the files that I deleted. After deleting a few of the build phases that appeared as though they were not the default build phases, it worked fine.
I found that there were a default of 4 compile sources.
Also, using Ctrl+Shift+K will clean your project, which helped me another time with an error like this.
I was having the same issue, and none of the above answers helped. Apparently, my issue was I had an import using a .m file instead of a .h file.
The easy way to find and fix these would be Find > Find in Project... and searching for #import.*m and changing them to the appropriate .h file

libCordova.a file missing in PhoneGap 2.9

Can you plz help me?
I am using XCode version 4.6.3 and phonegap version 2.9.
The project is running fine in Simulator but when I want to make a IPA file, it always build failed.
The message is showing like below:
file not found: /Users/admin/.../libCordova.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have found some discussion on this issue. Most of the solution is like (1) to change the BUILD ACTIVE ARCHITECTURE ONLY to YES, (2) to change the ARCHITECTURE only to armv7, (3) update the project after creating it...etc. But none of those working for me.
Plz help anyway.
Thanks in advance.
Follow these steps to fix this problem:
Go to project settings and Build Tab. Search for "Other Linker Flags"
Double click on the linker flags for Release and Change ${TARGET_BUILD_DIR}/libCordova.a to ${BUILT_PRODUCTS_DIR}/libCordova.a
Do the same for Debug
Clean and build archive again
If Prems answer doesn't fix the issue, try building your CordovaLib project first. After doing that I was able to build my project.
In addition to several other suggestions & post, I found that I was experiencing this problem on my AdHoc builds only.
The problem for me was the the CordovaLib subproject did not have an AdHoc configuration. Once I added an "AdHoc" configuration to the CordovaLib subproject, this started working.
Please note that I figured this out during debugging because if I set the Edit Scheme > Archive build configuration to "release" it would work OK, but if set to AdHoc it would give me a link error, telling me that this file could not be found:
/Users/jason/Library/Developer/Xcode/DerivedData/MommyNearest-ceourmykvgxdekbkmzenuvhcfnzk/Build/Intermediates/ArchiveIntermediates/MommyNearest/BuildProductsPath/Adhoc-iphoneos/libCordova.a
If you check the linker suggestion above and still not working. Make sure that Cordova project has the same configuration name. If your main project has "Debug, Release, and Production" configurations. Add same configurations in the Cordova project. Build Cordova and then build your project.
I you are using Xcode 5.0, do exactly the opposite and it works.

Linker command failed with exit code 1 error in Xcode project

I was working on my project and suddenly after editing the code and compiling gave this error:
ld: warning: directory not found for option '-
L/Users/mani/Documents/Classes/Twitter+OAuth/Libraries & Headers' ld:
duplicate symbol _OBJC_CLASS_$_playSiew in
/Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/playSiew.o
and
/Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/Thumb.o
for architecture i386 clang: error: linker command failed with exit
code 1 (use -v to see invocation)
I never touched the project settings, just edited the code.
What's more strange is that I took out last revised code from svn but still I got the the same error.
You may be accidentally #import'ing a .m file instead of a .h. Use Cmd+Shift+F and search for ".m" (without quotes). It will most likely lie in one of the classes mentioned in the warning. If not, clean and run again.
I was also having same issue and I did following and issue is gone.
Go to Product -> Clean and re-run the project.
I hope it might be useful for some other developers.
After running into this problem a few minutes ago (yes, I know it's been 7 months since the original thread) I found that the root of my issue was due to me dragging & dropping files into my project within XCode instead of right-clicking and choosing Add Files to Project.
Check playSiew.m is in Compile Sources section. isn't it?
You can find Compile Sources section follow this step
Select YourProjectName
Select TARGETS
Select Build Phases
If don't have playSiew.m in this section . You must to add it to this section.
As I said the problem wasn't the code but some settings. So what I did was copying the code from my friends' Mac (it was working fine), and installed a fresh copy of the project to my Mac. It worked.
I was importing a library in a test case which I had specified in my pod file for the main target but not for the test target.
I also got this error because I had accidentally included two versions of the same source file. Deleted the wrong one and the problem went away...
If you're working in Unity and export to iOS and you are using a plugin, go to Xcode Build Settings and set ENABLE BITCODE = NO. I'm guessing this might apply to other situations as well
Faced similar issue, while running the code on a simulator, tried all the above mentioned options, still got the same error. Tried connecting the iOS device and build the code, it worked for us. This can be a quick workaround.
the same error i faced. so, i just removed reference of that classes which are generating the errors and than again gave reference and the error was gone...
as D80Buckeye says there should be problem of dragging and dropping files instead of Clicking on "Add Files"
In case this comes in useful for anyone else--I just had this same error, and turns out the cause was initializing a variable in my header file rather than in the main file.
I just encountered the same error. If you are using embedded Libraries, make sure your Deployment Target is set to iOS 8.0 or higher.
you only need to add the following framework: quartzcore.framework
The only way we can get past this bug on our project is to do a Clean and then build for iPad Retina. After that it will build successfully for any device. Weird.
In my case i have add reference of FacebookLoginSDK framework but forget to give search path in build setting. After removing its reference everything was fine.
So conclusion is if you are adding any external framework be careful.
If this happens to you with CoreData generated classes, combine the +CoreDataProperties and +CoreDataClass into the +CoreDataProperties class and delete the +CoreDataClass. Make sure to search Derived Data for leftovers of the +CoreDataClass. Even after deleting the Derived Data and cleaning I sometimes had Xcode just generate the +CoreDataClass again and again. Deleting it manually in Finder and then re-bulding helped me solve this.
try this, go to Target -> Build Settings,then search these three as following,
GCC_NO_COMMON_BLOCKS,
CLANG_WARN_INFINITE_RECURSION,
CLANG_WARN_SUSPICIOUS_MOVE,
set NO to each value then clean and build.
I tried several of the answers listed but none worked for me.
I got the error after updating XCode (while it was still open which may have contributed to the problem)
First, I deleted my Derived Data folder:
XCode => Preferences => Locations => Double Click on arrow next to path indicating where the Derived Data folder is.
Then "Move to Trash"
I don't think that's what the problem was, but it's amazing how many times this has been an issue for me working on different problems.
Second, I 'Quit' the simulator.
Third, I 'Quit' XCode.
Fourth, I opened up my project in XCode again and then did a Clean and Build (found in the Product menu)
Fifth, I ran my project and it worked fine
Cleaning the project not works for me.
Restart the Xcode works for me...
For me it was different. I had the same error when I removed a Pod and solved it by removing this pod from the Other Linker Flags in the Build Settings
then clean your project [Product > Clean] and rebuild
Go to general and linked frameworks and libraries in xcode and remove all the files there.

Xcode4 Linking Problem. File was built for archive which is not the architecture being linked (arm6)

Recently, I switched to Xcode4 and when I compile my project I got following error.
ld: warning: ignoring file /Users/myname/Library/Developer/Xcode/DerivedData/appname-hezrgyqimckztgbdlslkavphdclw/Build/Products/Debug-iphoneos/libTapkuLibrary.a, file was built for archive which is not the architecture being linked (armv6)
Undefined symbols for architecture armv6:
"_OBJC_CLASS_$_TKLoadingView", referenced from:
objc-class-ref in RootViewController.o
I opened the TapkuLibrary and checked that it's Architectures set to 'Standard (armv6 armv7)'.
What can I do to fix this problem?
I figured out what caused the problem. I changed 'Build Active Architecture Only' of TapkuLibrary from Yes to No and it compiles with no problem.
I was able to solve this problem by doing the opposite of the accepted answer - I changed the 'Build Active Architecture Only' from NO to YES.
Had the same problem. But the reason was different I suppose. I was using the library.a file built for simulator and trying to run it on device.. came to know that i need different .a files for simulator and device. I hope this helps someone ;)
I met this problem when I upgraded the XCode to 4.5 and iOS to iOS6. For GMGridView, it just happened.
Not for simulator, but only for device.
I fixed this by the following steps:
1) Go to GMGridView project -> Build Settings
2) Under Setting -> Architectures, select "Standard (armv7, armv7s)"
Then clean all (including DerivedData) and rebuild.
Hope it helps!
Try to remove the armv6 architecture, and compile it only for armv7.
Something else that worked for me was making sure that all sub projects had the architecture set to be armv6 and armv7, making sure to set both the TARGET and the PROJECT of each sub project. After cleaning and rebuilding everything, it worked without a problem.
This solved the problem for me:
Some external library like three20 did extra settings for
Build Settings->Architectures->Any iOS SDK
the value is "armv6 armv7" that different from standard "armv7 armv7s"
drop down and select "Standard", it worked for me.
I managed it by clicking the "unfriendly" Project's (in my case GMGridView).
In tab "Architectures", I changed the value from something (I don't remember exactely anymore, I guess it was:) "armv7, armv6s" to "armv7, armv7".
After that it worked for me.
I managed to resolve this by just creating a adhoc configuration inside the Tapku info settings ...
XCODE 4, Project > Archive = library not found for -lTapkuLibrary - Issues - devinross/tapkulibrary - GitHub
Make sure the build variants on your projects are set to "normal".
If you are building a project which includes other projects, take a look inside the DerivedData folder for the main project. Examine the archive files with the "lipo -info yourarchive.a". Also, examine the timestamps on these archives. You may find that these libraries are not getting rebuilt or you are trying to link against an old version of the archive which is the wrong architecture.
In my case, I shutdown Xcode and deleted the DerivedData folder for my main project. This forced a full rebuild when I reopened the main project in Xcode 4. The full rebuild caused the i386 archives to be created (or the correct version to be found) & the simulator version to link correctly.
This worked for me :
Click on the offending framework's 'Project' file (xcodeproj).
Go to the "Info" tab for the framework's 'Project' (not 'Target').
Expand 'Configurations' and make sure that both 'Debug' and 'Release' have 2 configurations set--one for the framework's 'Project' and another for the framework's 'Target'. In the case of frameworks the 'Target' compiles to a Library and not an application, so it's easy to get confused.
'Debug' should have the Project set to 'Debug' and the Library set to 'Shared'
'Release' should have the Project set to 'Release' and the Library set to 'Shared'
Compile, run, and enjoy.
If you ended up mangling your entire project trying to figure this out, then you might want to double-check your Application's Project build phases (as Gon suggested). The Library should be there highlighted in red, even if it doesn't exist on your drive. If not, as long as it's set to 'Shared' you should be able to add it back again.
If you really really really mangled your project, then you may be forced to blow out your DerivedData folder, as russes suggested. Also, check the 'Organizer', since Xcode has a way of saving crap all over the place.
Oh, and you checked to make sure that 'armv6' is there right? :)
If I get the ignore file warning - I would run lipo -info on ignored file to find it's architecture as below
lipo -info libTapkuLibrary.a
That would print either of i386, armv6, armv7, armv7s, x86_64 etc. In general, that architecture has to match with your target build platform. E.g.
i386 = ios simulator or 32 bit build on mac os x
armv6 armv7 arm7s = ios device
x86_64 = 64 bit build on mac os x
Depending on the mismatch, either you have to rebuild your library for your target platform or change your target platform.
Note: For fat binaries, lipo -info will print a combination of above architectures.
I fixed this problem thanks to another thread where they show that armv6/armv7 is actually a little different than what you think it is: Upgrading to xcode 4 error No architectures to compile for
None of these answers worked for me. (Similar warning message, different static library project). For me it was having configured XCode to honor the build directories of the targets and then having targets build in a local build/ directory that caused the problem. Configuring XCOde to use "Derived data" folder fixed it.
I had this problem with the Three20 library. The thing that finally did it for me was switching the Project Format from Xcode 3.1 to Xcode 3.2 - leaving 'build active arch only' as "no".
I tried all the options above and none worked.
This is the right answer:
simply dragging a framework in your project won't link it properly (or something along these lines, in any case)
what you need to do is select the framework you want to add in Build Phases (click on your project's blue icon, then select your project's name under Targets, then the tab Build Phases), see here for more reference.
Had the same problem, and tried diverse solutions from the page to no avail.
I still had a message telling me my library was not build for arm64.
Finally how I resolved it :
opened the project.pbxproj for the library in a text editor
searched for VALID_ARCHS
there were 4 occurrences, 2 of which did not contain arm64
I manually added arm64 in the chain (VALID_ARCHS = "arm64 i386 armv7 armv7s")
rebuild the lib and it was all right
Seems sometimes the build settings displayed by XCode is incomplete, and doesn't correspond precisely to the make file.