No such module 'SwiftCharts' Xcode Swift 4 - ios

I have created an app in Xcode and Swift 4 that uses the external frameworks 'SwiftCharts'.
All works fine, however if I move the folder where the whole project and all its files are contained, I get the error message "No such module 'SwiftCharts'" appear after every "import SwiftCharts" in my project.
I need to submit my project as a university assignment but at the moment the only place the project will work is in my Documents folder on my laptop.

You can check the module by Right click the SwiftCharts and check by Show in Finder.
If it is not present in the folder, you need to copy it in the projects.

I would recommend you read about Embedding Private Frameworks in Your Application Bundle:
you normally specify the full path to the appropriate frameworks
directory. When you embed a framework inside a bundle, however, the
location of the framework is not fixed, so you have to use the
#executable_path placeholder to let the framework know its location is
relative to the current executable.
Open an inspector for your framework target and select the Build tab.
Set the value of the Installation Directory build setting to
#executable_path/../Frameworks.
From this link:
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html#//apple_ref/doc/uid/20002258-106880
Managing external references in any project is essential to understand.

Related

Not able to access public swift class through framework

I created a project and imported it inside this framework. When i load this framework into a demo app, i am able to access the public class MyTest inside MyTest.swift file but not able to access the public class inside MessagesViewController.swift. Am i missing something? Can't we access files inside a project through a framework this way?
Restructure your project space so that you do not have your application inside your framework, then tackle linking files between the app and the framework.
Create a xcworkspace file to contain all of your sub-projects. For more information check out the Xcode Workspace section in the Xcode Concepts document
Open the workspace file and add your framework and app projects by dragging the xcodeproj files to the "Project Navigation" panel. Be careful when adding the files as Xcode as a tendency to place one project inside another, you don't want this.
Build your framework and then link it to the the app project. This will also make all you framework files available to your app project as long as they are public(see below for more details). Navigate to the FireChat-Swift app project target in the editor view then from the frameworks project open the product directory and drag the framework file to the Embedded Binaries section of the general tab.
Now your framework is linked with your app project. You will need to import your framework in your app's source code.
Add new files to your framework and remember they need to be public should you require them to be used outside of the framework - i.e. by your app.
Did you add MessagesViewController.swift to the Target inside the original Project?
To check it just open the original project, select MessagesViewController.swift and take a look at the right sidebar (Target Membership section).
I had this problem, and I fixed mine by going to my framework and adding target membership to Tests and UITests:
Strange fix, but I guess it works! 🤷‍♂️
This can also occur as part of a bug in Xcode, though I'm not sure what causes it - possibly dragging files from another project into your library. I just fixed this by closing down and restarting Xcode, then cleaning the build folder (hold down Alt then select the option from the Product menu).

Proper way to add my own Framework to new Target in Xcode

I have developed my own framework. In the same Xcode project I have a target which is an iOS executable (app) that uses the framework.
What is the proper way to add and embed my framework in the target?
The only thing I have been able to get to work is when I provide paths to the temp build directory, you can see my lib is linked to build/Debug-iphoneos:
And I have to include the temp build directory in my Framework search paths, e.g.:
/XCode_Build/TDTPhotoLib-hiiogugjwmaajpcurftmlyveoies/Build/Products/Release-iphoneos
This just doesn't seem right the right way to set it up.

File missing error iOS Xcode

I have a sample project with multiple schemes.I am new to such a project.
I want to know How When and Where do we use such a flow(multiple projects in a single project).
See the image below,I am getting a file missing error while I try to build the project.But I don't know why I am getting such an error.The file that says is missing is already there in the project folder.
What am i doing wrong?I have added the three schemes by directly clicking +addfiles button to "my project " button at the bottom of the navigation pane.
the error is : "HTTPConnection.h file is missing."
Concerning your first question....
Sub-projects inside a project are useful if they build something (a library, usually) that your main project depends on. If the library is under development at the same time as the application, you may want to build it from source as a dependency rather than pre-building it and managing the installation of it as a binary file.
As for the missing file problem, including it in the project (or sub-project) doesn't automatically make it visible if it's not also in the source directory. In that case, it needs to be added to the project's header search paths.

finding the framework of a cocoa modules

I just followed a tutorial https://medium.com/#PyBaig/build-your-own-cocoa-touch-frameworks-in-swift-d4ea3d1f9ca3 for creating your own cocoa touch framework. There is one step where you need to right click a framework and it shows in finder, but it is not working for me. I can right click any other file and show in finder just fine. Any suggestions on how to find the framework file for dragging into another project?
well according to some apple doc I found:
Note: The standard locations for frameworks are the
/System/Library/Frameworks directory and the /Library/Frameworks
directory on the local system.
If it isn't in those directories, it is probably some custom path that would be specified on the CC line in the build output, and if you were really hard up, you could click the diff editor on the Xcode project and search for something.Framework, where something is the framework you are looking for.
... it is also possible that it is a framework that is build by a sub-project, and for whatever reason, it haven't been built yet.

Importing a third party framework into Xcode 6 – how do I save it to my project?

I'm trying to add the GPUImage library to my project, and I'm following the directions given on the GitHub page to use it with Swift.
I drop the .xcodeproj in, but it appears to just link to where it is in my ~/Downloads folder. How do I add it to my project itself? Where is the proper place to add a framework into a project? Am I even doing it correctly by dragging the xcodeproj into the main xcodeproj of my app?
The way I usually do this is to set up a directory for the framework at the same directory level as your application project (ex: ~/Development/GPUImage, ~/Development/YourProject). I prefer to have the code for the framework outside of the code for my projects for cleanliness of version control, but that's a matter of personal preference.
The instructions for the setup of the framework assume that you already have a set location for your GPUImage code in your filesystem (~/Downloads is probably not that place). Pulling in the .xcodeproj merely links to that location. You'll also need to know that location to set where the framework header search path is.

Resources