简体   繁体   中英

Static library and cocoapods with Xcode 6.1.1 - ld: library not found Error

Not sure it is related to Xcode 6.1.1 or Cocoapods 0.35.0.

I have generated new static iOS library with Xcode 6.1.1.

SUCCESS (without cocoapods)

  1. Generate simulator and Device library
  2. Lipo to both and generate FAT MyLib.a static final lib
  3. Create new View Application project. (I haven't changed any default setting. eg Base SDK, Valid Architecture.)
  4. Add MyLib.a and necessary header files to application project manually.
  5. Build the app project and IT WORKS FINE !! NO ERROR NO WARNING.

ERROR

  1. Upload same MyLib.a & headers (generated above) to HTTP direct download server(kind of artifact server).
  2. Generate specs & podfile.
  3. Remove all dependency (lib and header) from app project which i have done manually earlier.
  4. Add pod file and local specs
  5. "Pod install" command pull out MyLib.a and header properly in /Pods folder.

But while building the app project gives me

   Ld Build/Products/Debug-iphonesimulator/LibTest.app/LibTest normal x86_64
    cd /Users/admin/Cocoapods/Project/Library/TestProject/LibTest
    export IPHONEOS_DEPLOYMENT_TARGET=8.1

 ld: library not found for -lMyLib
 clang: error: linker command failed with exit code 1 (use -v to see invocation)

When i fire "lipo" command on MyLib.a

Architectures in the fat file: /Users/admin/Cocoapods/Project/Library/Libs/Final/MyLib.a are: armv7 armv7s i386 x86_64 arm64

Its not really architecture issue otherwise it should get failed in my first attempt which doesn't have cocoapods. Cocoapods does some build configuration changes and that creates this issue.

Help me to resolve this issue.

After spending 2 days to figure out the exact issue, i found very silly fix. Its basically issue with static library naming convention issue. If you have static library in artifact/media http server and wanted to integrate with Cococapods, make sure library name should be lib(your name).a along with headers.

In my case i have kept MyLib and it got dowloaded currently while "pod install" but during app building it was failing. After renaming to libMyLib.a , every thing works for me. :)

Very easy to apply yet difficult to find such solution]

Not sure whether cocoapods has documented this in there any guide or not.

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