Xcode 7 command failed due to signal: illegal instruction 4 - xcode

I just used Xcode 7's migration tool to migrate a project from Swift 1.2 to 2. After fixing up errors missed and such, all is well except for an error which prevents me from even building: Command failed due to signal: illegal instruction 4.
I have tried the help in these articles (Xcode 7 and Swift 2.0 : Command failed due to signal: Abort trap: 6, and Command failed due to signal: Abort trap: 6) which are not identical issues to mine, but nevertheless they were not able to fix the issue.
I have cleaned the build and removed the derived data folder. I have up to date CocoaPods installation, Xcode tools are at 7.0, and I Swift compile optimization is at None. Is there anything else I'm missing?
Thanks!

So an answer was found thanks to the help of a coworker. We found the offending file in the build error, but there was no line provided. Through process of elimination, we found it to be a line that was declaring a new constant to the result of getting a JSON dictionary ([String : AnyObject], typealiased to JSONDictionary), from inside an optional dictionary. Here is the line:
let objectsDictionary = maybeJSON?[key] as? JSONDictionary
Changed this to two guard statements:
guard let goodJSON = maybeJSON as? JSONDictionary else { return ... }
guard let objectsDictionary = goodJSON[key] as? JSONDictionary else { return ... }
This line worked in Xcode 6.3.2 as it would just provide an optional value, but for some reason, some change in Xcode 7 didn't like this. I hope this can help anyone else who runs across this.

'Illegal instruction' simply means that your binary contains instructions that are invalid for the type of architecture you are trying to run the code with. Start looking at the minimum version in your project build settings.

Related

Throwing error while debug and run PO command in Xcode 12

When I am running application on simulator or device and try to use PO command during debug. Xcode is throwing error instead of printing value. It is happening after I have updated Xcode 12.
error: virtual filesystem overlay file
/all-product-headers.yaml' not found
error: couldn't IRGen expression. Please check the above error messages for possible root causes.
What is the solution for this ?
Any help would be appreciated.
Go to /Users/<YOUR_USER>/Library/Developer/Xcode/ and delete "DerivedData" folder.
If in the path of the missing file is the name of a framework e.g. Usabilla.build/Release-iphonesimulator/Usabilla.build/all-product-headers.yaml
Try using an older version, using version 6.4.7 of Usabilla fixed the issue for me.
If the above fixes don't work, here are some info that might help:
https://steipete.com/posts/couldnt-irgen-expression/

Xcode 11 Beta 5 - Loading a plug-in failed

Opening a SwiftUI "Hello World" unaltered project in Xcode 11 beta 5 running on Catalina beta 4 produces a "Loading a plug-in failed" dialog warning.
Has anyone else experienced this or know how to solve it? I deleted Xcode, redownloaded it, reinstalled it and I'm still getting the same error.
No idea how to fix other than deleting the offending module, but that can't be right.
Error details:
Details
Loading a plug-in failed.
Domain: DVTPlugInErrorDomain
Code: 2
Failure Reason: The plug-in “com.apple.dt.UVKit” at path “/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework” could not be loaded. The plug-in or one of its prerequisite plug-ins may be missing or damaged.
Recovery Suggestion: The plug-in or one of its prerequisite plug-ins may be missing or damaged and may need to be reinstalled.
User Info: {
DVTPlugInDYLDErrorMessageErrorKey = "dlopen(/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit, 0): Symbol not found: _$s2IDs12IdentifiablePTl\n Referenced from: /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit\n Expected in: /usr/lib/swift/libswiftCore.dylib\n in /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
DVTPlugInExecutablePathErrorKey = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
DVTPlugInIdentifierErrorKey = "com.apple.dt.UVKit";
NSFilePath = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework";
}
--
The bundle “UVKit” couldn’t be loaded.
Domain: NSCocoaErrorDomain
Code: 3588
Failure Reason: The bundle couldn’t be loaded.
Recovery Suggestion: Try reinstalling the bundle.
User Info: {
NSBundlePath = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework";
NSDebugDescription = "dlopen(/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit, 265): Symbol not found: _$s2IDs12IdentifiablePTl\n Referenced from: /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit\n Expected in: /usr/lib/swift/libswiftCore.dylib\n in /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
NSFilePath = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
}
--
I was able to get my SwiftUI project running on Catalina beta 4 with Xcode beta 5. I too got the warning mentioned by OP.
And as mentioned in comments, the only negative impact I've seen is being unable to use the preview canvas. Other than that, everything else in my project is running well. Just using the simulator more ;)
Problem is gone on Catalina build 19A558d when installing Xcode 11 GM Seed (build 11A419c, released September 10, 2019)
this will get rid of the error message but will not bring canvas back.
based on:
https://forums.developer.apple.com/thread/120614
Please go to: /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework and delete all the shortcut files in all folders of UVKit.framework (Be sure DONOT delete orginal files).

Xcode watch 'invalid expression'

I'm stepping through some Swift code in Xcode and I'd like to watch values. Following the advice in many of the answers here (e.g. this one) I can add the expression to the local variables window.
The breakpoint I am on is the last line of this fragment from the Starscream library (by daltoniam) which I include as a pod.
for i in 0..<dataLength {
buffer[offset] = data[i] ^ maskKey[i % MemoryLayout<UInt32>.size]
offset += 1
}
var total = 0
I've added two expressions to watch:
buffer[0] and
MemoryLayout<UInt32>.size
For both the value I see is "invalid expression":
These expressions are clearly are not invalid, if they were the code would have thrown an exception when they were encountered executing the previous few lines. What am I missing? How should I watch and not get 'invalid expression'
N.B. If I call p buffer[0] from the lldb prompt I get the cryptic error:
(lldb) p buffer[0]
error: warning: :12:9: warning: initialization of variable
'$__lldb_error_result' was never used; consider replacing with assignment to '_'
or removing it
var $__lldb_error_result = __lldb_tmp_error
~~~~^~~~~~~~~~~~~~~~~~~~
_
error: :19:5: error: value of type 'WebSocket' has no member
'$__lldb_wrapped_expr_72'
$__lldb_injected_self.$__lldb_wrapped_expr_72(
^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
I have tried changing the podfile (as per Jim's answer) so that it explicitly gets the debug code:
pod 'Starscream', '~> 3.0.6', :configuration => 'Debug'
and I have even gone as far as removing the pods, cloning Starscream, and including the source code as a sub-project. I still get the same error.
An expression that accesses buffer[0] where buffer is a UnsafeMutablePointer works correctly in the expression parser when I'm stopped in some simple function. And from your experience with the expr command directly, it looks like your problem is not with this particular expression. Rather it looks like there's something about the context you are stopped in that's tripping up the expression parser altogether.
Make sure that you aren't using binary cocoapods's and that you've rebuilt all your code and all the pods you are using have been rebuilt from scratch with the same swift compiler. At present, lldb and swiftc are version locked - lldb can only debug programs built with the swiftc that it ships with.
If that doesn't fix the issue, then we'll need to figure out what about the particular function you are stopped in that's causing the problem. This seems like the sort of thing better dealt with by filing a bug with the swift project (http://bugs.swift.org).

Build crashes on displayAvailable in xcode

I am building my app from Unity and have been succesfull before, but now seems to have an issue with this DisplayManager.mm:
- (BOOL)displayAvailable:(UIScreen*)targetScreen;
{
return self[targetScreen] != nil;
}
It crashes my build saying: EXC_BAD_ACCESS (code=1, address=0xc)
on this line: return self[targetScreen] != nil;
I have no idea to do about this... Any help is appreciated :-)
Thanks in advance
You can fix this error by changing the code around line 227 to be this:
_displayConnection = [[NSMapTable
mapTableWithKeyOptions:NSPointerFunctionsStrongMemory | NSPointerFunctionsObjectPointerPersonality
valueOptions:NSPointerFunctionsStrongMemory | NSPointerFunctionsObjectPointerPersonality
] retain];
That's how I fixed for myself, but I think you should first try upgrading Unity, I saw some people having this error fixed recently by downloading the latest version of Unity 4 or 5.
Also, I found out that this error can happen if you are using a recent version of Unity and has disabled ARC.

xcodebuild (XCode 7.1) - unexpected successful exit code from cancelled command

I'm getting the following during the bundle resources copying phase in xcodebuild (XCode 7.1):
2015-11-03 22:16:28.218 xcodebuild[28202:300463] DVTAssertions:
Warning in
/Library/Caches/com.apple.xbs/Sources/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-9061/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/BuildSystem/Runtime/PBXTargetBuildContext.mm:739
Details: unexpected successful exit code from cancelled command
<C0505:'CpResource Foo.json':P10> Object: <PBXTargetBuildContext:
0x7faec015a440> Method:
-createCommandInvocationRecordFromInvocation: Thread: <NSThread: 0x7faebc8cc070>{number = 10, name = (null)} Please file a bug at
http://bugreport.apple.com with this warning message and any useful
information you can provide.
I have ~170 items I'm copying, but for some reason a few of them give me this error.
EDIT - I just ran the command again and now it works, so it doesn't seem deterministic.
The issue was a duplicate folder in the Copy Bundle Resources section. It used to be two different files, but they were moved so XCode decided to change them both to the folder they got moved into. Go figure.
Had this issue a couple of months ago. Today that error made it's comback.
I have it only if I try to emulate from ionic (--livereload) on a iOS-Device. Seem like if you have Xcode running it occurs. Close Xcode. That fixes it.

Resources