Matt S
Matt S

Reputation: 185

Swift Project not Building

I'm trying to convert one of my projects from purely Objective-C into Swift, but keep running into a problem with Xcode. With any Sprite Kit, Obj-C, or Obj-C/Swift project, everything will index, clean, build, and run successfully. However when the project is just comprised of .swift files, Xcode hangs on indexing and building, and won't do anything else. I've tried disabling indexing, nuking the DerivedData folder, even completely re-installing Xcode 6 along with the associated library files, but nothing seems to work. Any ideas on how to fix this?

Upvotes: 18

Views: 5283

Answers (7)

River Satya
River Satya

Reputation: 1099

XCode 8 beta 6 was hanging on Swift compilation for me. Turned out to be a circular reference in the class hierarchy. ie I had something like:

class Foo : Foo {
    // etc
} 

This came about through a refactoring from a more complex hierarchy, and I didn't notice. Clearly the compiler doesn't detect the cycle, and goes into an infinite loop :(.

Upvotes: 0

Cuong Thai
Cuong Thai

Reputation: 1165

I had the same issue with xcode 7 compiling forever. What I found is the initialization of map() in array caused the issue. I switched to use append() manually and the problem is solved. Here is the detail study http://applytech.me/blog/build-stuck-after-upgrading-from-xcode-6-to-xcode-7/ Hope it helps

Upvotes: 0

lmiguelvargasf
lmiguelvargasf

Reputation: 69675

I had the same problem, and I could find the solution when analyzing the following code

func toDictionary() -> NSDictionary  {
        return [
            "smartCoins" : smartCoins ?? 0,
            "name" : name ?? "",
            "birthDate" : birthDate ?? "",
            "photo" : photo ?? "",
            "gender" : gender ?? "",
            "zoneId" : zoneId ?? "",
            "cityId" : cityId ?? "",
            "username" : username ?? "",
            "id" : id,
            "smartShopperIds" : smartShopperIds ?? [String](),
            "followers" : followers ?? 0,
            "voucherIds" : voucherIds ?? [String](),
            "friend" : isFriend ?? false
        ]
    }

It turns out that the ?? operator increases the compilation time. Therefore, when it was used a few times (one to three), the compilation time increases but finishes. However, when having more, the compilation never ends.

I hope this helps.

Upvotes: 4

Nurdin
Nurdin

Reputation: 23883

There are no choices, you need convert it manually. No auto conversion so far.

Upvotes: 0

Mitsuaki Ishimoto
Mitsuaki Ishimoto

Reputation: 3181

This bug will relate to our project state and source code. I rolled back some commits of my project, xcode succeeded indexing my project.

In my case, xcode failed to index, when my project has a declaration of large dictionary. (I succeed indexing after removing it.)

Upvotes: 4

Apple Kid
Apple Kid

Reputation: 623

Hello I also faced the same problem and solved it.

go to product -> Click Stop. Until you see the indexing stops.

it worked for me. Try to stop the running if your not running

try it and tell me, if there's anything else.

Upvotes: 0

Abhi Beckert
Abhi Beckert

Reputation: 33329

I've tracked this down to some particular source code I was using (specifically tuples inside an array) that lock up the indexer.

There doesn't seem to be any workaround except to avoid having that particular source code in the project.

I filed a bug with Apple, Radar number 17241603.

Upvotes: 11

Related Questions