I've been in the process of refactoring some code and have created a static library that I'm now using in a framework that is used in a few apps. I'm using cocoapods and am having trouble properly integrating my new static library into the podspec.
I'm finding that builds are failing because the static library is missing from the build. If I manually add the static library to the final app, the framework and app work fine. A build team generates the final releases of the apps, and because of this I've only been responsible for update the podspec for the framework only.
Is it possible for me to modify the pod spec to set the static library as a linked library that shows up under build phases of the final app?
UPDATE:
When adding the static lib to the framework.library attribute of my sub spec I'm getting library not found for -lMyStaticLib
SUBSPEC FOR REFERENCE:
s.subspec 'MyStaticLibrary' do |msl|
mss.source_files = 'FrameworkSource/My-Static-Library/*.{h,a}'
msl.library = 'MyStaticLib'
msl.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(SRCROOT)/Pods/My-Framework-Name/FrameworkSource/My-Static-Library"/**', 'LIBRARY_SEARCH_PATHS' => '"$(SRCROOT)/Pods/My-Framework-Name/FrameworkSource/My-Static-Library"/**' }
#msl.frameworks = 'MyStaticLib'
end
UPDATE 2:
I changed the attribute to msl.vendored_libraries = 'MyStaticLib' Also validated paths in podspec. Everything 'seems' to check out. I'm still getting build errors.
When I built for a device (I get same error but for i386 when I build for simulator):
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_MyStaticLibrary", referenced from:
objc-class-ref in MyFramework(FileInFramework.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I also verified again that if I just go to the app's build phases and traverse the Pods folders and manually add the MyStaticLibrary.a file to the project it builds without issue.
Try renaming your MyStaticLib.a file to libMyStaticLib.a. I was also getting the library not found for -lMyStaticLib error and fixed it by adding a lib prefix to the filename.
You can definitely add the framework in your podspec. Check out the wiki entry on the Podspec format.
Edit: Ah, what you're looking for is vendored_frameworks or vendored_libraries which was added in 0.23.0. Looks like those haven't been added to the wiki yet. Will update that now!
For the error Library not found for -lxxxxxxx, if you static library name is MyStaticLib.a, try renaming to libMyStaticLib.a and put it in perserve_paths property so that your static library won't be removed after being downloaded:
msl.libraries = 'MyStaticLib'
msl.perserve_paths = 'libMyStaticLib.a'
Then, go to your project's build setting: to make sure you have the parameter -lMyStaticLib in 'Other Linker Flags'.
For the ARM and i386 architecture issues, ARM means iOS device, and i386 means simulator, better to make your static library universal, then it will work on both architectures.
change the:
msl.vendored_libraries = 'MyStaticLib'
to:
msl.vendored_libraries = 'FrameworkSource/My-Static-Library/libMyStaticLib.a'
and cocoapods will add a search path.
Related
I am working on building a Swift library and am hosting it on GitHub.
All was going fine until I added BluetoothKit to the project. I then got an Apple Mach-O Linker Error:
ld: warning: directory not found for option '-F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk/Developer/Library/Frameworks'
ld: /Users/calebklevetertest/Library/Developer/Xcode/DerivedData/Napalm-dblvhbjdwovurocsvzrzaxzkjjyw/Build/Products/Debug-iphonesimulator/Napalm.framework/Napalm compiled with older version of Swift language (2.0) than previous files (3.0) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
From reading the error it appears the issue somehow stems from the fact I am using Swift 3, but I can't figure out how to fix it.
I did convert BluetoothKit to Swift 3 when I added it.
There is one class that uses BluetoothKit and it is called NPFBluetooth.
A couple things to note are 1) Even though the class is public, the compiler gives an error of 'unresolved identifier', 2) The class does not show in the auto-complete and 3) All the other classes work fine.
I ran into the error migrating to swift3. As it turns out Xcode keeps copies of built frameworks and moving to swift3 is apparently not a cue to rebuild those (even after finding out it was built using swift2.... no let's throw a vague error instead...)
The solution is to delete the content of your 'derived data' folder.
Works for frameworks installed with Carthage and cocoapods.....
Go to your build settings and switch the target's settings to ENABLE_BITCODE = YES for now.
It's working for me ;)
After upgrading to Xcode 7.1 and fixing some issues with my cocoapods (I had pods in both the main target and the test target), I now have the following warnings.
ld: warning: directory not found for option
'-F/Users/john/development/OurLatitude/OurLatitude/Pods/GoogleMaps/Frameworks”'
ld: warning: Auto-Linking supplied
'/Users/john/development/OurLatitude/OurLatitude/Pods/GoogleMaps/Frameworks/GoogleMaps.framework/GoogleMaps',
framework linker option at
/Users/john/development/OurLatitude/OurLatitude/Pods/GoogleMaps/Frameworks/GoogleMaps.framework/GoogleMaps
is not a dylib
Originally I did only had the Auto-Linking
warning, but some how managed to pick up the directory not found warning
I have the following in my test target search path:
"$(PODS_ROOT)/GoogleMaps/Frameworks" $(inherited) $(PROJECT_DIR)/Pods/GoogleMaps/Frameworks”
If I delete this entry I get the following error:
ld: framework not found GoogleMaps for architecture i386
at one point I think this was complaining about armv7, I forget what I changed that affected that.
Including the path in my test target searchpath, is just a warning and everything , including the test seem to run, but I would like to get rid of the warning if possible.
Any ideas?
I tried what was suggested in this answer, but it only seemed to make matters worse.
I make a build for iPhone for the first time and got a problem.
I already checked a lot of posts and didnt find answer.
When i make a build on device a get:
Undefined symbols for architecture armv7:
"RegisterAllStrippedInternalCalls()", referenced from:
RegisterAllInternalCalls() in libiPhone-lib.a(MonoICallRegistration.o)
"RegisterAllClasses()", referenced from:
InitializeEngineNoGraphics() in libiPhone-lib.a(SaveAndLoadHelper.o)
"RegisterMonoModules()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
On simulator ok.
libiPhone-lib.a added to link libraries.
Can somebody tell what it is? Please
Your unity version is not compatible, just download the latest version of unity which I believe is 4.3.1 and try recompiling. Here is the link if you need it. http://unity3d.com/unity/download/download-mac
The new version is compatible with armv7.
ok if anyone else is experiencing the same problem here's a way out:
those 3 methods mentioned are declared in the RegisterMonoModules.cpp in the Libraries folder, usually. so take that cpp file and add it to your target's Build Phases > Compile Sources
then if you have additional SDK's integrated that are not added to the 'Compile Sources' the new build will throw some other errors. just make sure to add the wrapper .mm files from the sdk's to your Compile Sources. Usually one .mm file per sdk. (e.g. for unity facebook sdk it's FbUnityInterface.mm file)
hope this helps
I am too much of this Static Libary thing in Xcode 4.X
Following are the steps that I usually do..
1)For making a static libary , I open Xcode , new , static libary , and then by adding some classes in the project .. then build phases ->copy headers -> add all headers here one by one,and then i build up the project
when run on ios simulator -> static libary does not created ..(red color)
when run on ios device - > static library gets created..
2) for using the library..
I make a new Project , then i "add files to project" and also "copy if needed" the following 2 files..
.a file (i.e.static library)
folder consisting the headers of library files
Now when I try to import a header file in my project , there is no "suggestion" appear ...but still i write and it does not give an error "header file not found"...
but when I run the project it gives the error like:
ld: warning: ignoring file
/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a,
file was built for archive which is not the architecture being linked
(i386):
/Users/Subodh/Library/Developer/Xcode/DerivedData/LibraryImporting_test-cbchzzjdcehzvfgwmzbvifrnrwgk/Build/Products/Debug-iphoneos/libLibraryImporting_test.a
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_LibraryImporting_test", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Plz guide me....point out if get wrong at some step....help plz
it will be better if someone mentions all the steps as i have done in making a library and using it in a project...it will be a great help
The key to the issue is this part of the error message:
file was built for archive which is not the architecture being linked
(i386)
You have imported the library built for the iPhone Device (ARM) by the look of it, and you are trying to use it in the iPhone Simulator which is i386.
What I would recommend is using an Xcode Workspace where the static library project is one of the projects and the iPhone app is another project. This way Xcode will build the library, as required, for Debug/Release and Device/Simulator.
I created a command line application. Then I realized it would be handy to be able to use code in other projects, so I added a new target - a cocoa library.
It seems to compile and a .a file is generated.
Now in another project I want to use this library. So first I added the first project to this new project as a reference.
In build settings I set "Always search user paths" to YES, then keyed in the path to the above project in user header paths.
In build phases, "Link Binary with libraries" , I added the .a file.
Now in my new project code sense seems to work. But when I try to build, I get an error : ndefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RIImageSplitter", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What did I do wrong? :S I am a beginner.
Didn't add file to compile sources of target. =S
Check this:
Did you drag the static library to your project navigator?
Did you add in Target/Build Phases/ Target Dependencies?
Did you add the Header Search Path for the headers of the static library?
Good Luck!