How to compile any swift file in a given folder? - swift

I use actual folders for my Xcode projects containing my .swift files. I dragged the folder into Xcode but it appears that my swift classes are not being built. I went to my target, went to Build Phase, went to Compile Source and added the missing folder to the references to be built.
My swift files are still not being built.
Which flag could I add to the folder (in Compile Source) for force it to compile every .swift files within it (including the ones in subfolders) ?
I couldn't find any info about it so far, any ideas ?

TLDR Use Groups, not Folder References.
Folder References in Xcode are made mainly for resources. When you create a folder reference, Xcode won't care about the contents. They are helpful when copying resources that should keep their directory structure.
To organize source code files, you need Groups. Groups are logical project folders and most of the time they are backed up by a file system folder anyway.
See also Difference between folder and group in Xcode?

Related

XCode and Swift files for version control

So I have a .gitignore created, which I have basic files included in there, but when it comes to a Swift and .xcodeproj project..
Which one of these files are the only ones that I need inside Github?
Actually, you need both .pbxproj and .xcworkspace, however, it depends:
.pbxproj file contains metadata, file references, configuration... which use to execute/build the project.
.xcworkspace contains and manages subprojects. A common scenario is using cocoapods. If you're developing a small project that's don't need to depend on any 3rd parties, you don't have to create xcworkspace.
xcuserdata folder is safe to ignore. It contains some temporary info like user state, files opened, folders opened.

Custom folder structure for Swift Package

When you generate a new Swift project with swift init, you get a Sources folder similar to this. Wondering if there is a way to change the folder structure so it is like this:
main.swift
lib
lib/something.swift
And just get rid of the Sources directory.
I believe that you can use any folder structure that you want. The only thing in that references specific folders in that particular link you provided was the path in the Package.swift file. Which if you want to use, you can just update the path.
The project file keeps track of what swift files have been added into the project and which should be compiled and included in the resulting binary. As long as the files have been added via xcode you should be fine.

Can't link static library in XCode 4 in workspace

So, I'm working on a project and can't get my XCode 4 workspace to behave. I have the main application as one project in the workspace. I then add the static library project into the workspace. It seems like everything is working okay. I can import files from the other project. It builds, but when I run it, I get this:
dyld: Symbol not found: _OBJC_CLASS_$_iGBC
Referenced from: /var/mobile/Applications/CD00CC83-28E4-4467-96C0-0D1777E21FDA/GBA4iOS.app/GBA4iOS
Expected in: flat namespace
in /var/mobile/Applications/CD00CC83-28E4-4467-96C0-0D1777E21FDA/GBA4iOS.app/GBA4iOS
And crashes. It appears that although Xcode believes the library has been linked, and it builds and runs, the app doesn't actually have the library. But in the derived data folder, it looks like everything that should be there... is there.
I'm going insane with XCode and all it's nuances in settings. Are there sanity checks I can go through to ensure this is working properly? What else can I do?
Edit:
Project settings are valid, and I've already linked the libraries.
Edit 2:
My workspace is setup so the libraries are also in the workspace:
I have removed the lib.a file from the main project and removed it from the Build Phase section, and added it back numerous times. There is no "copy library into destination folder" option when adding it in this way, so I can't do that.
try clean your build, if it don't work, remove the library in build phase and your project folder. When adding the lib to your project, check "copy item to destination if needed", the add that lib in build phase.

How to set reference to the folder which contains multiple jar files?

My environment:
Netbean 6.9.1
Glassfish 3.0.1
Windows 7
Goal:
When my coworkers opens the Netbean Project, the library is already referenced without them manually create library, adding jars into it and reference it.
Detail:
I created Netbean project and the project has reference to few jar files in the folder.
Currently whoever opens the project for the first time, they have to manually create library and refer it to the project.
My project location:
C:\Users\masatosan\Desktop\myProject\myApp
My library location:
C:\Users\masatosan\Desktop\myProject\lib\myLib
The myLib folder contains:
some1.jar
some2.jar
some3.jar
I can achieve my goal if I create reference to individual jar file by defining to project.properties file like below: (creating reference to sqljdbc4.jar)
file.reference.sqljdbc4.jar=../lib/sqljdbc4.jar
javac.classpath=\
${libs.restlib_gfv3ee6.classpath}:\
${file.reference.sqljdbc4.jar}:
But my case is different since I have 3 jars in the myLib folder and wanting to reference them all.
Is it possible to reference all jars in myLib folder?
Please let me know if you need more clarification.
I'm sorry, but it doesn't work that way. When you create a project, you have to add the jar files individually.
However, if you put your lib folder under your project, netbeans will refer to them via relative paths. Then when you share the project (lib directory included), netbeans will be able to automatically find the jar files when the next person uses the project. That way you only have to add jar files once.
Short of using a dependency management tool like maven (which Netbeans has good support for), this is really the best solution. It uses a bit more disk space (obviously), but that's never been a huge issue for me.
I figured how so let me share.
Tool --> Library then library window pop up.
Create library called "MyLib" which contains multiple jars.
Add "MyLib" to your project. This change will be written to project.properties file under nbproject folder.
project.properties file indicates the classpath of lib reference you just added.
It should look like something below
javac.classpath=\
${libs.Excella.classpath}:\
${libs.MyLib.classpath}
Now someone else opens the project from different machine and she just needs to do step#1 and #2, which is to create library with same library name i.e. "MyLib"
I think this is what Bill was saying originally but thought it would be helpful to give step by step instructions since I finally figured .... after long time :D

What's that "Classes-1.moved-aside" directory in my Classes directory?

In the XCode project folder (the real one on my hard drive) there's a "Classes-1.moved-aside" folder inside the "Classes" folder. It contains a few files which are also in the "Classes" folder. What's the point of that "Classes-1.moved-aside" folder?
These are for classes that you deprecated.
One way you can get them is if you create a new class with the same name of another class, xcode will move the old class into a moved aside folder.