Xcode Framework Search Path - ios

I have an Xcode project set up with multiple frameworks. The file structure is as follows:
Project
|
-workspace
|
-framework_1
|
- framework_1.xcodeproj
|
-framework_2
|
- framework_2.xcodeproj
framework_1 depends on framework_2. How do I set up the framework search paths in framework_1 to correctly see framework_2?

Not exactly sure what you are trying to do but I drag each project into the workspace and they find each other just fine.

Related

Use CMake's find_library to add an iOS Framework from a custom location

I'm trying to add an iOS framework called WebPDecoder.framework using CMake. I found that the right way to do this would be:
find_library(IOS_WEBP NAMES WebPDecoder PATHS "${PROJECT_SOURCE_DIR}/lib/ios" NO_DEFAULT_PATH)
The framework folder is in the lib/ios folder, but CMake can't find it. Adding --debug-find I'm getting the following output:
find_library called with the following settings:
VAR: IOS_WEBP
NAMES: "WebPDecoder"
Documentation: Path to a library.
Framework
Only Search Frameworks: 0
Search Frameworks Last: 0
Search Frameworks First: 1
AppBundle
Only Search AppBundle: 0
Search AppBundle Last: 0
Search AppBundle First: 1
NO_DEFAULT_PATH Enabled
find_library considered the following locations:
The item was not found.
Why is CMake ignoring my custom path?
I had the same problem. It turned out that a copypasted CMake setup for iOS was setting CMAKE_FIND_ROOT_PATH_MODE_LIBRARY to ALWAYS. To allow CMake to find the custom path under project source directory, the setting must be BOTH or NEVER.

How to link my cocoapod with library?

My cocoapod library need to be linked with some lib, let's say "libFoo.a". How can i add headers to search path (Libs/foo/include) and library path to link (Libs/foo/lib)?
I've used:
s.ios.library = "Foo"
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/Libs/foo/include" }
but when linting i'm getting an error:
ld: library not found for -lFoo
Let's say here is my cocoapod structure:
L---Classes
| L---myClass.m
| L---... (other files)
L---Libs
L---foo
L---include
| L---libFoo.h
L---lib
L---libFoo.a
You might need to ensure the folder structure is retained, check out preserve_paths and also look at podspecs from other pods to see what they do.

Issues Linking ObjC Library using Xamarin

I've been working on binding my first ObjC library (SVGKit) for the past few days. I've got it all building and compiling but I'm unable to get it running when referenced by another project.
My code for the binding can be found here: https://github.com/jamesmundy/SVGKit.Xamarin
When run, the following error is displayed:
Could not create an native instance of the type
'SVGKitBindings.SVGKImageView': the native class hasn't been loaded.
It is possible to ignore this condition by setting
ObjCRuntime.Class.ThrowOnInitFailure to false.
I've checked the static library I'm using and it supports the following platforms:
Architectures in the fat file: libSVGKit-iOS.1.2.0.a are: armv7 i386
x86_64 arm64
I believe this is all I need.
My linker file is as follows:
[assembly: LinkWith ("libSVGKit-iOS.1.2.0.a", LinkTarget.ArmV7 |
LinkTarget.Simulator, SmartLink = true, ForceLoad = true)]
Do I have to configure the project that I'm using this binding in differently? Any help getting the native library to load is much appreciated.
Update 1: Thanks to a suggestion I tried editing the Linker file to support the same platforms as the static library, unfortunately it didn't solve the problem. The file is now as follows:
[assembly: LinkWith ("libSVGKit-iOS.1.2.0.a", LinkTarget.ArmV7 |
LinkTarget.Simulator | LinkTarget.Arm64 | LinkTarget.Simulator64,
SmartLink = true, ForceLoad = true)]
I also tried the code on all the emulators, but still had no luck unfortunately.
[assembly: LinkWith ("libSVGKit-iOS.1.2.0.a", LinkTarget.ArmV7 | LinkTarget.Simulator, SmartLink = true, ForceLoad = true)]
That might not be your (only) issue but it's not correct. Your LinkTarget should be matching the architecture supported by the static library. IOW you are missing Arm64 and Simulator64.
Also try to execute your application on different simulators (32 bits, like iPhone 4S, and 64bits like iPhone 5S) or devices (again 32 vs 64 bits). That will tell you if it's a general or architecture-specific issue (and you should update your question with those extra bits of information).
I was able to solve this problem after having identified a few issues with my code and the project.
The Linker.cs file was not actually building with the project. Although it was in the solution it wasn't being compiled and therefore the important information it contained to link the libraries together was missing.
SVGKit uses several framework. I was not referencing these in the linker file and there were some other linkerflags needed. When I had solved this issue the file looked like this:
[assembly: LinkWith ("libSVGKit-iOS.1.2.0.a", LinkTarget.ArmV7 |
LinkTarget.Simulator | LinkTarget.Arm64 | LinkTarget.Simulator64,
SmartLink = true, Frameworks="QuartzCore CoreText CoreGraphics
CoreImage UIKit", LinkerFlags="-lxml2 -ObjC", ForceLoad = true)]

Import issue - libraries should not have the same name

I am trying to build a library that currently has the following structure
lib
| src (contains some internal .dart files)
| | private_parts.dart
| strategies (contains sample strategies for applications)
| | scoring.dart
| | time.dart
| mylib.dart (the main library file to include)
My problem occurs when I try to write an application that uses the sample strategies. I get the error/warning The imported libraries 'scoring.dart' and 'time.dart' should not have the same name ''.
My main file looks something like this (placed in the web folder)
import 'package:mylib/mylib.dart';
import 'package:mylib/strategies/scoring.dart';
import 'package:mylib/strategies/time.dart';
main() {
game = new Engine(new StandardTime(), new StandardScoring());
}
How should I restructure the library to make it correct? What is best practice?
Your code doesn't show a library directive so I suppose more than one library has the library name 'NONE'.
Add a library directive at the top of your dart source file
library my_library.my_sublibrary; // <= this should differ for each library
In dart each source file is a library as long as you don't add
part of some_library
instead of the library directive. Adding no library or part of directive makes it implicitely a library without a name.

How to support different architectures on a podspec?

In my company we are using some 3rd party static library that comes with a "wrapper" class and I want to create a pod for it. We have two versions of the static library, for simulator and device. The folder with the files that I want to include in the pod looks like this:
Engine
|
|- libEngine.a
|
|- libEngine-Simulator.a
|
|- Engine.h
|
|- EngineWrapper.h
|
|- EngineWrapper.mm
|
|- SomeOtherFile.bin
Now, since:
The library only supports armv7
EngineWrapper.mm is not using ARC
there is a requirement to set CLANG_CXX_LIBRARY to libstdc++ and
SomeOtherFile.bin needs to be "seen" by Engine.h,
the related part of my podspec looks like that:
s.requires_arc = false
s.source_files = 'Classes/ios/Engine'
s.preserve_path = 'Classes/ios/Engine/SomeOtherFile.bin', 'Classes/ios/Engine/libEngine-Simulator.a', 'Classes/ios/Engine/libEngine.a'
s.vendored_libraries = 'Classes/ios/Engine/libEngine-Simulator.a', 'Classes/ios/Engine/libEngine.a'
s.xcconfig = { 'CLANG_CXX_LIBRARY' => 'libstdc++', 'VALID_ARCHS' => 'armv7' }
This is just one of the hundreds of combinations/different settings I tried. I can provide more examples if you want. However, no matter what I try, I get the following error when trying to build:
Undefined symbols for architecture armv7
I tried to go through all the settings in Pods.xcodeproj but I can't see something suspicious there (but at the same time I am not familiar with the way Cocoapods works in detail).
Among others, I tried to:
keep a flat folder hierarchy (instead of the Classes/ios/Engine path)
use libraries instead of vendored_libraries
remove one of the static libraries
create a fat binary instead of having the two ones
zip all the files together (in the same way TestFlight does it in their podspec)
remove the VALID_ARCHS setting
and I also saw several different podspec examples using static libraries, but without any luck..
I am using Cocoapods ver 0.32.1.
If you have any idea of what could be wrong, please let me know before I lose my sanity. Thanks!

Resources