2

I'm following this tutorial in order to create an iOS framework (in order to support older than iOS8). It all went just fine.

The problem started when I made a step forward and tried to use 'Cocoapods' to get 3rd party libs which my framework is depended on.

When trying to build the aggregate target, I get the following error:

Libtool /Users/me/Library/Developer/Xcode/DerivedData/testFrameworkJverkoey-etqkesvvsfnndbdcydkphdythnve/Build/Products/Debug-iphoneos/libmyFramework.a normal armv7
    cd /Users/me/Dev/testFrameworkJverkoey
    export IPHONEOS_DEPLOYMENT_TARGET=8.1
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Tools:/Users/me/.rvm/gems/ruby-2.1.1/bin:/Users/me/.rvm/gems/ruby-2.1.1@global/bin:/Users/me/.rvm/rubies/ruby-2.1.1/bin:/Users/me/.rvm/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/Library/PostgreSQL/9.2/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/CrossPack-AVR/bin:/usr/bin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only armv7 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -L/Users/me/Library/Developer/Xcode/DerivedData/testFrameworkJverkoey-etqkesvvsfnndbdcydkphdythnve/Build/Products/Debug-iphoneos -filelist /Users/me/Library/Developer/Xcode/DerivedData/testFrameworkJverkoey-etqkesvvsfnndbdcydkphdythnve/Build/Intermediates/testFrameworkJverkoey.build/Debug-iphoneos/myFramework.build/Objects-normal/armv7/myFramework.LinkFileList -ObjC -ObjC -lPods-AFNetworking -lPods-RestKit -lPods-SOCKit -lPods-TransitionKit -framework CFNetwork -framework CoreData -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration -lPods -o /Users/me/Library/Developer/Xcode/DerivedData/testFrameworkJverkoey-etqkesvvsfnndbdcydkphdythnve/Build/Products/Debug-iphoneos/libmyFramework.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC -ObjC 
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-AFNetworking
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-AFNetworking is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-RestKit
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-RestKit is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-SOCKit
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-SOCKit is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-TransitionKit
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-TransitionKit is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods is not an object file (not allowed in a library)

** BUILD FAILED **


The following build commands failed:
    Libtool /Users/me/Library/Developer/Xcode/DerivedData/testFrameworkJverkoey-etqkesvvsfnndbdcydkphdythnve/Build/Products/Debug-iphoneos/libmyFramework.a normal armv7
(1 failure)
Rizon
  • 1,516
  • 4
  • 25
  • 45
  • Static lib cannot contain other static libs. – pronebird Nov 29 '14 at 10:58
  • Well I do manage to build the static lib target. The issues are with the aggregate target. – Rizon Nov 29 '14 at 11:12
  • Well because if you want to put together your pods (which are compiled as another static library) you have to use LIPO or such tools to actually merge both libs into one. But whatever libs you use in your framework will be also exported to the host app that included your framework. You'll get symbols clash if both app and framework use the same library (for example AFNetworking). – pronebird Nov 29 '14 at 13:06
  • When you build your static lib, it will reference all dependencies from Pods. Static lib does not require to contain all external symbols it use, but it will require those symbol to exist when you link it into the hosting app. – pronebird Nov 29 '14 at 13:08
  • And here comes CocoaPods which does this for you, it will make sure that all components properly linked and there is only one copy of each library even if let's say your framework and the app itself use the same AFNetworking, no clash in the end since AFNetworking will be compiled with all bunch of stuff into Pods.lib and linked directly to the app. – pronebird Nov 29 '14 at 13:11
  • So if you want to distribute your embedded framework to older iOS then I suggest you to include compiled lib and headers in your pod and list all dependencies you have in Podspec file. But certainly be aware that if you use AFNetworking 2.0 and host app uses AFNetworking 1.x then you get conflict again. – pronebird Nov 29 '14 at 13:21
  • @Andy, thanks a lot for your attention! I'll refer to what you suggested and maybe clarify what I want: 1) I wouldn't want to require my lib users to deal with my 3rd party dependencies. I know it will be at the risk of symbols clash and I'm ok with that. (I'd even prefer using a symbol prefixing technique if it comes to that, instead of revealing my 3rd party dependencies). – Rizon Nov 29 '14 at 13:43
  • 2) "Static lib does not require to contain all external symbols it use" Really? Would I be able to use AFNetworking code within my library without somehow linking AFNetworking to my project? *I don't think I got to the bottom of what you meant here – Rizon Nov 29 '14 at 13:44
  • 3) "I suggest you to include compiled lib and headers in your pod and list all dependencies you have in Podspec file". I don't want to ship my lib as a pod. I only need my lib to get its own dependencies using CocoaPods. – Rizon Nov 29 '14 at 13:46
  • Regarding #2 - You can compile static lib without external symbols physically being inside of your .LIB. Static lib is simply a compiled blob, but symbols resolution will happen at the point when this blob is compiled together with the app executable. For static lib to compile, headers are more than enough. – pronebird Nov 29 '14 at 13:51
  • Alright, so you should then use libtool to merge together your static.a and lib-Pods.a. http://stackoverflow.com/questions/8170450/combine-static-libraries – pronebird Nov 29 '14 at 13:54
  • You can run `nm mylib.a` to see all defined and undefined symbols inside. – pronebird Nov 29 '14 at 14:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65872/discussion-between-rizon-and-andy). – Rizon Nov 29 '14 at 14:14
  • @Andy can you please help here : http://stackoverflow.com/questions/40039378/how-to-access-a-third-party-framework-from-my-framework – jeet.chanchawat Oct 17 '16 at 06:59

0 Answers0