Upgrade project from swift1.x to swift2 - ios

after modifying lots of code for swift2, remove lots of error.
and finally it shows swiftc failed with exit code 1
and I got this error as well...
Invalid bitcast
%16 = bitcast i32 %15 to %CSo15NSManagedObject*, !dbg !252
LLVM ERROR: Broken function found, compilation aborted!
any idea on how can I locate the broken function??

Instead of fixing all the errors manually, you should do it automatically. See attached image.

Related

Swift expression evaluator (LLDB): error while loading Swift module

I have a target with mixed Swift and Objective-C code. I do the following:
I put a breakpoint on a line in a Swift file part of this target.
I run this target.
I type po $someVariableName in the debugger once it hits the breakpoint.
The debugger now shows a host of errors, ending with:
error: failed to import bridging header '/path/to/Bridging-Header.h'
Couldn't initialize Swift expression evaluator due to previous errors.
The output starts with:
Error while loading Swift module:
TARGET_NAME: /path/to/Bridging-Header.h:18:9: note: in file included from /path/to/Bridging-Header.h:18:
In between are a host of nullability annotation warnings and errors about unknown type names. Some errors come from bridging headers in the Carthage builds directory:
error: /path/to/project/Carthage/Build/iOS/Some.framework/Headers/Some-Swift.h
It seems as if whatever is executing after my po statement, lacks a few header imports or executes things in the wrong order. Any clue as to what could be wrong here?
I am using Xcode 11.4 (11E146)

xcodebuild linker assertion failure

I run into this ld assertion error while building an iOS dynamic framework in command line using xcodebuild.
0 0x10163b342 __assert_rtn + 144
1 0x101678a3a archive::File<arm64>::makeObjectFileForMember(archive::File<arm64>::Entry const*) const + 1138
2 0x1016783e8 archive::File<arm64>::justInTimeforEachAtom(char const*, ld::File::AtomHandler&) const + 122
3 0x10168ea75 ld::tool::InputFiles::searchLibraries(char const*, bool, bool, bool, ld::File::AtomHandler&) const + 265
4 0x101697db8 ld::tool::Resolver::resolveUndefines() + 160
5 0x10169a117 ld::tool::Resolver::resolve() + 79
6 0x10163c060 main + 812
7 0x7fff9dd4c5ad start + 1
A linker snapshot was created at:
/tmp/MyKit-2016-02-31-154836.ld-snapshot
ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-253.9/src/ld/parsers/archive_file.cpp, line 355.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
According to archive_file.cpp source code (http://www.opensource.apple.com/source/ld64/ld64-253.3/src/ld/parsers/archive_file.cpp) it seems there are some kind of symbol corruption while ld is loading a library. But other than that I have no clue how this issue might be fixed.
This issue shows up only when I try to build my framework with bitcode enabled by adding "-fembed-bitcode" compiler flag.
Also, in my ld command, I am trying to link against a few static libraries, one of them is > 4.25 GB (with bitcode built-in), and this size exceeds an unsigned 32-bit integer's max value (~ 3.99 GB). I previously run into a few issue with libtool related to not being able to handle large binary libs, so this is one of my suspicion.
I wonder if anyone has seen similar problems or figure out how to fix it ? Thanks
a few related questions
Weird xCode linker error I've never seen before saying "Assertion failed"
https://github.com/SciRuby/nmatrix/issues/69
http://lists.llvm.org/pipermail/llvm-dev/2013-October/066722.html
https://github.com/TrinityCore/TrinityCore/issues/14689
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57438
Do you want to read the explanation for your error, which is ld: Assertion failed: (memberIndex != 0) ...? Follow this link
Also, don't worry about the size of your static library. The linker will remove all unnecessary information in the final executable. Please read here
TL; DR version:
Clean your project using Command-Option-Shift-K. Also, choose Window > Organizer and switch to the Projects tab. Click the right-arrow to the right of the Derived Data folder name, delete Derived Data folder, and restart XCode.
go to Build Settings in your project's settings => find Linking->Other linker flags => add -v. This will show you the exact corrupted file that is causing your error, if it still occurs. If you have the error again, please post the path of the corrupted file here, we can work from there.
The reason of your error is because one of your static library is corrupt. You can remove your 4.25gb lib and rebuild again to see if this is the problem. It is under your project's target settings -> build phases -> link binary with libraries. If the error goes away, that might be it. In this case, care to give the name of the lib?
Just adding to oasisweng's answer.
Does one of the following help?:
Every time I upgrade Xcode, I get linker errors with brew installed GCC
Are you reliant on any dependencies that do not have Bitcode enabled?
Similar error reported at the Unity forum; see last post in thread

Compiler error with no line number

Whwn trying to compile my project, the following error appears in AppCode (Xcode only prints the "Error: Command... part"):
AppCode:
Note:Stored value type does not match pointer operand type!
Note: store %CSo7UIColor* %135, %objc_object** %136, align 8, !dbg !4686
Error: %objc_object*LLVM ERROR: Broken function found, compilation aborted!
Error:Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
Is there a way to actually get the line number causing the problem ? Note says something related to UIColor but that's the only thing I got from it :S
P.S: I have deleted Derived Data, checked out a previous commit, created a new project and still the same issue. I'm almost certain that the problem is due to a dependency.
Found the problem...
self.navigationController!.navigationBar.titleTextAttributes = [ NSForegroundColorAttributeName : .clearColor()]
.clearColor() should work...Fixed it by appending UIColor back.

swiftc failed with error code 1

i am building a swift/objc app. I have the app working fine on the device, but when i try to archive i get an error
Command
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
failed with exit code 1
The error seems to link to my Bridging-Header.h file.
I've tried some solutions with no success:
cleaning the Derived Data
setting the optimization level to None
UPDATE
i've installed xcode 6.3 beta 2 and upgraded class with appropriate swift 1.2; in the editor, the build works fine, but when i try to build in the terminal using:
xcodebuild -project Proj.xcodeproj
and i do get a specific error:
Call parameter type does not match function signature!
%V4Hive15MultivalueEntry.64* %0
%V4Hive15MultivalueEntry* tail call void #_TFFC4Hive22SwiftAddressBookPersonP33_FEAC8E239DA88BD1517B50EB72890C1824convertMultivalueEntriesFS0_U_Ss9AnyObject__FTGSqGSaGVS_15MultivalueEntryQ____9converterFQ_Q0__GSqGSaGS2_Q0____U_FGS2_Q__GS2_Q0__(%V4Hive15MultivalueEntry.64* noalias sret %0, %V4Hive15MultivalueEntry.63* noalias %3, i8* %.fn.load, %swift.refcounted* %6, %swift.type* getelementptr inbounds (%swift.full_type* #_TMdSS, i32 0, i32 1), %swift.type* %7), !dbg !5089
LLVM ERROR: Broken function found, compilation aborted!
2015-03-05 10:08:02.467 xcodebuild[6416:24559] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-7523/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/BuildSystem/BuildCommandResultsPostprocessing/XCClangResultsPostprocessor.m:68
Details: Unable to read diagnostics from file "/Users/erpk/Documents/Work/Hive/Hive/build/Hive.build/Release-iphoneos/Hive.build/Objects-normal/arm64/AddressBookManager.dia" (Invalid File): Invalid diagnostics signature
Function: void XCGenerateDiagnosticsFromFile(NSString *__strong, NSString *__strong, NSDictionary *__strong, NSDictionary *__strong, IDEActivityLogSectionRecorder *__strong, BOOL (^__strong)(IDEActivityLogMessage *__strong))
Thread: {number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
the main thing to get from this is
LLVM ERROR: Broken function found, compilation aborted!
this is generated in a certain file:
http://snipsave.com/user/profile/badescualex#10418
It looks like he problem is that there is an internal compiler error in the file AddressBookManager.swift I would start commenting out all implementation until you can get it to pass the build. Binary search style. You should be able to isolate it better that way. It would be great if you could provide the Swift team a failing project. They are generally very responsive given a repeatable test case.

LLVM ERROR: Broken function found, compilation aborted

Here are couple of simple lines in swift:
let umAB: Unmanaged<ABAddressBookRef> = ABAddressBookCreate()
let ab: ABAddressBookRef = umAB.takeRetainedValue()
The second line breaks code compilation, here's the error that I get:
Bitcast requires both operands to be pointer or neither
%27 = bitcast %objc_object* %26 to %PSs9AnyObject_, !dbg !170
LLVM ERROR: Broken function found, compilation aborted!
Command /Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 1
Any ideas what's wrong with the second line?
This is late, but the answer is simple: This is a bug in the compiler. LLVM ERROR implies that bad LLVM IR has been generated, and that is a bug in the calling program.

Resources