Compiler error: Invalid library file - CoreLocation - swift

I have one of my application, that is created in Xcode 8. I have used CoreLocation and MapKit in that app.
I have update app with latest iOS till now. and it was working fine. Now I am updating application with iOS 1. So I hvae opened app with Xcode 11.0 and updated all the required code. Also updated setting that is suggested by Xcode "Perform Changes" and all that.
Now I run application, but I am getting error like :
Compiler error: Invalid library file.
I have searched lot, but can't find any solution. Is this a bug in new Xcode or new iOS ?
Is there anything I have to do extra changes or settings ? Please guide me.
Is this known bug by Apple ?
EDIT :
2019-10-18 10:34:39.899827+0530 MapLocation[1697:57778] Compiler error: Invalid library file
2019-10-18 10:34:39.900098+0530 MapLocation[1697:57778] Compiler error: Invalid library file
2019-10-18 10:34:39.915973+0530 MapLocation[1697:57778] Compiler error: Invalid library file
2019-10-18 10:34:39.916228+0530 MapLocation[1697:57778] Compiler error: Invalid library file
2019-10-18 10:34:39.920608+0530 MapLocation[1697:57778] Updated coordinate are : <+23.02055700,+72.50524900> +/- 5.00m (speed -1.00 mps / course -1.00) # 10/18/19, 10:34:39 AM India Standard Time
2019-10-18 10:34:39.920697+0530 MapLocation[1697:57778] Latitude:- 23.0206, Longitude:- 72.5052
2019-10-18 10:34:39.925441+0530 MapLocation[1697:57778] Entering in ----> (Latitude:- 23.0206, Longitude:- 72.5052), With Radius:- 300.00
2019-10-18 10:34:39.925546+0530 MapLocation[1697:57778] Stated in ----> (Latitude:- 23.0206, Longitude:- 72.5052), With Radius:- 300.00
2019-10-18 10:34:39.926582+0530 MapLocation[1697:57778] Exit from ----> (Latitude:- 23.0021, Longitude:- 72.4995), With Radius:- 300.00
2019-10-18 10:34:39.926683+0530 MapLocation[1697:57778] Stated in ----> (Latitude:- 23.0021, Longitude:- 72.4995), With Radius:- 300.00
2019-10-18 10:34:39.932080+0530 MapLocation[1697:57778] Compiler error: Invalid library file
2019-10-18 10:34:39.932268+0530 MapLocation[1697:57778] Compiler error: Invalid library file
2019-10-18 10:34:39.948942+0530 MapLocation[1697:57778] Compiler error: Invalid library file
2019-10-18 10:34:39.949220+0530 MapLocation[1697:57778] Compiler error: Invalid library file

I'm seeing this issue also. It only happens if you implement the renderFor overlay for MKMapView. And without this function, I can't display the polyline that I'm adding to the mapView. This was working fine in Xcode 10.

Hope this will be fixed in the next version of xcode. But this only happens on the simulator. Use your real device for testing for now..

For me what works is to disable OS Activity Logging.
Add the Environment Variable: OS_ACTIVITY_MODE with value: disable on Product > Scheme > Edit Scheme > Run > Arguments.
Warning
Folks have reported that other useful logs for them have also been silenced.
Taken from a similar answer I gave regarding WKWebView, but reposting here for visibility after finding the logging noise appears also with MKMapView.

I started running into this error recently and was able to get it to go away by clearing the Simulator from Hardware->Erase All Content and Settings... menu item.

I worked around this by using SwiftLog to log my messages, putting some unique string inside the tag of each logger (could just be com.yourcompany.yourapp to differentiate it), and then filtering to messages which contain that tag on the console.
A more general solution would be to have a negative filter inside the console view, which would obviate the need to use the logger in this way.

I've got the problem too, trying to update multiple polylines coordinates.
The problem was coming, in fact, from the way new coordinates were pushed into the array containing the polylines coordinates (which is a property of a model object in my case).
To get the problem, i was just pushing new coordinates into that array.
To solve the problem, I had to clone that array first in a new var, then add the new coordinate into the cloned array and update the model property.
Before, i was doing :
existingArray.push(object);
Now, I am doing :
var newArray = [...existingArray];
newArray.push(object);
existingArray = newArray;
Hope it can help !

For those of you experiencing this error with IOS 15, take a look at a helpful article on raywenderlich that says the error can be safely ignored:
Note: If you’re running on the Simulator, you’re likely to see a plethora of errors of the form Compiler error: Invalid library file in the Xcode console. This is a simulator bug and can safely be ignored. Unfortunately, it makes the console rather noisy, making it more difficult to see the results of your print statements.
You may want to do some more research to confirm this for yourself, but raywenderlich has never lead me astray.

For me, this only happens when I have Traffic turned on for the map.
I leave the feature on but turn it off in the simulator:
#IBOutlet
var mapView: MKMapView? {
didSet {
#if targetEnvironment(simulator)
mapView?.showsTraffic = false
#endif
}
}

Related

Abort Trap: 6 error after upgrading to Xcode 14

I just updated my Xcode to Version 14.1 (14B47b) from version 13.4. When I try to run my SwiftUI project in the live preview, the "Abort Trap" errors showed everywhere in the project.
Part of the error log is as below:
CompileSwift normal x86_64 /Users/apple/Downloads/SwapSpot/SwapU/ViewModels/ItemVMs/ItemGridViewModel.swift (in target 'SwapU' from project 'SwapU')
unknown:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project
unknown:0: note: SmallVector unable to grow. Requested capacity (4294967297) is larger than maximum value for size type (4294967295)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
I found a post that answers as such:
We will not observe "Abort: trap 6", if under Build Settings, we are using "Optimize for Speed" in Debug, instead of "No Optimization"
We can also avoid "Abort: trap 6", if we change the following code
guard let batchUpdateResult = batchUpdateResult else { return }
to
guard let batchUpdateResult2 = batchUpdateResult else { return }
I tried both methods mentioned above. Renaming the guard let variable did not work at all. Changing the optimization level in the target removed all the Abort Trap errors, and the project runs successfully in the simulator.
However, the live preview stopped working due to the optimization level. The new error is stated below:
OptimizationLevelError: not building -Onone
"SwapU.app" needs -Onone Swift optimization level to use previews
I believe this is a swift compiler error. Can anyone help me avoid this while keeping the live preview working?

including Kal.a (from Kal calendar) and including libidn.a (xmpp framework) causes app to crash

After trying really hard i am posting this qustion in the 2 o clock of night in my office.
The problem is :
1) i have included Kal calender (link here) in my application
2) And its really working fine before i decided to include xmpp framework(xmpp framework) in my application.
3) The Main problem is when i try to include libidn.a file and then compile the project it gives me 4 errors , and to remove these error i have to remove "Other linker flag -> -all_load".
4) Here the problem begins when i have removed -all_laod flag and compile , app compiles success fully. But i try to run my app and press calendar button to load calender it crashes with following error:
-[__NSDate cc_dateByMovingToFirstDayOfTheMonth]: unrecognized selector sent to instance 0x75b85c0 2012-06-12 01:38:47.483 BizPro[10251:11903]
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate
cc_dateByMovingToFirstDayOfTheMonth]: unrecognized selector sent to
instance 0x75b85c0'
* First throw call stack: (0x209e022 0x22f0cd6 0x209fcbd 0x2004ed0 0x2004cb2 0x12bc3d 0x12bb91 0x13149e 0x1315f6 0x12961 0xa8d38f
0xa8d5eb 0xa9dff1 0xa9e85f 0xa9e9e1 0xbbc5c2 0xa02d21 0x209fe42
0x856679 0x860579 0x7e54f7 0x7e73f6 0x874160 0x9d4f30 0x207299e
0x2009640 0x1fd54c6 0x1fd4d84 0x1fd4c9b 0x26e67d8 0x26e688a 0x9c4626
0x2a9d 0x2a15 0x1) terminate called throwing an exception(lldb)
4) I know very well that this error is a misguide (NSDate is not causing the crash but the collision of static libraries is doing it , i think so) , because when i again add -all_load flag and remove the libidn.a file from my project , It compile and RUN successfully and calendar displays my data smoothly.
i googled a lot about it .. and got very little guidance .. relating the solution to workspaces and all that .. But i really dont know what could be the solution .. Plz help me
Thanks
cc_dateByMovingToFirstDayOfTheMonth
is an addition to NSDate that is defined in NSDateAdditions.h from the Kal Framework.
I had no end of problems and wanted more customisation of the Kal framework so I just dragged all the source code into my project.
If you still have issues with the framework then remove Kal.a and just bring in the source code :) then you can get dirty with it
If you rather keep Kal as a subproject, the way to fix this is to link the addition files.
Under
Project -> Build Settings -> Linking -> Other Linker Flags
add '-all_load'
sorry i am answering late ..
i solved the problem ..
removed kal.a file and just included src folder (all the header files required)
so that i will not collide with the other static library ...
Similar problem here. Because I'm using Parse Framework, can't add -all_load, so integrating static library will never work for me. The simplest way is to add all source files in src folder to my own project, rather than adding Kal.xcodeproj. Other steps to config "copy bundle files" or "header search path" etc are still necessary. I also need to add these lines from Kal_Prefix.pch to my own project.pch.
#import "NSDate+Convenience.h"
#define RGBCOLOR(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1]
#define RGBACOLOR(R,G,B,A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
#define kDarkGrayColor RGBCOLOR(51, 51, 51)
#define kGrayColor RGBCOLOR(153, 153, 153)
#define kLightGrayColor RGBCOLOR(185, 185, 185)

Strange Xcode error

When I run my app, i get one error and i dont know how to fix it. Can someone help me?
Here is the error:
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
Picture: http://imageshack.us/photo/my-images/200/screenshot20110609at256.png/
Thanks
The causative problem is the error immediately preceding that one, the duplicate symbol error.
gcc-4.2 failed with exit code 1 Error Occurs due to some of your file or frame work are duplicated check it out which file is in you target link file or in your framework are repeated.
from your log message "didUpdate" may be repeated in your project look for that...
May be this is helpful to You.
From the error message, it seems like didUpdate is defined more than once in your code. Search for didUpdate on your workspace and make sure it's only being defined once.
Either you are redefining variable or you are probably importing a *.m file somewhere in your project.Try importing corresponding *.h file.

iphone: co-processor offset out of range

i have a strange compiling problem with xcode and iphone. my game is almost finish but now i got suddently this compiling error:
{standard input}:6108:co-processor offset out of range
gcc-4.2 failed with exit code 1
this only happens if i compile the release version for the device. the debug version and both versions for the simulator works. clean targets and recompile don't work.
strangly enough that error only happens if i add a line of code to one specific source file and only between these lines:
[_sharedDirector checkAndPutScoreToHighscore:(int)[player score]];
gameOverScreen = YES;
gameOverScreenSlideY = 320.0f;
[buttonManager activateButtonWithID:replayButton];
[buttonManager activateButtonWithID:menuButton];
so when i put a random line between this lines of code i get that error.
i do not know what causes this error. i had opened the sourcecode file to "show as assembly file" just for fun but i don't think this has caused the error.
has anybode a hint for me what could be going on? i am searching the web for over 3 hours and thats very frustrating.
You most likely found a compiler bug. You really should switch to the LLVM compiler (clang).

Exception when running on simulator 3.2

I'm testing my app on simulator 3.1.3, it runs fine.
When it come to simulator 3.2, it crashes right from the beginning:
2010-06-24 16:35:29.208 MyTestApp[6991:207] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'
2010-06-24 16:35:29.213 MyTestApp[6991:207] Stack: (
46195275,
2520474889,
46194715,
46194554,
6387912,
6392266,
5568184,
6388086,
6386450,
6392266,
5564974,
5573454,
3555255,
3560368,
3586056,
3567777,
3599431,
52998524,
45735996,
45731912,
3559044,
3591649,
10824,
10678
)
As far as I know, I do not use the "initWithCoder" method (do not really know what this is though).
How can I know where the exception is thrown so I could have a better understanding of what is causing the problem?
ps: I have added an exception in Breakpoint: objc_exception_throw (with location libobjc.A.dylib, strangely I had to enter the location manually, I expected xcode to find it for me when I added objc_exception_throw). But still the same trace and no more information.
This page should provide some helpful info: Debugging Tips for Objective-C
Of particular interest is the console command info line *. Every one of those numbers listed by the exception log is an address on the stack. Those bottom ones in the 10,000 and below range are usually located in the app's main method, for example. The highest ranged addresses tend to represent the default libraries.
Using the command info line *10678 would likely return some info about a specific line in the main method, which doesn't help very much. Normally the trick is to find the highest address before the default libraries begin. I'm unsure how much this will help your problem in particular, seeing as there's a huge gap between the expected small addresses and the next highest up. In any case, start with the smallest address above the bottom two (3555255 from what I can see in the log you posted) and see if it returns a line from one of your own code files. If it does, check the one above it, and so on until you find the last address from your own code. Hope this helps.
I figured out the reason of this error. I had created an object of type NSDictionnary within IB and it seems it was not the correct way to do this. Instead I have programmatically created this same object in XCode and this works fine. Seems like it was some kind of persistent problem.