4

Does anyone face this issue when trying to run their application on an actual iPhone (iOS version 8.4) using Xcode 7 Beta 4?

dyld: Library not loaded: /System/Library/Frameworks/GameCenter.framework/GameCenter Referenced from: /private/var/mobile/Containers/Bundle/Application/CC713E5A-7839-43F1-9AEB-932AE2A3DF8A/.... Reason: image not found

For your information, it has been working with no errors before I switch to Xcode 7...

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
LFS
  • 145
  • 1
  • 9

3 Answers3

2

In Project Settings->Build Settings weak link both the new iOS 9 GameCenter lib and the old GameKit libs and try again. You can weak link them by specifying the 'Status' as 'Optional'.

enter image description here

You need the old one still incase you're running on an older iOS than 9 which will need the GameKit stub library linked in still as it won't know about the new GameCenter one for iOS 9.

It may also be necessary to change

#import <GameKit/GameKit.h>

to

#import <GameCenter/GameCenter.h>

If I had to guess the change might simply be down to using a less generic library name as Apple continue to add more game orientated libs (Spritekit, Scenekit, Replaykit etc), renaming the main GameCenter lib from GameKit to GameCenter makes sense.

jdtec
  • 51
  • 3
  • Sorry... could you explain how to weak link both the new iOS 9 GameCenter lib and the old GameKit libs? I currently only see the new GameCenter lib which is needed for the application to compile without error i.e. import GameCenter. How do you support both? If I am running on iOS 8.4, then how do I specify the old GameKit stub library? Thank you. – LFS Aug 04 '15 at 09:04
  • Do the added details explain well enough and does the answer solve your problem? – jdtec Aug 04 '15 at 11:10
  • Thanks a lot :) It does resolve the issue! :D The problem now is that it still crash because I need the iOS 8 way of handling Game Center (it crash at let localPlayer = GKLocalPlayer)... I believe this means that I need to check 'if #available(iOS 9, *)' and code separately. Now it makes me wonder it is worthwhile to support iOS 8 at the same time... – LFS Aug 04 '15 at 14:33
  • Perhaps something similar to: `NSString *iOSVersionrequired = @"4.1", *iOSVersion = [[UIDevice currentDevice] systemVersion]; bool osVersionSupported = ([iOSVersion compare:iOSVersionrequired options:NSNumericSearch] != NSOrderedAscending);` If a runtime check is better. Would you please accept the answer above if it's all good? – jdtec Aug 04 '15 at 15:04
  • Sorry... I have an runtime error at let localPlayer = GKLocalPlayer() The error is: Thread 1: EXC_BAD_ACCESS(Code = 1, address = 0x20) P.S.: I have no errors with iOS 9 but with iOS 8.4. By the way, I've import GameCenter. Do you happen to know what is happening? – LFS Aug 04 '15 at 15:13
  • Sorry @LFS I haven't actually got that far myself, I only needed to get my projects building for the time being. I'd recommend creating a separate question to attract answers for that specific issue. – jdtec Aug 04 '15 at 15:25
  • Could you more clearly elaborate on the reasoning as to what is going on here? Has GameCenter replaced GameKit binaries? – Joey Carson Aug 06 '15 at 21:21
1

For me, it worked well on iOS 8.4 and iOS 9 with these modifications to the above suggestions:

  • Don't change your code, just stick with #import < GameKit/GameKit.h >
  • When building with XCode 7, add GameCenter.framework (weak link / optional) and don't change this option for the GameKit.framework (required)

That's it.

If XCode7 gives you a linker error about GameKit.Framework, go back to XCode 6.4 and rebuild the project (disable the target membership of GameCenter.framework in the file inspector before). Then go back to XCode 7 - the linker error is gone.

Tommy356
  • 252
  • 2
  • 7
  • Sorry, do you mean that you totally do not change the codes from Swift/Objective-C to Swift2? – LFS Aug 05 '15 at 08:40
  • I won't be able to rebuild the project in Xcode 6.4 because I've converted all of them to Swift 2.0... I think there is a bug with the new Game Center? – LFS Aug 05 '15 at 08:49
  • No worries :) Wine's better when it's old yeah? – LFS Aug 06 '15 at 03:51
  • This solved the problem for me (Xcode 7 Beta 4) with an objective c app. I did not have to go back to Xcode 6.4. – vegashacker Aug 08 '15 at 16:06
0

Looks like the issue is gone in XCode Beta 5. Somebody to confirm this?

Tommy356
  • 252
  • 2
  • 7
  • Hi sorry, I was away for the last few days for my country's jubilee weekend and had not been coding. Yes, it has been resolved with Xcode 7 beta 5. There is no need to make the changes shared in this thread :) – LFS Aug 11 '15 at 09:25