Automate the process of including generated proto files into an Xcode project - ios

Our iOS app currently is using Google protobuffer gRPC as our API layer to communicate between App and backend. And so we have these .proto files in our backend directory which will be converting to .grpc.swift and .pb.swift files by gRPC-Swift-Plugins and then consumed by the App.
This works okay, but the process of converting is very tedious, and we would like to automate the whole process.
Below is how we're doing it:
Delete previously copied directory, and copy all .proto files from backend (.proto files are maintained by backend devs) to App directory named "Protos" via a shell script
We already set up Build rules and include .proto files in Compile Sources. Following the steps from an answer here on SO
Screenshot of the current setup in Xcode Build Rules:
Whenever we build the project, .pb.swift and .grpc.swift are generated and putting into a directory named "generated" under the "Protos" folder.
Here are the problems:
If the backend added a new .proto files into the source directory, my script will only copy the files into the Protos directory but not included news files in the Compile Sources list.
Similar to the first problem, we need to manually set up Compile Sources in Xcode and that means if a new dev joins our team, he/she also needs to do the same setup again.
We sometimes need to refer to the .grpc.swift and .ph.swift files while coding. But If we add these files into Xcode and build the project again, Xcode will complain that these generated files are there like (Sorry, we're working on a private repo, so the project name and file names are replaced):
Multiple commands produce '${user_path}/${proto_name}.pb.o':
Target '${my_project_name}' (project '${my_project_name}') has compile command for Swift source files
Target '${my_project_name}' (project '${my_project_name}') has compile command for Swift source files
Any answers or comments and suggestions are greatly appreciated!

It's interesting I didn't have those problems with Swift if I use the $DERIVED_FILE_DIR
protoc "$INPUT_FILE_NAME" --swift_out="$DERIVED_FILE_DIR" --proto_path="Your/proto/path"
I don't use the plugin because I've got the plugin installed in my /usr/local/bin
But I have exactly those problems when we use the output for cpp files.

Related

QNX momentics linked source files not compiling

I am creating a QNX port for a Linux application. As a test, i copied all source code and header files into /src/ directrory and built the code. the binary was created, and I was able to execute on target VM. but now I have to create the momentics project inside the project folder, without altering or creating duplicate copies of existing source files.
I found that I can use linked resources. So I followed steps provided here and could add the file to project.
but when I compile the project, it is not taking the linked files.
As one can clearly see the process is directly going to linking stage.
but if I add a new cpp file without linking, only that particular file is getting compiled, not the linked file.
only the new main.cpp is getting compiled.
Can anyone help me to get this project built, only using linked resources?
I was able to use IDE for compiling my writing a Makefile and importing it to IDE.

How to integrate .proto files in Xcode compilation?

I am trying to port an android app to ios and new to mac/xcode ecosystem. My app uses Google proto buffs and using instructions at https://github.com/alexeyxo/protobuf-swift/blob/master/README.md I am able to build protobuf for swift and add ProtocolBuffers.xcodeproj to my project. I was even able to generate .swift files for my proto files outside of xcode using protoc directly. However, my question is how do I integrate .proto files in Xcode so xcode can find/compile them? Do I need to copy my .proto files manually in my project? I am using Xcode 7.2.1 and protoc version is 3.0.0. Thanks in advance.
Create a build rule for *.proto files, something like this:
Add your .proto file to "Compile Sources" build phase list.

Unable to compile / run run book-examples in eclipse

I am trying to run sample code "MyHierarchicalUI" from section 4.2 from "book of vaadin" and this code refers to TreeExample and TableExample classes which can be found at
http://dev.vaadin.com/svn/doc/book-examples/
I downloaded the book example code from mentioned svn link and imported it as existing eclipse project,however when I try to compile / run this project in eclipse I get the following error.
Errors occurred during the build.
Errors running builder 'Integrated External Tool Builder' on project 'book-examples'.
The file does not exist for the external tool named Copy sources.
The file does not exist for the external tool named Copy sources.
book-examples project is not valid vaadin project so can not be imported directly, we can not build it directly as vaadin project due to missing artifacts like ivy.xml and ivysettings.xml.
To use any code from book-examples project you will have to bring the code to your project manually (copy/paste), however a support ticker to make book-example project import-able / build-able and run-able has been created and can be tracked using this link Ticket # 13078.

Facebook iOS SDK 3.1 from Github missing FacebookSDK.framework

I want to use Facebook SDK on XCode 4.5 for integration with iOS6.
I read this tutorial. I was using this .dmg package to install the library but I need to track and read the implementation of some methods, so I noticed that there is a repo on Github with the current source code.
My problem is that I don't know how to install this properly as with the package .dmg. Any ideas on how to do it? I tried to just import the src folder and reference the whole project but I'm having a lot of issues, warnings and errors.
Update
I had to do this again, so now I made it work. Here is what I did:
I tried both ways, building the source code (1) and importing the files directly(2). On the first scenario it was easy, on the root folder of Github repo just run:
sudo scripts/build_framework.sh
You will get the files needed, the same that you get when installing with .pkg. But I needed to track the functions, so I tried to importing the files.
First I added the src folders from the Github repo on my project. I had an issue with duplicated definitions on every file. The problem was on my Build Settings (BS), I was still referencing to the .pkg install directory of Facebook so I had the files duplicated. I removed every reference to that folder on BS and then added the files.
After that, on the files that imported the Facebook files I got:
Undefined symbols for architecture i386
When I copied the files to XCode, the .m files where not automatically added to the Build Phases / Compile Sources. I added them manually and imported FBConnect.h on my files.
Hope it helps some one with the same issue.
If you include the FacebookSDK via git, you will need to build the framework. Run the following command from within the FacebookSDK directory:
scripts/build_framework.sh
Then, FacebookSDK.framework will appear in FacebookSDK/build
Add the entire src folder to your project. Import FBConnect.h in any class where you want to use Facebook. The connect class imports the rest of the necessary classes.
#import "FBConnect.h"

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