Unit test failing after adding framework to framework project - swift

I have a framework project that I've added a framework to. The existing project has a test target, since I've added a third party framework I now get the following error:
Library not loaded: #rpath/JWT.framework/JWT
I have tried adding the framework to the test target's build phases Link binary with libraries section with no success.

This error typically occurs when the app is unable to load a framework at runtime. One cause of this could be that the framework isn't embedded in the built app.
Aside from the Link Binary With Libraries build phase, you'll also need to ensure that the framework in question is added to the Embed Frameworks build phase in order to ensure it's bundled into the final app.

Related

UI Test target does not recognize Swift package from custom framework in xcworkspace

I am developing several projects in a single workspace (monorepo). The workspace contains a shared framework that contains code shared between the projects. Some of the code depends on external packages that I import using the Swift Package Manager. Everything is working except that the packages aren't recognized when I use the UI testing target. When I run the UI tests for one of the projects it complains that the packages cannot be found (in the framework). Another solution that suits my needs is also welcome. Anyway, I'm using Xcode 11.3. To reproduce:
Create a new workspace.
Add a new project A and a new framework B into the workspace.
Add any dependency (for example SDWebImage) to the framework.
Add a Swift-file to the framework that just does import SDWebImage.
Now add framework B as a dependency to project A.
If you build project A or unit test project A, there is no problem. However, when you run UI tests on project A it complains that it cannot find the module SDWebImage in the Swift-file you added in point 4 above. Any idea how to solve this?
Edit: When I use Cocoapods instead it gives me the same error. When I use use_frameworks! it doesn't give me the error, but it crashes with "SDWebImage: image not found".
You have to manually add your B framework as a linked library in on your UI Tests target under Build Phases -> Link Binary With Libraries

Link a binary framework to both Pod Target and main app project

I have a library project which was installed via Pod into my main project. That library project use a framework. I didn't or actually couldn't embed that framework in the library project cause of making Umbrella Project and this is not recommended by Apple.
So I tried to embed it in my main project but the library project in Pod couldn't see it so that lead to error "No such module"
So how I can link the framework which embedded in the main project to that library pod target.
Ok. I'm able to make it work. Just drag the folder on main project which contain the framework in your pod target project framework search path. It will automatically transform a path like this
"$(SRCROOT)/../"

Module created in a framework not found in a project in which framework is embedded

I am trying to create a swift framework containing both facebook and google SDKs for login, so that by implementing my framework, both of them may be used in a project without embedding them separately. I found out I can use pods for facebook SDK, but I have to add google SDK manually into my framework.
To reach classes in google SDK, I tried to add
#import <GoogleSignIn/GoogleSignIn.h>
into framework's umbrella header. However, when embedding my framework into project, it states that the file cannot be found.
I tried using the module approach instead. I created module.modulemap file defining GoogleSignIn module. I had no problem using the module in a framework.
However, when embedding my framework in a project, it states that module cannot be found. I even tried to import Google SDK into project itself and creating module in a project, but the error did not disappeared.
Could you please help me how to import google SDK into framework so that I can use my own framework in a project without any problems? Thank you in advance.
You can do this with an Objective-C bridging header.
First add an objective c file, then you will be prompted to create a bridging header. Click yes and then delete the other objective c file.
In this file place your import statement:
#import <GoogleSignIn/GoogleSignIn.h>
(This is assuming you have imported the SDK manually.)
Make sure you've imported your framework in Linked Frameworks and Libraries, embedded binaries and to Target Dependencies in the app's Build Phases setting. for this to work. In this solution, you can add the swift framework .xcodeproj file as a file of the main swift project.

Installing a package which depends on Entity Framework via NuGet

Okay, so I have an internal library for entities, and I have a web application which depends on the library.
So the dependency looks like this:
Web Application
Library
Entity Framework
The library is managed via an internal NuGet feed.
The problem I have is that every time I update the library within the web application, the install.ps1 script gets run for Entity Framework. This creates an EF folder (along with with Model1.tt, Model1.cs, Model1.Context.tt, Model1.Context.cs files) within the web application.
I don't want this obviously, so every time I update the library project, I have to delete files from the web application.
I feel there's something I'm missing here - how do I get to use Entity Framework as a dependency without it creating the EF folder every time I update the library project within the web application?

"Unknown type name" despite included framework

I'm trying (failing) to setup RestKit, which requires one Xcode project to be referenced inside of another. The RestKit framework file creates an NSRegularExpression and appropriately does a #import <Foundation/Foundation.h>. When I build, Xcode spits out "Unknown type name 'NSRegularExpression'".
I'm thinking there might be a circular reference to Core Foundation because I include it in my project and RestKit includes it in theirs? (Remember, the RestKit project is referenced inside of mine, as per their install instructions.)
Also worth noting: In my project build settings, I have the Header and Library search paths set to inside the RestKit/Build path, again, as per their instructions.
I assume you are building your project for iOS. If you included the RestKit.framework in your project, remove it. The .framework is meant to be used in Mac OS projects, add 'libRestKit.a' instead.
I realized I was making the build settings on the project instead of the target. Making sure I was changing paths and libraries on the target instead of the project alleviated all my woes!