简体   繁体   中英

Cannot Archive when a library is included in my own iOS custom framework

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM