Xcode 6: What to ignore when committing to SVN so the application can later be checked out and runnable without any extra work? - ios

I want to commit the minimum amount of files and still be able to checkout and have it working without ANY work. This will be specifically used for a Phonegap iOS application. However, any relation to iOS apps will be great.

Essentially you may ignore only the builds/ folder as the files in there are generated every build. Have been working in a project with other develops having only this folder .gitignore'd.
If you wish, you may ignore several other files to make your repository as clean as possible.
Another way to commit as little as possible is to use external library managements, such as CocoaPods. Just remember to ignore Pods/ folder and run pod install when first running the project on a new computer.

Related

Save packages downloaded by SPM into project GIT using Xcode 11

I started using new Xcode 11 which integrates SPM.
I added first dependency to my project:
but detected that files are not fetched into my project folder but into Xcode's cache:
I would like to commit all my dependencies files into my main project repository so my question is:
Is it possible to change location of fetched packages via SPM using Xcode 11?
It's somewhat possible, although the solution isn't necessarily a good or great practice, so I can't recommend.
Set the DerivedData in workspace settings to be relative to the workspace.
Add gitignore rules such that the workspace/WORKSPACE_NAME_DIR/SourcePackages/checkouts and related files are includes. Maybe best to ensure repositories directory is not included.
Add a Run Script phase to remove .git and .gitignore files in the checkouts directory.
Obviously, this is fragile largely through fighting the way SPM works. The workspace settings are per person so it's not great in teams.
SwiftPM integration has been setup to prevent this. It clones the files into a DerivedData/ProjectName-[RandomStuff]. You should commit your Package.resolved into the repo to ensure that you get the same version of each dependency across clones of the project.

Cordova project from .zip fails to build ios, tries to write to directory from other computer

After successfully creating, building, and emulating Cordova's Hello World project, I unzipped the project folder that I am taking over from another developer on a different machine and saved it locally. While I can run the iOS app from XCode with the built project from the previous developer, I can't run the $ cordova build ios command successfully to rebuild it on my machine.
It give the following output:
The following build commands failed:
Check dependencies
Write auxiliary files
When I run it in debug mode, I notice that both of these commands are trying to make a directory for the old dev's computer (/Users/hisName/whereHePutIt/CordovaProject/stuffItIsTryingToBuild) rather than one relative to my project folder (/Users/myName/whereIPutMine/CordovaProject/stuffItIsTryingToBuild).
There is a lot of text to comb through, but it looks as though it is always failing while attempting to make a directory in /Project/platforms/ios/CordovaLib/build/CordovaLib.build
I am really stumped by this because I can't find any sort of setting or file in the project that tries to write anywhere but a path relative to my project file, and Android builds and emulates fine.
I had a similar issue on Android actually. My home for sdk tools moved but the project still wanted to use the old sdk tools.
The solution I took was to remove the platform and then re-add it. I am sure there is a way of going through the existing files and patching this, but everything you should need is in the plugin/ and www/ and where ever you elected to keep your assets.
If you do try this, make sure to create a backup before removing the platform -- it would be awful to lose changes that someone might have jammed down in the platform/ios folder.
I just ran across this issue under similar circumstances - unzipped a zipped copy of a iOS Cordova app from a coworkers computer to continue developing it, and found I could not successfully run the cordova build command.
I managed to get this to work by deleting the old "Debug-iphonesimulator" folders that had been zipped up with the rest of the project from the other computer, and then re-running the build command.
There were two folders that I deleted:
"../ios/CordovaLib/build/CordovaLib.build/Debug-iphonesimulator"
and
"../ios/build/ProjectName.build/Debug-iphonesimulator"
Hope this helps someone!

Universal iOS app using CocoaPods - which files to check in into Git?

In Xcode 5 I am developing a universal iOS app - on three different Mac OS machines (on which I happen to have different usernames too - "admin", "alex", etc.)
My project uses the SDWebImage library through CocoaPods and I plan to add few more later.
I would like to keep my project in a Git-repository on GitHub or BitBucket.
I'm confused: which files of my project should I check in into the git repository.
Especially I wonder about 2 groups of files:
The CocoaPods-related (currently I've only checked in the Podfile and Podfile.lock, but there are also Pods.xconfig and Pods, etc.)
And the Xcode-related (should I check in the Workspace Settings? What to do with User Data - admin - ...?)
Here is the screenshot of the commit dialog:
When I run git clean -n -d in my project dir, I see the following:
Would remove Podfile.lock
Would remove Words.xcodeproj/xcuserdata/
Would remove Words.xcworkspace/
And my Podfile contains the following:
platform :ios, '6.0'
pod 'SDWebImage'
UPDATE:
I use a .gitignore containing xcuserdata, but for some reason still see the User Data files in the commit dialog:
This is a bit of a matter of taste and requirements for your projects. There are two schools:
Never check in generated code. Put your xcworkspace, Podfile.lock and Pods folder in .gitignore and never commit them. Instruct developers on your code base to run pod install directly after checkout. This is my preferred choice, and should work fine as long as your pod dependencies point to a specific version or a range of compatible versions.
Check the workspace, lock file and Pods directory into Git with the rest of your code. This is a guarantee that all developers on the project are using the exact same code when they build. Even if your third party dependency removes their code from the Internet, your project is still buildable. However, you now have a lot of source code that is unrelated to your own, version controlled together with your own.
As an aside: you should probably always put "xcuserdata" in your gitignore, maybe even your system-wide git ignore, because other users of your code are probably not interested in your personal Xcode settings.

how add manually a cordova plugin to ios existing project

i've a cordova project created via cordova cli command.
i build the project for Android and iOS platform but... i copied the build project into respective workspace (eclipse/xcode) and i updated that single project.
Now i need to add a plugin.
The project into cordova project folder is now so outdate so i would add the plugin via cli and copy the plugin to the respective project.
I copied successfully the generated plugin into the android project, but i'm not able to do the same thing with iOS.
For example i added the console plugin for iOS
cordova plugin add org.apache.cordova.console
if i open and run the build project it work and i see my message in console, but if i try to copy the generated plugin into my existing project it doesn't work.
nobody could help me to understand how add manually a plugin into my existing project?
update
yes i know, i'll try to explain better
i have my cordova project under folder /Document/cordova
when i made an ios build via command line cordova put the built project under /Document/cordova/platforms/ios
well i copied the folder ios under /workspace/my-project-name
after some work under workspace i see that i need to add a cordova plugin.
i added the plugin via command line and it was added to /Document/cordova/platforms/ios
at this poin i have a project under /Document with plugin but asset outdated and one project updated without plugin under /workspace
i'm trying to copy from built project to /workspace project.
i copied
/workspace/my-project-name/my-project-name/Plugins
/workspace/my-project-name/my-project-name/config.xml
/workspace/my-project-name/www/plugins
/workspace/my-project-name/www/cordova.js
/workspace/my-project-name/www/cordova_plugins.js
but it doesn't work... i missed somethings?
After reading it several times I think I get more less the idea...
Well, I am not sure why do you want to copy the ios project outside the current location. I suppose you have a good reason to do it, however you can always tweak that project instead of going back and forward, cordova will not impact non cordova related files each time you run "cordova build".
Are you familiar with control versioning? Git, SVN, mercurial? If so it is simple just we which files were impacted once you add the plugin and copy those... If no, I suggest using control versioning anyways to help keep track of your code changes.
NOTE: Be aware if you build the cordova projet and then you just want to update the files noted above it is highly likely that it won't work, that is why you run "build" is not a simple file sync. I recommend taking the new cordova project with the plugin added and then just add you personal tweaks on the ios in the other folder. Or just tweak the ios folder inside platforms folder...
I hope you are doing for good reason. Anyway you are missing to copy below file to work
/workspace/my-project-name/my-project-name/platforms/ios/my-project-name/config.xml
Copying the cordova iOS platform folder is not a good idea. The reason is, cordova builds an Xcode project in the platform folder, and there is some sort of caching/built in references to absolute location of the original Xcode project. Therefore it would be unclear to you and to Xcode which file is being referenced from within Xcode. This may have caused some other unnoticed errors in the project as well. So therefore, instead of keeping original project path available along with the new path, I would recommend renaming the original project folder in order to remove the ambiguity. This way, you will assure that the right file versions are referenced.

Issues Using GIT with Xcode projects

I know git and use it to manage a lot of my Repos on other projects. However I run into issues when it comes to xcode projects.
I start a project on Machine 'A' - when I push up to a repo and pull to let say machine 'B' I always receive compiling errors. Normally the errors have to do with files not being found. Literally "no such file or directory" followed by a path.
I'm working with the same version of Xcode on both mac's A and B. I also use the threetwenty framework.
When I zip the project up and send via email - the same results occur.
Many times these files that xcode can't find and that fail the build, are media files, like a image or video. Sometimes I see the three20 framework too.
My question is - how in xcode should I set a project up to play nice with git and or code sharing in general. Let me know if you need more information, I know the above is a little vague.
The first thing I always do is set up the .gitignore file before adding any other files from the project. Problems can occur when loading project settings for two different machines that may have the same User account name. You have to make sure some settings aren't added to the repo whilst others are.
I set up my .gitignore by adding the following:
.DS_Store
*/.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
Documentation/Generated
doxygenWarnings.txt
*.xcodeproj/xcuserdata/*.xcuserdatad
*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
*/*.xcodeproj/xcuserdata/*.xcuserdatad
*/*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
If you create the repos from scratch or run git rm --cached <filethatshouldbeignore> to each file that should be ignored and then commit, see if the problem still occurs.
Problems will occur in the .pbxproj file, so make sure all conflicts are corrected too.
Regarding files that cannot be found, remember to import the libraries etc. into the project folders and reference them from there. Apple's own iOS libraries should be fine, but others won't be. For example, in your project folder, copy your images from there and reference them only within the project folder.

Resources