Swift without Xcode importing class
If you are on Linux, you can use the Swift Package Manager. It will allow you to import custom modules and to download external frameworks (aka dependencies). I believe however, you may need to build swift from source in order to use it.
The structure of your project will most likely need to change. SwiftPM is pretty strict about it.
With the typical setup of a package, you will need to have two sub folders within the Sources
directory, one forming a library and the other forming an executable. For example,
ExampleProject/
Package.swift
Sources/
MyLibrary/
components.swift
MyExecutable/
main.swift
This structure will allow you to import module MyLibrary
from the main.swift
file.
Note that the only difference here is a library doesn't contain a main.swift
file, while the executable does.
You will also need to make a manifest file - Package.swift
- with SwiftPM also requires for building packages. Here are some of their examples on how to build packages.
How to import module into xcode
When you clone or or download the socket io project you get a directory with multiple subdirectories. One of the subdirectories is named Source
. Simply drag that folder into Xcode (into the Project Navigator in the left sidebar).
You will then be presented with a screen like this:
Make sure the box for your app is ticked in the "Add to targets" list. This is what the instructions mean by "Make sure you add the files to your target(s)"
Import my custom module/framework Xcode Swift
Drag your module's x-code project into the left pane with all the files.
Then click on your main project file and go to general, scroll down to Embedded Binaries and add it through the menu there.
getting module not found after importing packages in swift
Author of EPUBKit here, thanks for taking interest in my library!
The issue is reproducible in a new project which kinda makes sense but don't at the same time. I am glad Xcode is not adding a package to every single target in my project but at the same time why does it assume that I want it in the iOS target? Anyway, I know that this question was already answered in the comment and the problem is solved but I might as well just drop more detailed instructions. Maybe it will help someone.
1. Select Project from Project Navigator
Select te target that is not working for you, in this case it's the macOS target. In the General tab you will see the Frameworks, Libraries, and Embedded Content section. If the package is missing from the list, tap the plus button at the bottom.
2. Add Missing Library
Look for the one you are missing, in this case its of course EPUBKit and tap the Add button.
3. Success
Now the library is successfully added to your target. Go ahead and build the project to run and enjoy your app :)
Can't use cocoa pod modules once installed into Xcode project
Please dont name your Project copied of the framework you installed. Or try Cmd
+ Shift
+ K
(Clean build), or just Build it first (Cmd
+ B
)
Related Topics
How to Draw Two Polylines in Different Colors in Mapkit
Realmswift + Multiple Predicate
How to Generate an Auth Token Using Jwt for Google Firebase
Convert to Latest Swift Syntax' Breaks the Build Even When There Are No Changes
How to Declare Protocol Property as Private
Swiftui 2 Pop to Root View with No Scene Delegate
How to Integrate Uisearchcontroller with Swiftui
Convert JSON Anyobject to Int64
How to Override Private Method and Call Super in Swift
How to Set Interactive Push Notifications on iOS8
@Objc Redundancy When Having @Objcmembers Private Dynamic Var
Swiftui MACos Commands (Menu Bar) and View
Swift 3:Appdelegate Does Not Conform to Protocol Gidsignindelegate
Nswindow with Round Corners in Swift
How to Retrieve All Contacts Using Cncontact.Predicateforcontacts