7

I created my own iOS framework by following this tutorial, https://code.google.com/p/ios-static-framework/, which uses a static library template and aggregate target with a custom run script to create a framework.

At first it works fine. After including another library in the framework project creates the error when archive or build for device. I think the problem is with some wrong settings for that library. But I just don't know what to try. I have tried setting some sensible Other Linker Flags from https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ld.1.html , but no luck. Can anyone help please ;(

What steps will reproduce the problem?

  1. Follow the tutorial, but change the Aggregate script architecture from armv6 armv7 to armv7 armv7s. Here is the part of the aggregate target script I changed. Everything else is the same.

    if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
    then
    SF_OTHER_PLATFORM=iphonesimulator
    SF_ARCHS=i386
    else
    SF_OTHER_PLATFORM=iphoneos
    SF_ARCHS="armv7 armv7s"
    fi
    
  2. Add an external library to the project, here I use libBlocksKit.a.

  3. Build the framework, success.
  4. In another child project. Include my built framework.
  5. Add -ObjC in the app Target > Build Settings > Other Linker Flags
  6. Archive and get error. Building for device (iPhone5) gives error too. But building for simulator seems to work.

What is the error?

This error, basically "ld: warning: directory not found for option ... ld: lto: could not merge in ... symbol multiply defined!".

ld: warning: directory not found for option '-L/Users/hlung/Dropbox/- Notes/stackoverflow/RealFrameworkApp/RealFrameworkApp/External/BlocksKit'
ld: lto: could not merge in /Users/hlung/Library/Developer/Xcode/DerivedData/RealFrameworkTest-evagqzwzyyolhjenkkjbvzibxppf/Build/Products/Debug-iphonesimulator/RealFrameworkTest.framework/RealFrameworkTest(NSObject+BlockObservation.o) because 'Linking globals named 'OBJC_CLASS_$_BKObserver': symbol multiply defined!', using libLTO version 'LLVM version 3.2svn, from Apple Clang 4.2 (build 425.0.28)' for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I archive my child project with only one architecture (like armv7), it works. It shows this error with armv7 armv7s architectures ( $(ARCHS_STANDARD_32_BIT) ).

What version of the product are you using? On what operating system?

OS X 10.8.5, XCode 4.6.3

== Update 1 ==

  • Posted an issue at the tutorial's code.google.com page Update: 2 weeks no answer.
  • I found a set of useful suggestions from this answer. Update: Doesn't work
  • I have created a project so you can run and see for yourself here
Community
  • 1
  • 1
Hlung
  • 13,850
  • 6
  • 71
  • 90
  • does the dir '/Users/hlung/Dropbox/- Notes/stackoverflow/RealFrameworkApp/RealFrameworkApp/External/BlocksKit' exist, is that here the library is? what are the permissions? are you the user hlung, otherwise you will likely have a permissions issue. are you building all of the arch's in your library that you are using in your final target? have you turned off "build current arch only" for release? – Grady Player Sep 28 '13 at 20:43
  • I've checked all that. – Hlung Sep 29 '13 at 17:45

2 Answers2

1

Linking against a static library from within a framework can create some interesting challenges... It sounds like you may be linking to BlocksKit from both your framework and your application projects.

You should link in only one of those places. Try removing libBlocksKit.a from the Link Libraries build phase of your framework, but leave it in the other project.

Ben Mosher
  • 13,251
  • 7
  • 69
  • 80
  • Sorry, seems like I can't do that because libBlocksKit.a is visible only in Framework, but not in the other project. So it's already only linked at one place, in my Framework project. – Hlung Sep 30 '13 at 08:56
0

You can do like this:

  1. Click on your project (targets)
  2. Click on Build Settings
  3. Under Library Search Paths, delete the paths

I hope it can help you.

Thirumalai murugan
  • 5,698
  • 8
  • 32
  • 54
MackC
  • 352
  • 3
  • 17