Multiple targets and library from bridging header issue - xcode

I've added Today extension to my Swift project, because of that I had to add it to targets for my Model class, which resulted in "Use of unresolved identifier..." when using libraries imported in ObjC bridging header. There's no issue for libraries written in Swift(imported directly in class). How can I solve this?

Related

Swift Embedded Framework That Depends on Swift Package

My iOS app follows the "Photos Extension" template:
- A standalone, "container" app
- A Photo Editing extension, which is deployed by embedding it within the app above.
As suggested by Apple, code that is shared by both the app and the extension is gathered in a "core" cocoa framework that is embedded in the app, and to which both the app and the extension are linked.
So my Xcode project contains three targets:
The Framework target,
The Photo Editing Extension target, which links to the Framework but does not embed it, and
The App target, that embeds the Extension binary and the Framework binary, and links to both.
So far, so good.
Furthermore, the framework, the app, and the extension depend on two libraries MyLibraryA and MyLibraryB I have on Github (and in turn, MyLibraryA depends on MyLibraryB).
I originally set the dependency on MyLibraryA and MyLibraryB using Carthage, and everything was working fine.
Then, I decided to migrate my libraries A and B to Swift Packages.
I removed all Carthage-related settings in project and targets, framework search paths, etc. to make sure the Swift Package versions of my libraries are referenced and not the cached Carthage builds. I also deleted the Carthage directories (checkouts and build).
The Problem
When I build the shared/embedded Framework target, there are no issues.
But when I try to build either the App or App Extension targets, I get an error pointing to the shared frameworks Swift header (MyFramewor-Swift.h):
// ...
#import CoreGraphics;
#import CoreImage;
#import Foundation;
#import PhotosUI;
#import UIKit;
#import MyLibraryA; <-- Module 'MyLibraryA' Not Found
// ...
And the resulting:
Could not build Objective-C module 'MyFramework'
I know frameworks that are distributed as binaries cannot depend on Swift packages, but this embedded framework is compiled locally from source code and then embedded.
Perhaps there are some changes I can make to my setup on Xcode to get it to work?
I tried changing Enable Modules (C and Objective-C) to No in the Build Settings for the Framework target, to no avail.
You can currently set Install Objective-C Compatibility Header to No in Build Settings for modules that require a Swift Package dependency.
This's probably due to "Swift Packages" being "Swift", but still looks like a bug to me.

Adding CommonCrypto to custom Swift framework

I’m building a Swift framework which seems relatively simple. Then I needed to import CommonCrypto.
In the framework’s .h file I added the line
#import <CommonCrypto/CommonCrypto.h>
and included Security.framework in Link Binary with Libraries for the framework’s target.
When I build I get the following build error:
Include of non-modular header inside framework module ‘MyKit'
I’ve tried changing the Allow Non-modular Includes In Framework Modules to YES and NO and tried every combination for both the framework target and the project with no luck.
The MyKit.h’s Target Membership is set to Public and is ticked for MyKit too.
In Xcode 10.0 you'll be able to import CommonCrypto. As a work around I suggest inverting that dependency with a protocol and importing CommonCrypto in your framework client.

Add dynamic library to firebreath

I'm developing a plugin for mac. I'm trying to use afnetworking and other frameworks which needs arc. I'm trying to create a .a(library) for the framework and access it in firebreath. I tried adding the directory which contains .a using include_directories in projectdef.cmake then linking it in target_link_libraries. Please lemme know how to add this and whether the framework can be used in firebreath without any pitfalls
I have used external libraries in firebreath. Though I have used editors to link the libraries. You need to specify .h files for the function prototypes, along with .a files which will dynamically link to .dylib
Try adding these via Xcode and see if that works.

Glympse API Linker Error for iOS

I am unable to compile the Glympse API for iOS due to 4 duplicate symbol errors in the framework. Like the example projects, I only import the GlympseLite.h header in my .pch file. Is anyone else having this issue?
One of the duplicate symbols is: __ZN7Glympse15ControlsFactory9showAboutERKNS_1OINS_12IGlympseLiteEEERKNS1_INS_8IGlympseEEE
How did you add GlympseKitLite into your project? Could you provide exact steps.
Which XCode version are you using?
Is there anything special about compiler/linker flags in your project?
Is it brand new or existing project?
Were you able to build sample projects provided with SDK?
I just confirmed that it compiles fine in a brand new projects. Here are the steps I followed:
Created new iOS project.
Dragged GlympseKitLite.embeddedframework (from SDK package) to Frameworks.
Added all required standard frameworks (CFNetwork, libz, CoreLocation, AddressBook, Security, EventKit, MapKit, MessageUI).
Added import entry to PCH file.
Called Glympse::LiteFactory::createGlympse(...);
In the mean time you can try the following. Set C Language Dialect, C++ Language Dialect and C++ Standard Library to Compiler Default. Let me know, if it helps.

Problem with static library in C++

I'm trying to use a static library created by me in Visual C++ 2005 (unmanaged C++). I declare one function "int myF(int a);" into a .h file, I implement it in a .cpp file, I compile it - the .lib file is produced.
I create a new project (a separate solution) in VC++ 2005 (also native C++), I add the paths for the include file and the lib file; when I invoke the function myF the linker reports an error: "error LNK2019: unresolved external symbol _myF referenced in function _main". if I create the client project in the same solution as the library project and then add a reference to the library projects, it works, but I'm not going to implement everything like this, but rather to add external libraries to my projects...
What is wrong?
Thank you.
You need to also include the actual .lib file in your 2nd project (not just the path to it).
There should be an option in the linker settings to do this.
It is not sufficient to list the folder in which MyStatic.lib can be found. You have to explicitly tell the linker that Dependant.vcproj is using MyStatic.lib.
In VS2005 you do this by project properties->Linker->Input->Additional Dependencies. You can also sprinkle some preprosessor stuff in the .h file to tell the compiler to tell the linker to use MyStatic.lib.
Edit:
The preprocessor magic goes like this
#pragma comment(lib, "MyStatic.lib")
(EDIT: This was a response to the question of getting the /NODEFAULTLIB error in link phase which has now been deleted... shrug)
You are mixing compiler settings if your are getting the defaultlib error. For example, if you build your library in debug and the build your main in release, you will get this error since they are built to use different versions of the CRTL. This can also happen if you use different settings for linking with the C Runtime as a object library or as a DLL. (See the C/C++ options, the "Code Generation" section, under the "Runtime Library" setting)
In many projects there isn't much you can do if you can't correct the settings of the library (for example, 3rd party libraries). In those cases you have to use the /NODEFAULTLIB switch which is a linker option in the "Input" section called "Ignore Specific Library".
But since you are in control of both the main and the library, build a debug and a release version of your LIB file or make sure your "C/C++;Code Generation;Runtime Library" settings match in both projects.
Try setting additional dependencies in the linker input for a project properties.

Resources