How to import xcode project into xcode? - iphone

I downloaded SwiffCore (https://github.com/musictheory/SwiffCore) for iOS and the Demo project contains a the main SwiffCore xcode project inside with all the necessary libraries.
Now I want to use SwiffCore in my project.
How do I import the xcode project inside my project?
I tried by dragging inside but it does not copy all files.
I have seen it a lot in other xcode samples.
Regards
mirza

From what I see on the github repository, you just need to drag the Source folder into your project and then use the classes as indicated by the documentation.

Related

Xcode import local Swift Package and build from the app

The goal is to import a local Swift Package "Shared" into a Xcode project and have them both in a workspace.
I have created a workspace, dragged and dropped both the package and the project in, and then added the package to the app by adding it to Frameworks, Libraries, and Embedded Content.
This works when building from the workspace! But I have to make it also possible to build from the app project, currently it throws: "Missing package product 'Shared'".
I know it is possible to do what I want because I have an example project where it works, in there Shared is listed as a local Swift Package in the app project, in mine it is not. In the project Shared is listed under Frameworks, Libraries, and Embedded Content but can't be added again after removing the reference.
It would be great if someone could help me with this!
The solution is to create a local Swift Package in the app project and to import the Shared Package there. Then it will be available in the whole project.

Add a local Swift Package target to an existing Xcode project

I have an existing Xcode project that contains targets for a "traditional" iOS app ("Foo") and an iOS framework ("FooLib"). When the Xcode 12 beta dropped a few days ago, I added a multiplatform (iOS/macOS) SwiftUI app target ("Foo SwiftUI") to the same project. Now I want to make my framework cross-platform, too, so I added a multiplatform Swift Package ("Foo Package") to the project and moved the iOS framework classes to the new Swift package. I then added this package to all app targets' Frameworks, Libraries, and Embedded Content sections. It appeared to work for all app targets until I cleaned the project and tried again. Now the app targets complain that the Foo Package can't be resolved:
Missing package project 'FooLib'.
I tried removing & re-adding the FooLib package to the app targets, but it no longer shows up in the pop-up list of frameworks and libraries to add. Are local Swift packages explicitly unsupported in Xcode projects? Do I need to put the package in its own Git repo and set it up like any other third-party package dependency?
What I'm most confused about it that it looks like it worked right after I created the Swift package, but not after I cleaned the project and tried re-running the app targets.
OK, sorry for my previous answer. — It is obvious how to share a package with yourself by way of a remote URL, such as GitHub, that serves it. Basically you are playing the role of both developer and end-user, and it's clear how to do that. So I think what's needed here is a step-by-step tutorial to sharing a package with yourself locally without actually serving it.
In Xcode, choose File > New > Swift Package and save as MyLibrary to the Desktop.
Now choose File > New > Project, choose the iOS App template, and save as App1 to the Desktop.
You now have two windows open. Drag MyLibrary from the project navigator in the MyLibrary window into the empty area at the bottom of the project navigator in the App1 window.
Quit Xcode.
Launch Xcode again and open App1. Look, the MyLibrary icon now has hierarchical contents. Edit the app target and add MyLibrary library as a dependency.
You can now edit MyLibrary; you can also import MyLibrary in your code and you will be able to use any public members of public types.
Close App1 and create another project, App2. Repeat steps 3, 4, 5, and 6.
From now on, either App1 and App2 can "see" MyLibrary. From either one, you can edit MyLibrary, you can import it and use its code. But you cannot have both App1 and App2 open at the same time. If you do, one of them will complain that the package is missing. So you'll be fine as long as you only have one at a time open.
Now, if you want to escape that limitation, then go back to the first way of dealing with all this: upload the package to GitHub and acquire it in your projects as a package dependency.
For me, it works using Xcode Workspaces “around” local Projects and Swift Packages.
Create App project
Create Swift Package
Create Workspace for app project
Add the App project to the Workspace
Add the Swift Package to the Workspace, too
In the app target “General” settings, “embed&sign” the Swift Package from the current workspace
You might have to restart Xcode afterwards for it to pick up on the changes ...

Xcode have 2 projects under 1 workspace

I have 1 workspace with project with project with swift3.
Now I need to add other project or target. I am not sure.
But the goal is to have the other project in swift4. It will be helper project for main project in swift3. And this second project should be available from swift3. It's extensions for UIViewController. How can I make it?
You can do that either as separate project or as target of existing project.
Create Framework
Choose Swift version(4.0 in your case)
Add Swift file
Link framework in application
Import framework and use extension

how to add .bundle file to a nativescript plugin

I have some thirdparty code I want to add to my nativescript (iOS) project. The code consists of a .framework file and a .bundle file which contains a .momd file. I was thinking of adding this via a custom plugin, the docs are pretty clear on how to add the .framework file, but am not sure how I add and reference the bundle and underlying .momd file. Does anyone have any experience of this that they can share please?
I spent a lot of time poring over the iOS interop documentation while working on my nativescript-midi plugin, but I don't recall seeing anything specifically on adding bundles or .momd files. If possible, I suggest you create a new "container" iOS framework project in which you can import your desired framework, bundle, and .momd file, and then import that combined framework project into your plugin via a Podfile. That's essentially the approach I took to import a C library in my project (the cocoa-midi-message-parser repo referenced by the Podfile in my plugin).
In case anyone else needs to do this. I ended up using cocoapods xcodeproj gem to inject my file into my workspace file. A gist of the working code is here.

Using Alamofire within a Playground

I'm new to iOS development and using Xcode and I'm having trouble getting Alamofire to work within a Playground. There's some functionality I'd like to test out for proof of concept but the library is not linked to the Playground and I've tried getting it to play nicely. I have Alamofire set up to work within an iOS (not in a Playground) project before the installation instructions in the Github Alamofire repo were recently updated.
Any suggestions on how to get Alamofire to import properly in the Playground?
Apple provides excellent step-by-step instruction to do so here: Importing Custom Frameworks Into a Playground
Here is what I consider to be the simplest straight line path:
Download and build Alamofire:
brew install carthage
echo "github \"Alamofire/Alamofire\"" > Cartfile
carthage update
Configure the workspace with a playground file and Alamofire.
From the Carthage/Build/{iOS / OSX} directory, drag the Alamofire.framework file into your link library list: {Project Name} -> {Target Name} -> Build Phases -> Link Binary With Libraries
Command-N (create file) -> {Platform} -> Source -> Playground
If not already in a Workspace file, File -> Save as Workspace. To be paranoid, I close the project / workspace and (re)open the workspace.
Click on the playground file created in #2, and add the import import Alamofire
You can try moving library to
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/
Then you can import and use it right in your playground
You can create a playground within the project also like in this tutorial
Steps
If the project is not in a workspace, save as workspace
Create new Playground, by adding to workspace level in the project pane
Ensure your project has a framework target. If it doesn't Edit the scheme to add a new Cocoa Touch Framework target (it doesn't need to have unit tests)
Add the files that you want to use in the playground, to the new framework target
Build the Framework by selecting the target in the build box at the top
In the playground, import the Framework. If the classes you want to use are not public, you need to import like so: #testable import ModuleFramework