We have multiple development machines, some running Xcode 3.2.5 and others running Xcode 4.2. We have a static library that is referenced by our project. It contains Objective C categories, so we need to use the -force_load flag with the path to the library.
The problem that we are having is that on Xcode 4.2, the library is linked from a different location than the path that we specified in -force_load. This causes duplicate symbol errors since it's trying to link two copies of the same library.
The path Xcode 4.2 links from is:
/Users/USERNAME/Library/Developer/Xcode/DerivedData/PROJECTNAME-ehxeazvigqrpvogkxlkcmdzpisdw/Build/Products/CONFIGURATION-PLATFORM/
whereas the location that Xcode 3.2.5 links from is:
PROJECT_ROOT_OF_STATIC_LIBRARY/build/CONFIGURATION-PLATFORM/
Is there a way to get Xcode 4.2 to use the same locations as Xcode 3.2.5 when linking static libraries so that we can use the force_load linker option? If not, can anyone suggest an alternative solution to get Xcode 3.2.5 and 4.2 to play nicely together?
It sounds to me like you are doing things the hard way.
I've never used -force_load to load static libraries. With the libraries I use, they are all stored as frameworks in a directory on my system which is separate from the project. I then use the XCode standard add frameworks dialogs to bring them into the project and "-ObjC -all_load" to ensure they work and categories are active.
I've successfully move a few projects from XCode 3 to 4 and not had the problem you are mentioning. I suspect that if you can stop using -force_load your problems will go away.
Related
I recently had to duplicate my own frameworks to be able to link them from the native watchOS 2 extension, because the platform is different. So for every framework X I have an X-watchos counterpart.
Everything works fine in the simulator and when building directly to my devices, and it wasn't until I tried to archive that I got this linking error:
I ran lipo -i on the built watchOS framework and sure enough, its archs are arm7 and arm64 instead of armv7k.
When I looked further into the built directory I noticed this:
Both versions are symlinks to the same file, and because the have the same product name, they're being overridden. I could make them have different names, but that would make importing them really cumbersome.
Note that this is not a problem for 3rd-party frameworks because Carthage is already building them in separate directories.
EDIT 08/22/2015: I've filed a radar with a sample project: http://www.openradar.me/22392501
EDIT 08/24/2015: This has been acknowledged in Xcode 7 Beta 6 release notes as a known issue:
EDIT 09/9/2015: Xcode 7.1 Beta release notes hint that this is fixed, but I haven't confirmed it yet.
This is working for me in Xcode 7.1.
I’m using a similar configuration with my own frameworks, but I set a different name when creating it in each platform (MyFramework and MyFramework-watchOS). Don't forget to set a common product name manually (mine is MyFramework on both) in the build settings tab of each framework.
My Xcode 7 beta3 project includes some framework compiled by Xcode 6, these frameworks are imported to my project by Embeded Frameworks option in "Build Phase" tab. Because these frameworks does not support bitcode, so the "Enable Bitcode" option turned to NO, when compile the project, Bitcode_strip error occurred:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip
/Users/panzhansheng/Desktop/MusicFans_2.0.4_xcode7_autoplay/MusicFans/Frameworks/FLAC.framework/FLAC
-r -o /Users/panzhansheng/Library/Developer/Xcode/DerivedData/MusicFans-bxutvotiungdbwfsxloykffnqoqs/Build/Products/Debug-iphoneos/MusicFans.app/FLAC.framework/FLAC
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip:
input file must be a linked Mach-O file not an archive:
/Users/panzhansheng/Desktop/MusicFans_2.0.4_xcode7_autoplay/MusicFans/Frameworks/FLAC.framework/FLAC
(for architecture i386) error: bitcode_strip
/Users/panzhansheng/Desktop/MusicFans_2.0.4_xcode7_autoplay/MusicFans/Frameworks/FLAC.framework/FLAC:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip
exited with 1
I found that the error happened when Xcode copy my frameworks to my App package and try to strip bitcode from the framework, but these frameworks were compiled by Xcode early version and did not include bitcode at all. How to fix this? Thanks!
As I found out, XCode uses bitcode-strip only when enviroment variable STRIP_BITCODE_FROM_COPIED_FILES is set to YES. It seems that it's set to YES by default when enable_bitcode is switched on.
Adding User-Defined Setting STRIP_BITCODE_FROM_COPIED_FILES=NO to your Target can help you, XCode will not use bitcode-strip, but your app which will use frameworks without bitcode section probably will not work. So it's better to recompile them also using STRIP_BITCODE_FROM_COPIED_FILES=NO if necessary.
Tested on XCode 7 beta 5
following up on M. Pogosskiy's answer, it took me awhile to track down where to put the STRIP_BITCODE_FROM_COPIED_FILES bit setting (not too familiar with these). for reference, here's an illustration:
It was due to low memory/ disk space available in Mac system. When I cleared it. It runs smooth without cleaning itself.
I'm having trouble linking an Xcode project using the AAF SDK, with Xcode 5.1.1 on MacOS 10.9.5. When I link the main dynamic library, these symbols come up missing:
_StgCreateDocfile
_StgCreateDocfileOnILockBytes
_StgOpenStorage
_StgOpenStorageOnILockBytes
AssertProc
I can't find a definition for them anywhere in the entire source tree for the SDK. The first four appear to be part of Structured Storage on Windows. A Structured Storage library is provided in the SDK and I'm already linking that.
Can anyone tell me of a Mac system library that defines these? Or is there a linker argument that pulls in a library for them? Thanks for any help.
A late answer (!), but in case anyone comes across this... The solution is either:
To use the makefiles with the AAF SDK to generate the AAF dylib,
which works fine. or...
If you use Xcode to build the AAF SDK, ensure the correct
#defines are kept, namely:
_DEBUG OM_DEBUG OM_STACK_TRACE_ON_ASSERT OM_USE_SCHEMASOFT_SS OM_STRUCTURED_STORAGE
Note that DEBUG=1 is absent (it is added by default by Xcode) - if defined, this brings in AssertProc. Define NDEBUG on release builds and omit the debug defines.
The Stg... functions are part of the MS implementation of Structured storage as you stated, but should not be referenced on a Mac, the Schemasoft implementation being used.
I am trying to build a library of code that can be built into a .framework for OS X as well as a shared library for iOS. I'm not sure this is possible, there seems to be some strange behavior on XCode 3.2.5's part.
I want one project that holds all my shared code. Keeping the #if and #else definitions out of the equation here, I'd like this code to be able to be built with the 10.6 SDK as well as the iOS 4.2 SDK. I'd like to have 2 separate targets in my project, one building the .framework, and the other building the shared library lib*.a. They would each only get to compile the code that is relevant to them, but this single project would hold all of it.
My first steps seemed ok - created a fresh new project for building .frameworks, then I added a target to build an iOS shared library. As soon as I flip back to the .framework target, I get an error trying to build:
"target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform"
I didn't change the "product type" in the framework target (not even sure how), but it now seems to think that it's supposed to build everything for iphonesimulator, and that product doesn't support frameworks (which indeed it doesn't).
Has anyone else gotten this to work? Is this possible with XCode 3.2.5? Will this be possible in XCode 4?
I'm in the process of porting some code from Linux to Mac OS X. The code is a static library that you add to your code. Basically after you compile the code you get a MyLib.a that can be linked to whatever project you want.
I'm managing the "project" via a Makefile.
Is there a way to have a project on Xcode that ultimately produces the same kind of library? How?
Thank you for the help.
Sure. You don't say so, but I am assuming you are using C or C++ as source.
Assuming you are using Xcode 3.2.2, you can create a new project (File > New Project...), which will bring up a New Project window with available project templates. Select the "Framework & Library" category under Mac OSX from the list on the left. You should now see a "BSD C Library" and "STL C++ Library" among the other library and framework types. For building a static library like you described you want the "BSD C Library" option. There are static and dynamic options for this which you will see when you click on the icon, but static is default.
Depending on which version of Xcode you are using, the location of the project template may be a little different since Apple has been changing this UI for the New Project window fairly frequently. So if you are not using 3.2.2 you may need to poke around the available projects a little bit.
Oh, and don't worry if you are trying to build C++. Event though this says it is for C, C++ libs build just fine as well.