I am working on a project with SwiftUI and it originally started with creating a new project as an "App" (Xcode, clicked on file, new, project, click on "App") but was then later asked to put it into a pod as a framework. I did it successfully (Xcode, clicked on file, new project, click on "Framework"), however I am unsure what the differences are and I'm unsure why I would want to do that. To me they look very similar, except that I'm unable to launch my project as a framework in the simulator. Luckily SwiftUI offers the canvas preview window however it is a bit finicky when it comes to certain button interactions, which is why I am wanting to use the simulator.
Two places of confusion:
What is the difference between an app and a framework project?
Why is it more advantageous to have my project as a framework?
An App is a standalone application that can be launched and run. For example, all of the apps that you have on your phone are just that -- apps. You tap on them and they launch and run, presenting a user interface, accepting input, etc.
A framework is something else entirely. It's a collection of code that is bundled together into a package that is used by another framework or by an app. Some frameworks are provided by the system -- for example, SwiftUI is a framework that it sounds like you're using in your app. Other frameworks are provided by 3rd parties. For example, you can find many frameworks via CocoaPods or the Swift Package Manager -- Alamofire is a common example. Also, you can make your own frameworks and use them in your own code as a form of organization and separation of responsibilities.
Why is it more advantageous to have my project as a framework?
It is not -- they are two almost completely different concepts (besides both ultimately being collections of code and resources). If you intend to build an app that is launch-able on someone's device, your only choice is to make an app. If you intend to make a collection of reusable code for use in your or someone else's app, than you would make a framework.
Excellent answer (and upvoted) by #jnpdx. Let me give you a physical example:
(1) Create a project in Xcode that is a framework. Call it "MyAppKit". Inside it create, well, basically anything - a View, UIView, or more likely a function that will be shared by several views. (Let's go with that.)
public func setLoginName(_ login:String) -> String {
return ""Hello, " + login + "!";
}
Pretty simple. Call it, pass in something, and it returns a string saying hello. Please note the public piece. It matters. (And there's much more there. This is a simple example.)
(2) Now we get to your app or apps. Let's say you have two apps that need to use this (again, very simple) code. One is SwiftUI, one is UIKit. (It doesn't matter except for syntax.) Sine my forte is UIKit I'll use that. (And it can be several dozen apps too.)
import MyAppKit
let myLoginMessage = setLoginName("World").
Pretty much, it's "Hello, World!'
Again, this is really a nonsensical example. But it should get you started on what the difference in Xcode is between a Framework project and an App project is.
Can anyone suggest me like:
I had done one project by using Objective-C. And I had an requirement to keep one button and If any user tap on that and it needs to open "https://github.com/Block-Equity/stellar-ios-wallet" (Swift) inside my app.
If user want to come back to Parent app from Sub-Project.. He can..
How can I keep 2 separate projects in One project and need to operate two projects while run-time?
I want to create an iOS app that contains Unity3D elements. I also want to control these elements, to change colors and set specific properties on them.
I want to do this controlling from UIKit elements, so that I can create my interface easily (using native elements such as UINavigationController).
Is there a way to integrate a Unity3D view as a subview in a native (or Xamarin) app?
I have found a way to take the exported build code from Unity and put it inside another project so that I can instantiate that UIWindow and display it when I need it, but I have not found a way to interact with it or use it as a subview in my view hierarchy.
Does anyone have some experience with this? Or a way to do this?
Edit: I have a structure in my mind: create a unity app, take the main window (or even the view that is contained inside it, if that does not mess with the contents), and then use the view in the view hierarchy as I like. I think I might be able to use the Native Plugin Interface to talk to my Unity view then.
Edit2: I found a video explaining the entire process I had in mind: https://vimeo.com/145572230
This interaction will require iOS plugin to be written for Unity. A bit tough job but definitely possible.
Have a look here should answer your questions.
https://docs.unity3d.com/Manual/PluginsForIOS.html
Define your extern method in the C# file as follows:
[DllImport ("__Internal")]
private static extern float FooPluginFunction();
Set the editor to the iOS build target
Add your native code source files to the generated Xcode project’s “Classes” folder (this folder is not overwritten when the project is updated, but don’t forget to backup your native code).
If you are using C++ (.cpp) or Objective-C++ (.mm) to implement the plugin you must ensure the functions are declared with C linkage to avoid name mangling issues.
extern "C" {
float FooPluginFunction();
}
to call Unity from native code
UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
Hope that helps
I have an existing iOS (Swift- and storyboard-based) app and I'd like to use cross-platform OpenFrameworks code in just one UIViewController. However, I notice that the demo OF projects take over the iOS application lifecycle up to the application delegate class and even contain a customised main.mm file. Has anyone managed to create a storyboards-based iOS project where use of OF is restricted to a single view controller?
I want to integrate two Xcode projects together and they both are full Xcode projects with UI and all. For example lets say i have an App 'A' which has a UIButton and on click it should open App 'B' which has its own UI.
I know we can open an App from another App through Custom URL schema but is there a way i can do this without custom URL schema and via connecting Xcode projects.
I know this a little vague question but i don't a better way to put this.
Thanks,
You're question doesn't make any sense. You're talking about two very different things. Yes, you may import one Xcode project into another Xcode project and setup a dependency between them. However, this in no way affects how the apps work with each other. If you're wanting to embed one app inside another, you have to do it at the view controller/code level. You cannot simply add one project to another and expect the two to intercommunicate. You'll have to move the functionality of one app to another. Apps are sandboxed on the device and can therefore have no communication with each other except for by using custom URL schemes as you've mentioned.