Build Swift 3 in Terminal to create XCode project - ios

It seems Apple changed this line:
swift build -X
This no longer works to create an Xcode project as described here
Doest anyone know the updated way to do this as I cannot find it online
Thanks

Now you should use the Swift Package Manager.
To create a project structure:
swift package init --type executable
or
swift package init --type library
To make a project compatible with Xcode:
swift package generate-xcodeproj

Related

Module 'Swift' was created for incompatible target x86_64-apple-ios13.0

I'm creating an iOS framework and I want to copy some Xcode templates from my framework directory (that are not included in my .xcproject, but are in the folder that contains the project), when my framework is installed trought Cocoapods. In other words, when a developer installs my framework with Cocoapods or manually, I want to copy the templates into his Xcode Template Files folder.
I'm trying to execute a swift script file from the build phase of Xcode like this:
swift "${SRCROOT}/Folder/Folder/installer.swift"
But I get this error when I try to build it:
/<unknown>:1:1: module 'Swift' was created for incompatible target x86_64-apple-ios13.0: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule
If I execute swift installer.swift from the terminal, the script works. So, I think there is a problem with my Xcode.
My installer.swift file copies the template files to the Xcode Template Files folder.
I don't know if this way is the correct one, but I didn't find any other solution so far.
When I tried something similar I had to tell swift to compile for macOS by adding the following "shebang" comment as the first line of the swift script:
#!/usr/bin/env xcrun --sdk macosx swift

Instaling without cocoapods

https://github.com/IBM-Swift/Swift-SMTP
Im sorry if this is a dumb question but I am trying to install this inside my app and there is no documentation on how to add it. I always use cocoapods but it seems this can't be used for this project. Could anyone help me I need this functionality
That particular project/repo uses Swift Package Manager, so in Terminal cd into the project root:
$ swift package generate-xcodeproj
This will create an .xcodeproject which you'll then open and build. Once you've done that just drag the built framework into the project you'd like to include it in and use the import:
import SwiftSMTP

Using Swift3 Package Manager with Xcode 8 with no luck

I'm trying to integrate swift package manager in my project, but with no luck. The iOS simulator crashes at startup.
Here are the steps that I followed in order to integrate the package manager:
open xcode and create a new xcodeproject: testcpackage
from the terminal I've run the command:
swift package init to create the Package.swift file
swift package generate-xcodeproj
swift build
swift test - everything seems to be ok
open the new generated file testpackage.xcodeproj in xcode
run the application (cmd+R): build succeeded
first error given by the iOS simulator: Could not attach to pid : “9207”
I close the iOS simulator and I run the project again when I get the 2nd error:
No installable items found at /Users/xxxxxx/Library/Developer/CoreSimulator/Devices/555xxx14-xxx-xx-8E6E-C13D5AB463A0/data/Library/Caches/com.apple.mobile.installd.staging/temp.rA1vGO/extracted/Payload
Could you please help me to solve this issue?
I use the following method to get packages to work in iOS. That being said, I'm not sure if this is the "best" way to do this:
Make starting Package.swift file
swift package generate-xcodeproj
Open project in Xcode
Project : Build Settings : Base SDK ==> change to IOS
Editor : Add Target : (iOS ... Single View App)
Select your project, look at target list, find your newly added target : General : Deployment Info
On toolbar, change "active scheme" to the new target
Run
It has worked for me in the past. However, I have had to fix search paths. I'm currently suffering from that problem here: Xcode: missing required module error
Good luck

No such module "PackageDescription"

I just started with swift 3 and made a simple app in xcode using Swift 3.0 . Now i want to add a third party library using Swift Package Manager . I am following installation method given in this link . I created Package.swift file which looks like this
import PackageDescription
let package = Package (
name : "SwiftPM",
dependencies : [
.Package(url: "https://github.com/ArtSabintsev/Siren.git", majorVersion: 1)
])
but i get error No such module "PackageDescription"
The Swift Package Manager and Xcode are orthogonal. That is, you can't expect to compile Package.swift in Xcode; it simply won't work. Instead, until Xcode supports the package manager, you need to have two distinct builds - one with the package manager and one with Xcode.
So, using the Swift Package Manager, once you've defined Package.swift and formulated your directory structure as expected by the package manger, you perform simply:
swift build
Then for Xcode, you create an Xcode project that uses your source code, but not Package.swift. You'll need to clone the Siren.git project, explicitly - into your Xcode build's source files.
Swift 3/4
Navigate to your project folder through a terminal and run these commands swift package init --type library first and then swift package generate-xcodeproj
Reference
For me the issue turned out to be Target Membership. I created the Package.swift file manually inside an iOS app project.
Solution:
Select and go to the Package.swift file
Open the File Inspector on the right side
Deselect any modules inside Target Membership section
Refer to the solution in this link:
https://forums.kodeco.com/t/server-error-no-such-module-packagedescription/177438
Command:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
For other people who faced the same error as this:
Fix your Package.swift syntax
I got this error because Xcode hadn't parsed Package.swift fully yet, because of syntax errors.
In my case, I had a .target(name: "name-of-target", dependencies: [""]). As soon as I removed the empty dependency string (""), Xcode immediately parsed the file, and the error disappeared. Remember to save the file though.
Also, GoZoner and Pratiks answers are outdated:
Xcode has integration with Swift Packages now (as shown above)
swift package generate-xcodeproj is deprecated, shown by the error message when using it:
warning: Xcode can open and build Swift Packages directly. 'generate-xcodeproj' is no longer needed and will be deprecated soon.
More information about what that is, and why its gone here.

Phonegap 2.1.0 Cordova/CDVViewController.h file not found

I have installed Xcode 4.5 (no previous phonegap version installed). I have downloaded,extracted and created project by Phonegap tutorial : http://docs.phonegap.com/en/2.1.0/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS
After the terminal command : ./create myproject ~/Desktop/myproject com.test.myproject I have successfly created structure.
Than i launch xcode and wanna Play this example project. Xcode build Fails and says:
Lexical or proccessor issue 'Cordova/CDVViewController.h' file not found
I tried to add this missing header in to classes folder, repaired the import syntax, but still same problem.
Does anybody solved this problem?/HOW?
After many attempts I decided to read Readme.md and solve the problem using ./update_cordova_subproject!
Create project using:
./create ~/Desktop/project com.example.project project
Update cordova subproject reference:
./update_cordova_subproject ~/Desktop/project/project.xcodeproj
Build successfull now!

Resources