XCode Update - iOS Link Error

2019-09-17 15:30发布

问题:

I just converted my project up from Xcode 3 to 4 and updated to the latest SDK. The project runs fine when I open it in XCode 3, but there are errors when I run in XCode 4.

I am getting the following link error:

Undefined symbols for architecture armv7:
  "_objc_memmove_collectable", referenced from:
      __ZN9cPlaylistaSERKS_ in MediaItemManager.o
ld: symbol(s) not found for architecture armv7

From what I have read about memmove_collectable it has something to do with guards around garbage collected memory. However in my project settings are set to:

Obj-C Garbage Collection - Unsupported

I am not even sure there is garbage collection to be had in iOS. Anyone know what I might be doing wrong?

Some help demangling the name would be great too. My MediaItemManager is a C++ class, it does call new/delete and memset/memcpy. However none of them are in a function called Playlists. Here is evertying in MediaItemManager with the word Playlist in it. cPlaylist makes no calls to memset/memcpy functions.

cPlaylist* AllSongsPlaylist() { return mSongList; }
pPlaylistVec Playlists() { return &mPlaylists; }
cPlaylist* PlaylistByIndex(uint32 idx);
cPlaylist* PlaylistByName(NSString* name);

...

    std::vector<cPlaylist> mPlaylists;

    typedef std::vector<cPlaylist>*                   pPlaylistVec;

Edit: It seems to happen with armv7 or armv6. It may be an installation issue with XCode, I am not sure how XCode installation should look though. I did have to add this symbolic link to get XCode building after the install. iPhone Codesign object file format invalid or unsuitable

回答1:

So you are probably gonna hate this because it takes an hr or so but what I have had to do with these linker errors is completely uninstall xcode and then restart reinstall xcode and restart. Usually that is the issue because installing xcode 3 and then xcode 4 without uninstalling xcode 3 usually causes huge problem. So you are gonna have to go to terminal and cd to your developer folder and sudo /Library/uninstall-devtools --mode=all sorry man :( Hope this helps.



回答2:

I assume that your C++ code is in a library. Did you rebuild the library?

The error suggests that your library needs to be rebuilt, because it doesn't contain armv7 symbols, as the error suggests. In other words, it's not a universal library. You'll need to rebuild that library, OR, change your primary project to build for armv6 only.

It is worth noting that Xcode4 defaults to building for armv7 only. If you want to support iOS4 versions earlier than 4.2, you have to add armv6 to the supported architectures in your build settings. AND, you have to rebuild any dependent libraries accordingly.

Does that make any sense?