Code does not compile for extra large implementation file - objective-c

The compiler exits by throwing following error.
/var/folders/2t/jkh9ngsn6f9bnmz8l0mz0zm80000gs/T/xsdLocal20-ZhAiH9.s:1895977:branch out of range
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
The file has 98341 number of lines.
using compiler Apple LLVM 3.1
The code builds for simulator but not for iOS device

Save the original file.
Comment out out #implementation after another, til the file compiles properly. Npw you know the class that is giving you the problem.
Then take the very biggest method, adding '#if 0' around the code, and at the top before the '#if 0', return a proper value - YES, NO, nil, whatever so the file will compile.
Compile. Do you still get the problem? Then comment out the next largest method, or just do the methods sequentially, or use a binary search technique (ie comment out one half of the methods, then the other half, to drill down on the culprit.
Once you find the problem method, you will need to refactor it into two or more methods, which probably can be private to the class, so your public interface does not change.

Related

I have opened .xcworkspace and when run application am getting clang: error: linker command failed with exit code 1 (use -v to see invocation)

duplicate symbol _GTMNSDictionaryURLArgumentsExportToSuppressLibToolWarning in:
/Users/Varshana/Library/Developer/Xcode/DerivedData/Lodore-axtsfmjdyxbqyccujoquacrynsxv/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libGoogleToolboxForMac.a(GTMNSDictionary+URLArguments.o)
/Users/Varshana/Documents/Lodore final stage/GoogleSignInDependencies.framework/GoogleSignInDependencies(GTMNSDictionary+URLArguments_aec9c2446af4c2ac5a7380b418b337ea.o)
duplicate symbol _kGTMOAuth2WebViewKey in:
/Users/Varshana/Library/Developer/Xcode/DerivedData/Lodore-axtsfmjdyxbqyccujoquacrynsxv/Build/Products/Debug-iphonesimulator/GTMOAuth2/libGTMOAuth2.a(GTMOAuth2Authentication.o)
/Users/Varshana/Documents/Lodore final stage/GoogleSignInDependencies.framework/GoogleSignInDependencies(GTMOAuth2Authentication_ad53759ab562393658e6c193e56628dd.o)
duplicate symbol _kGTMOAuth2ErrorRequestKey in:
/Users/Varshana/Library/Developer/Xcode/DerivedData/Lodore-axtsfmjdyxbqyccujoquacrynsxv/Build/Products/Debug-iphonesimulator/GTMOAuth2/libGTMOAuth2.a(GTMOAuth2Authentication.o)
/Users/Varshana/Documents/Lodore final stage/GoogleSignInDependencies.framework/GoogleSignInDependencies(GTMOAuth2Authentication_ad53759ab562393658e6c193e56628dd.o)
don't worry, just xcode bug. try clean and build and it will work, or better, go to xcode->preferences->location->Derived Data. delete all files inside derived data and then restart xcode. clean and build the project and then it will work perfectly
ps: updated for cleaning
Cmd + Shift + Alt + K
To check the exact error for this issue check following:
Select issue navigator > Click on error will show logs for error > In that select All Messages tab.
75 duplicate symbols for architecture x86_64
Means that you have loaded same functions twice. As the issue disappear after removing -ObjC from Other Linker Flags, this means that this option result that functions loads twice:
from Technical Q&A
This flag causes the linker to load every object file in the library
that defines an Objective-C class or category. While this option will
typically result in a larger executable (due to additional object code
loaded into the application), it will allow the successful creation of
effective Objective-C static libraries that contain categories on
existing classes.
https://developer.apple.com/library/content/qa/qa1490/_index.html

typedef in separate header file

I have a defines.h file with following code
typedef enum AnswerType : NSUInteger {
kAnswerTypeNotResponded = 0,
kAnswerTypeYes = 1,
kAnswerTypeNo = 2,
kAnswerTypeComplain = 3
} AnswerType;
When I import this file in several other files - I get an error
ld: 13 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I need AnswerType be visible in many places. What is the best variant to implement it?
Your enum looks fine. However, I guess there should be another problem.
One of the major reason for occurrence of this issue is that you might have a file listed in build phases more then once. So you need to make sure that files are listed in build phases only once.
Here are the steps you can follow:
Check Build phases in Target settings.
Check if any file exists twice.
If file exist twice delete one. If not delete file in the bottom which is the latest one.
Build again.
Original source of answer
Just follow below steps and your issue is solved.
1. Go to Build Setting
2. Search for No Common Blocks and
3. Set it NO
4. Build again
5. You will not get this error again.

duplicate symbol _OBJC_CLASS_$_Reachability in:

duplicate symbol _OBJC_CLASS_$_Reachability in:
XYZMobileApp/Build/Intermediates/XYZMobileApp.build/Debug-iphonesimulator/XYZMobileApp.build/Objects-normal/x86_64/Reachability.o
XYZMobileApp/BusinessLogic/Library/XtifyLib/XtifyPush.embeddedframework/XtifyPush.framework/XtifyPush(Reachability.o)
I am getting this error:
duplicate symbol _OBJC_CLASS_$_Reachability in:
and
clang: error: linker command failed with exit code 1 (use -v to see invocation)
you have used Reachablity class two times in your code.
One is included in the framework XtifyPush.framework and other you have included in the bundle.
Remove the one you are adding to remove the duplicacy.
Make sure that you did not include the Reachability.m -> implementation file instead of Reachability.h-> header file.
And also make sure you didn't include Reachability in you your unit test target this can also cause issues.
I renamed Reachability class as well as filename in library to "MyReachability". Xcode asked me to unlock the file as it was under pod. I unlocked it and after building i got few errors in my framework that Reachability class not found. I renamed the class references there as well to MyReachability and it worked fine. Hope this helps.

Accessing files using MPI

THIS WORKED (see comment in the code)
I am new to MPI and still learning it. I am actually trying to write a code in Fortran to read data from same set of files (already generated) on each processor at same time and perform different computations in different processors. For which I decided to use,
program...
use mpi
implicit none
.
.
.
call mpi_file_open(mpi_comm_world,filename_i,mpi_mode_rdonly,mpi_info_null,i,ierr)
to start with the program. Now, each processor calls a subroutine in which I am trying to use normal fortran command to open files, open(i,*)...(since I don't use mpi in subroutine).
First, I am not confident about this idea itself. Next, it gives this error,
_open(mpi_comm_world,filename_i,mpi_mode_rdonly,mpi_status_ignore,i,ierr) (1)
Error: There is no specific subroutine for the generic 'mpi_file_open'
at (1)
Please give your suggestions and comments.
The thing I am trying to do is very long because of subroutine, I would just include a prototype code, if this is solved, my problem will be solved. The code below gives the same error as said before. Please give your suggestions. Thanks.
program hello
use mpi
integer::ierr,num_procs,my_id,i,j,no
call MPI_INIT(ierr)
call MPI_COMM_RANK (MPI_COMM_WORLD,my_id,ierr)
call MPI_COMM_SIZE (MPI_COMM_WORLD,num_size,ierr)
open(4,file='hella') !CHANGING THIS LINE
do i=1,num_size
if(i-1 .eq. my_id)print*,"In",my_id
if(i-1 .eq. my_id)then
read(4,*)no
print*,no
endif
enddo
call mpi_finalize(ierr)
end program hello

Objective C, CABase.h file error

I hate Xcode 4! It crashes all the time and finally it gives me an error in CABase.h file which is an library header file that I am not allowed to modify..
I don't even know how this file is broken.
How to fix this problem? It complains like
"Expected *before*
Expected '=',',',';','asm' or '_attribute_' before 'extern'
Also, how can I completely remove Xcode on my Mac and re-install?
You probably just have a simple error, perhaps in a header which is included prior to CABase.h. Use a "divide and conquer" strategy to locate it.
To answer your last question:
$ sudo /Developer/Library/uninstall-devtools –mode=all
This happened to me just because I had the letter 's' at the beginning of one of my implementation files. I must have missed the cmd key when cmd+s for saving the file. Luckily, another compile error discovered this and removing the 's' fixed both errors.
For example,
s//
// GraphingViewController.m