Import my custom module/framework Xcode Swift - ios

I want to import my custom module/framework in my Swift project on Xcode 7. I understand how to normally do it. But I don't want to keep dragging and dropping my framework and linking it every time I make a new project. I was thinking I could move the framework to folders in the iPhoneOS.sdk/../Frameworks folder and/or the iPhoneSimulator.sdk/../Frameworks folder. Without dragging or dropping my custom framework into the project, I can import module (with autocomplete). However I get an error "Could not build Objective-C module 'Tumblr'". Is there a Setting in Build Settings I am missing.
**The Tumblr module is a module I created.
I have also created a .tbd and module.map files for the framework existing in the iPhoneOS.sdk

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.

Related

Error when Trying to import external framework to Xcode 9

I´m working on an app that integrates MySpin system from bosch, and there is a framework available to be used in the process.
I did all the importing process of the framework into my Xcode 9 project with a drag and drop into the frameworks project folder and linked to the target app.
But I´m not able to use the header file from the framework in my project.
I tried to import in some different ways, changing the options : Copy items if needed, Create Groups e Create folder references but the file dos not appear in the auto complete of importing process inside the AppDelegate.h, the error File not found always appears.
also included the folder path to the Header Search Path option.
Does anyone had any ideia on how to solve this importing problem? I have all files inside a local folder.
Check copy items if needed and add it to Embedded libraries , dynamic frameworks sections as below

No such module 'SwiftCharts' Xcode Swift 4

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.

Swift3 Framework Module is empty

Framework Project: https://github.com/twodayslate/SwiftGMP
I built this this project and dragged the SwiftGMP.framework into my iOS application. I can import SwiftGMP just fine but I cannot use any of the functions or structs even though they are set to public in the framework. What am I missing? I'm hoping it is just a flag or build setting. The SwiftGMP-Swift.h is being generated.
edit:// I got it working by dragging project into my application and then settings the library path in my main project. Doesn't seem right but it works.
Take a look at the settings of this project which uses SwiftGMP without adding it as a separate sub-project.

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).

Trouble Creating Cross Project Reference for Xcode 4

I'm trying to pick up some better code organization practices. Over time, I've developed a collection of utility-type files that I import into all of my iOS projects. Rather than continuing to copy them in, I want to setup a separate "Library" project which builds these files to a static library. Then, I reference the static library in my app's project.
In Xcode 4.2 I created a new project "JTLibrary" with a static library as the target, added some files, and it builds as expected.
Now, I created a new project "LibraryTest" which should behave like any other app project I might be working on. My understanding was that I should be able to drag the JTLibrary project into this project to create a cross project reference. Once that was done, I would link LibraryTest's binary against the static library from JTLibrary.
However, when I drag the JTLibary project into the LibraryTest project, it does not appear expandable. I expected I should be able to see the files in it, etc. See screenshot below:
Can anyone offer some insight to why the project appears like this rather than expandable? Once it is expandable, I should be able to see the static library in the app's project.
Thanks!
EDIT 11/7
It's worth mentioning that I'm working with a VERY basic project now. From the new project window, select Framework & Library >> Cocoa Touch Static Library. Add one function to the default class and build.
I can copy the header and .a files into another project and use them successfully, but if I try to drag the project itself, it appears like the picture above.
To create a subproject simply drag a project node from Finder into Xcode.
DO NOT open two Xcode instances and drag the project node from one to the other (that's why the subproject is not expandable).

Resources