Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to make a port my Node.js command line application to Swift, and I don't want to use Xcode to do it (on Linux).
Does the Swift Package Manager have a specific package structure, and will I be able to use existing Xcode frameworks for my application?
Thanks!
hans
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.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Had a developer make a app for me. But he only sent me the src/ folder. Can I still use this to edit and build?
Not without some extra effort and guess work. Some considerations:
There is a resources directory which is typically a peer of src, which contains icons and splash screen assets used during the build process (if you had those icons).
The root of the project (one level up from src) has a good deal of important items
config.xml - contains formal app name & version (for app stores), contains critical native build info for cordova plugins, can contain "whitelist" setups, contains desired ios/android platform versions, can contain special build adjustments, etc.
package.json - contains the list of NPM packages (and versions) needed to make the app build and run, and can contain other build steps used during setup.
various other files, depending on the app (e.g. push notification setup files, unit testing setup files, etc.)
Besides the source files, it's also very helpful to know the version of the Cordova CLI and the Ionic CLI used to build the app. Often times getting different versions of these can cause mixed results when building.
This question already has answers here:
Is there a Prefix Header (or something with this functionality) in Swift?
(4 answers)
Closed 7 years ago.
I've started coding in Swift with a game project using SpirteKit
I want to import SpriteKit in a file like a .pch file, so all the other files in the project can use and no need to call
import SKSpriteKit
again. But Swift seems not support .pch file
Is there any alternative way to achieve it
I know I've answered this before, but digging out duplicates is cumbersome on mobile, so I'll just answer it again for now...
Unlike with (Obj)C (specifically, C before modules were introduced in Xcode 4), there is no cost to having the same import statement at the top of multiple files in a project. If there were a way to say "import SpriteKit for all files in my project", it wouldn't save on compilation time the way a pch file can for C.
On the other hand, even though you're typing the same import statement in each file, there's a benefit to that in terms of clarity. It lets you choose not to import the same modules in every file (which can be important for optimization and controlling which overloaded/generic functions get used), and it makes clear to readers of your code what its dependencies are. (Because it sucks to copy/paste code from some file and not know what modules you need to make it compile again in its new location.)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I need to create a .jar file out of few .so files using perl scripts
This is not generally possible.
A .so (shared object) is a library that can be loaded dynamically, like a .dll on Windows systems. These libraries contain natively compiled code, and may depend on other libraries in turn. A .jar is an archive for the Java Virtual Machine (JVM). It too can be loaded dynamically, but it contains .class files that contain code compiled for the JVM.
Which much hackery, you could perhaps translate a program in machine code to JVM byte code (or write an emulator e.g. for the x86 architecture), but it would be excessively difficult to do, as the execution model of a CPU and the JVM differ substantially, e.g. in their treatment of memory. The result would likely be highly inefficient. And re-compiling a dynamically loaded library would be rather unportable, thus defeating the purpose of the JVM.
If you simply want to interface with a native library from the JVM (e.g. a program written in Java), then you could use the Java Native Interface (JNI) instead. In that case, you'd have to write a C or C++ wrapper around the .so, and would then be able to call the functions.
I have no idea why you mentioned Perl. While a nice language, it cannot help here.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
We have an idea for an framework or library that will be very helpful for any iOS developer. So we're seriously thinking about switching from app development to framework/library development.
But when we want to charge for the library/framework, we must protect the code somehow. How can we build a framework in such a way that the user of our framework can't see the source code, similar to how we can't see the source code of Apples frameworks? They only ship the header files and some weird Unix exe file with the compiled framework, I guess.
Or if it is not possible to make an compiled framework / library that other iOS developers can use without being able to copy&paste our source code, then is there a way to obfuscate the objective-c code?
Yes, it is possible to build frameworks so the user of the framework can't see the source code.
Check out these articles (I've successfully used the first one to create frameworks in the past -- the later articles are updates to the original):
http://www.drobnik.com/touch/2010/04/making-your-own-iphone-frameworks/
http://www.drobnik.com/touch/2010/05/making-your-own-iphone-frameworks-in-xcode/
http://www.drobnik.com/touch/2010/10/embedding-binary-resources/
To use the framework, your users would just drag the .framework bundle into Xcode. They will be able to see the header files you copy into the bundle (see the articles above), but not the source (as it's not included -- only the compiled output is in the bundle).
This can also be a great way to distribute code that is used for multiple projects within your company.
Update:
Check out the link featherless added below -- it is much more recent and all on one page: http://github.com/jverkoey/iOS-Framework. It also lays out the issues with several other approaches. This is the guide I now follow when trying to remember what to do when setting up a new framework. :)
Update2 (with Xcode 6 release)
There is a option, exactly that you a re looking for:
Universal Framework for iOS!
Will be my code visible to others? A: No. This Framework will export a compiled binary, so anyone can see inside it. You can make the same for some other files, like XIBs.
Why I need this? A: This is for developers/teams that want to share their codes without shows the entire code (.m/.c/.cpp files). Besides this is for who want to organize compiled code + resources (images, videos, sounds, XIBs, plist, etc) into one single place. And this is also for that teams that want to work together above the same base (framework).
(c) http://blog.db-in.com/universal-framework-for-ios/
This guide is a bit more recent for creating iOS static frameworks:
https://github.com/jverkoey/iOS-Framework
There is also a template for XCode 4 that will let you create iOS static framework projects.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Hey Folks, I need to create a plug-in that updates an application.
Look, I have a host application, but probably I will update it with to more functions. I am working in Windows with Delphi 7.
Basically, "my plugin" should add 2 or 3 new functions to the host application.
How can I program a plug-in (or a functionality) that inserts new code (new functions) in the host application without re-compiling it??
Note: I am sorry about my English. My natural language is Spanish.
Thanks anymore,
Yulien.
You didn't specify the language or the platform on which you are working, so I can only give you a generic answer.
Plugins can be implemented in several different ways. The simplest (YMMV) is to compile the plugin to a Dynamically Linked Library (DLL in Windows) or a Shared Object (.so under Linux), and then you use the appropriate function to get specific functions from the DLL and call them.
Search the internet for the function LoadLibrary() on Windows or dlopen() on Un*x/Linux systems for more information.
An alternative is to embed a scripting language interpreter in your program. Firefox, for example, is implemented in C/C++ and exposes its internals to its JavaScript interpreter (SpiderMonkey) - in this way, all Firefox plugins can be written in JavaScript.
There are different ways to accomplish this, I will give you one of the most basic.
Say you are programming with C# on Windows (Other languages and environments are similar)
Part 1. You need to be able to load an assembly (if C++ a DLL). You might want to take this from a configuration file. Do this for every piece of functionality you want the plugin applications to extend.
Part 2. You need to be able to invoke code from this plugin, so put the functionality in an interface. For example, the main application will code to an interface IMyPluginCapability and your plugin will include some class which implements this interface. You can figure out which class through reflection.
Part 3. Invoke the functions you wish your plugin to extend.
Your language, environment will surely have similar capabilities. You can lookup details for that environment.