I'm building a library. And I want it to compile and contain another one (which is googleConversion) but I need to do it with xcconfig files (because for some build I want to not include the library for example)
Following: Link binary with static library in xcconfig
So what I did was add in my xcconfig file:
LIBRARY_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/../Vendors/Analytics/GoogleConversion/GoogleConversionTrackingSDK-iOS-3.2.0
OTHER_LDFLAGS =$(inherited) -ObjC -L$(PROJECT_DIR)/../Vendors/Analytics/GoogleConversion/GoogleConversionTrackingSDK-iOS-3.2.0 -lGoogleConversionTracking
which let me compile without warning, but don't include the library in my .a
the only way I managed to do it is adding the library in the build phase in Link Binary With Library.
But it's not something I can do if I want to be able to automate my different type of builds
It sounds like it should be very simple ;(
Maybe some other configuration is preventing those lines to work?
I tried checking my logs and I can see in my "check dependencies" in Libtool export path I can see the resolved path of my OTHER_LDFLAGS (which disapear when I remove it from my xcconfig) but not the -lGoogleConversionTracking which exist when I put my lib in the build phase.
(I have more things happening, like nothing in libtool if I completly remove the panel from the build phases, but it could make sense in a way and it's not a big deal)
Thank you in advance!
Finaly got it!!!!
It because of an old xcode bug that was solved in xcode 6.
https://tarunsharmaios.wordpress.com/2014/09/12/xcode6-static-library-linking-broken/
BlockquoteXcode will no longer pass options in the build setting OTHER_LDFLAGS to libtool when building static libraries, nor will it pass options in OTHER_LIBTOOLFLAGS to the Mach-O linker when building any other kind of product. Previously all options in both settings would be passed to both tools. Make sure that options are in the correct build setting for the product type, static library, or other component being built. (4285249)
In my case it looks like:
LIBRARY_SEARCH_PATHS = $(inherited) "${SRCROOT}/thirdparties/CardIO-5.1.0"
OTHER_LDFLAGS = $(inherited) -ObjC -lz -lc++ -lCardIO
But my libs placed inside source folder in a same level with the *.xcodeproj-file.
I think that paths with "\..\" won't work for xcode.
This issue can be resolved with a script phase in your scheme.
Open your scheme via Product->Scheme->Manage Schemes.
Add the New run script action in the Build->Pre-actions
Script should copy file libGoogleConversionTracking.a to the ${SRCROOT}
Set new path for a LIBRARY_SEARCH_PATHS in *.xcconfig file
Related
I'm working on an iOS App and a Watchkit App.
I read a few things regarding best practices and I decided to create a custom framework, as NathashaTheRobot advise here:
https://realm.io/news/architecting-app-apple-watch-natashatherobot/
So I'm trying to use Realm in my framework.
I followed the installation instructions for Carthage:
Add github "realm/realm-cocoa" to your Cartfile.
Run carthage update.
Drag RealmSwift.framework and Realm.framework from the
Carthage/Build/iOS/ directory to the “Linked Frameworks and
Libraries” section of your Xcode project’s “General” settings.
On your application targets’ “Build Phases” settings tab, click the
“+” icon and choose “New Run Script Phase”. Create a Run Script with
the following contents:
/usr/local/bin/carthage copy-frameworks
and add the paths to the frameworks you want to use under “Input
Files”, e.g.:
$(SRCROOT)/Carthage/Build/iOS/Realm.framework
$(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework
Then I added my framework to the Target Membership of both Realm.framework and RealmSwift.framework.
But when I try to build the project, I get this error:
ld: framework not found Realm for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Then I gave a shot to lipo:
$ lipo -info Carthage/Build/iOS/Realm.framework/Realm
Architectures in the fat file: Carthage/Build/iOS/Realm.framework/Realm are: i386 x86_64 armv7 arm64
Do you have any ideas of what I might be doing wrong here? Thank you.
EDIT:
OK so I found the problem and it was totally unrelated to Realm...
It looks like I deleted the Headers and Resources sections of my framework Build Phases somehow (which were and are still empty). I just put them back and everything compiles/works like it should.
Don't be tempted to delete those two
Is it possible that it's your test target that can't find the frameworks? You'll have to add the parent location of the frameworks to the "Frameworks Search Path" section of your unit tests (likely $(SRCROOT)/Carthage/Build/iOS).
Here's a sample project of a Swift framework bundling RealmSwift as a dependency which you might find useful to compare your build settings against: https://static.realm.io/debug/ParentFramework.tgz
Unity 4.6.5 project won't run on iOS simulator and I'm getting runtime error:
dyld: Symbol not found: _OBJC_CLASS_$_CBAnalytics
Referenced from: /Users/diverseconnection/Library/Developer/CoreSimulator/Devices/983BAC55-2713-423B-B5F3-C135ECCC2768/data/Containers/Bundle/Application/D4CAC0C7-E3D6-48F5-B264-E6EB715F9709/trouble.app/trouble
Expected in: flat namespace
in /Users/diverseconnection/Library/Developer/CoreSimulator/Devices/983BAC55-2713-423B-B5F3-C135ECCC2768/data/Containers/Bundle/Application/D4CAC0C7-E3D6-48F5-B264-E6EB715F9709/trouble.app/trouble
(lldb)
Any ideas how to fix it?
Well this error is usually rather broad as there can be number of causes. You can try these fixes
Add the correct libraries in the Link Binary With Libraries section of the Build Phases.
If you want to add a library outside of the default search path you can include the path in the Library Search Paths value in the Build Settings and add -l{library_name_without_lib_and_suffix} (eg. for libz.a use -lz) to the Other Linker Flags section of Build Settings.
You copy files into your project but forgot to check the target to add the files to. To resolve:
Open the Build Phases for the correct target, expand Compile Sources and add the missing .m files.
You include a static library that is built for another architecture like i386, the simulator on your host machine. To resolve:
If you have multiple library files from your libraries vendor to include in the project you need to include the one for the simulator (i386) and the one for the device (armv7 for example).
Optionally, you could create a fat static library that contains both architectures.
Also try this
Remove Build Active Architecture Only (build setting parameter key is 'ONLY_ACTIVE_ARCH') from all of your static libraries' project build settings or overwrite it with 'NO'
I know there are lot of questions and answers are available like this but since 2 days I tried to figure out this issue and not got any success.
I have added the below listed frameworks in my projects,
libSqlite3.dylib
AddressBook.framework
AssetsLibrary.framework
AVFoundation.framework
CoreMotion.framework
MediaPlayer.framework
but not getting any success
I think you've copied the Frameworks into your project, rather than just linking to them, so they only contain the library compiled for device. Xcode will normally locate the Simulator version of the framework for you.
Delete any of the .framework folders in your project and Finder, then follow Step 6 of this tutorial with the frameworks you listed in your original post: http://quickblox.com/developers/IOS-how-to-connect-Quickblox-framework#Framework
This library AssetsLibrary.framework in Step 3, is not included in your project, that's why you are getting this error.
Try these:
You need to add the AssetsLibrary framework to the “Link Binary With Libraries” build phase of your target.
Try cleaning your project using Command+Shift+K and adding the required frameworks again. Hope it will start working
Copy files into your project but forgot to check the target to add the files to. To resolve: Open the Build Phases for the correct target, expand Compile Sources and add the missing .m files.
Another cause, may be:
You include a static library that is built for another architecture like i386, the simulator on your host machine. To resolve:
If you have multiple library files from your libraries vendor to include in the project you need to include the one for the simulator (i386) and the one for the device (armv7 for example).
Missing library or missing .m file
Check and add:
TargetSettings -> Build Phases -> Compile Sources -> add your .m class -> Build and Run
I'm trying to incorporate OmniGroup's frameworks into a project. I'm very new to building with these kinds of dependcies so I've been fumbling my way through this. What I've done so far it.
Created new Xcode project for iOS (iPad) using the Single View Application template.
Edited the Schema and unchecked Parallelize Build and Find Implicit Dependencies.
Added the 'Configurations' directory from the OmniGroup repository to my project.
Created a lib directory in my project's repository.
Copied the OmniBase directory to my lib directory.
Created an Omni Frameworks group in Xcode.
Dragged the lib/OmniBase/OmniBase.xcodeproj file to the Omni Frameworks group.
In my project's Build Phases tab I added 'libOmniBase.a' in the Link Binary With Libraries section.
⌘B to build
Yes, I know OmniBase is useless by itself. I'm just trying to build the minimum amount first and add on from there. But I can't get OmniBase to build. I get one error...
Ld /Users/mluton/Library/Developer/Xcode/DerivedData/CoreTextWithOmni2-dzbwnmvzfbuyhzadnmwrvmfmzyoa/Build/Products/Debug-iphoneos/CoreTextWithOmni2.app/CoreTextWithOmni2 normal armv7
cd /Users/mluton/dev/ios-recipes/CoreTextWithOmni2
setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/Users/mluton/Library/Developer/Xcode/DerivedData/CoreTextWithOmni2-dzbwnmvzfbuyhzadnmwrvmfmzyoa/Build/Products/Debug-iphoneos -F/Users/mluton/Library/Developer/Xcode/DerivedData/CoreTextWithOmni2-dzbwnmvzfbuyhzadnmwrvmfmzyoa/Build/Products/Debug-iphoneos -filelist /Users/mluton/Library/Developer/Xcode/DerivedData/CoreTextWithOmni2-dzbwnmvzfbuyhzadnmwrvmfmzyoa/Build/Intermediates/CoreTextWithOmni2.build/Debug-iphoneos/CoreTextWithOmni2.build/Objects-normal/armv7/CoreTextWithOmni2.LinkFileList -dead_strip -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.1 /Users/mluton/Library/Developer/Xcode/DerivedData/CoreTextWithOmni2-dzbwnmvzfbuyhzadnmwrvmfmzyoa/Build/Products/Debug-iphoneos/OmniBase/OmniBase -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/mluton/Library/Developer/Xcode/DerivedData/CoreTextWithOmni2-dzbwnmvzfbuyhzadnmwrvmfmzyoa/Build/Products/Debug-iphoneos/CoreTextWithOmni2.app/CoreTextWithOmni2
clang: error: no such file or directory: '/Users/mluton/Library/Developer/Xcode/DerivedData/CoreTextWithOmni2-dzbwnmvzfbuyhzadnmwrvmfmzyoa/Build/Products/Debug-iphoneos/OmniBase/OmniBase'
I've tried comparing my project to the TextEdit example workspace but I haven't run across any solutions yet. I know there's probably some step or setting I'm missing. Hopefully, this is obvious to someone reading this.
After examining this some more I finally got it to build. Here's the additional steps involved.
Copied the Script directory from the OmniGroup repository to my project.
Added a Build Phase. Run shell script Scripts/CopyLibraryResources. Ordered my Build Phases the same as in the TextEdit example. Target Dependencies, Compile Sources, Link Binary with Libraries, Copy Bundle Resources and Copy Library Resources which is the shell script build phase I added in the previous step.
Converted my project to a workspace.
Add my original project and the FixStringsFile project to the workspace.
Edit the scheme. Under build add FixStringsFile as a dependency. Made sure it was at the top of the list. Add any other library (in this case OmniBaseTouch) as a build dependency as well. Place them after FixStringsFile and Before the application target.
⌘B to build. No Issues!
PS: In both projects I edited Configurations/Target-Mac-Common.xcconfig and commented out OMNI_MAC_CODE_SIGN_IDENTITY = Mac Developer: since I'm not in the Mac Developer program.
I get a 'Lexical/Preprocessor Issue "*.h" not found' error when I build for release.
But it builds perfect fine if I set the build configuration to Debug.
I have this static library project in the same workspace, so I am assuming it builds every time I build my project just like CocoaPods.
When I look in the build folder, the .a file is not copied over. But it is there for the debug config. Maybe it is trying to call a header before the static library is built.
I have looked all over stack overflow and I feel like I have tried everything. This is not a duplicate.
I have -ObjC in other linker flags.
I have checked the Prefix Header
Update: The User Header Search Path is "$(BUILT_PRODUCTS_DIR)" both debug and release
Thanks for your help.
For your project target Build Settings, look for "Search Paths->Header Search Path". Compare your Release and Debug settings here.
Also look into the "Build Location" for the library project for Release and Debug.