Protocol Buffers in xcode 6 Mac 10.9 - ios

I have been researching how to make a demo on Protocol Buffers in iOS
I found this tutorial recommended by a lot of people:https://code.google.com/p/metasyntactic/wiki/ProtocolBuffers
I use 10.9 Mac version and xcode 6 with command-line tool installed.
I have followed this tutorial and downloaded protobuf-2.6.0 and get some problem in "Project Integration" from step 2 to step 6.
I don't understand how to do it in step 2 and I can't find /Classes/ProtocolBuffers.h in step 3. Also in step 4 and 5. Can anyone help me explain cleary this tutorial.

you can find your the ProtocolBuffers.h in ProtocolBuffers-2.2.0-Source ▸ objectivec ▸ Classes.
In step2,
first you create a workspace and add you current project to your workspace, and then add the ProtocolBuffers.xcodeproj to the workspace which is in the ProtocolBuffers-2.2.0-Source ▸ objectivec.
you can see here about how to add a existing project to the workspace, hence, your current project can't be opened when you add it.
https://developer.apple.com/library/ios/recipes/xcode_help-structure_navigator/articles/Adding_an_Existing_Project_to_a_Workspace.html#//apple_ref/doc/uid/TP40009934-CH1-SW1
and in xCode 6, there is no pch file, you can get your help here:
Why isn't ProjectName-Prefix.pch created automatically in Xcode 6?

Related

Xcode 9 Swift Language Version (SWIFT_VERSION)

I've recently updated xcode to version 9. Before that in Xcode 8.x whenever I use to do pod update it shows me an update code to convert the code to Swift 3 and doing that solve the errors. But now it is giving me this error:
The “Swift Language Version” (SWIFT_VERSION) build setting must be set
to a supported value for targets which use Swift. This setting can be
set in the build settings editor.
For this error I've tried Build Settings > Swift Language Version and it was Swift 3.2
But as the update call has re-installed some of the pods like Alamofire and it says to install Xcode 8.x to convert the code to Swift 3 so do I need to install an additional version with the latest Xcode? If yes, then how can I install Xcode 8 with Xcode 9?
Answer to your question:
You can download Xcode 8.x from Apple Download Portal or Download Xcode 8.3.3 (or see: Where to download older version of Xcode), if you've premium developer account (apple id). You can install & work with both Xcode 9 and Xcode 8.x in single (mac) system. (Make sure you've Command Line Tools supporting both version of Xcode, to work with terminal (see: How to install 'Command Line Tool'))
Hint: How to migrate your code Xcode 9 compatible Swift versions (Swift 3.2 or 4)
Xcode 9 allows conversion/migration from Swift 3.0 to Swift 3.2/4.0 only. So if current version of Swift language of your project is below 3.0 then you must migrate your code in Swift 3 compatible version Using Xcode 8.x.
This is common error message that Xcode 9 shows if it identifies Swift language below 3.0, during migration.
Swift 3.2 is supported by Xcode 9 & Xcode 8 both.
Project ► (Select Your Project Target) ► Build Settings ► (Type 'swift' in Searchbar) Swift Compiler Language ► Swift Language Version ► Click on Language list to open it.
Convert your source code from Swift 2.0 to 3.2 using Xcode 8 and then continue with Xcode 9 (Swift 3.2 or 4).
For easier migration of your code, follow these steps: (it will help you to convert into latest version of swift supported by your Xcode Tool)
Xcode: Menus: Edit ▶ Covert ▶ To Current Swift Syntax
For Objective C Projects created using Xcode 8 and now opening in Xcode 9, it is showing the same error as mentioned in the question.
To fix that, Press the + button in Build Settings and select Add User-Defined Setting as shown in the image below
Then in the new row created add SWIFT_VERSION as key and 3.2 as value like below.
It will fix the error for objective c projects.
I just got this after creating a new Objective-C project in Xcode 10, after I added a Core Data model file to the project.
I found two ways to fix this:
The Easy Way: Open the Core Data model's File Inspector (⌥⌘-1) and change the language from Swift to Objective-C
Longer and more dangerous method
The model contains a "contents" file with this line:
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14460.32" systemVersion="17G5019" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
In there is a sourceLanguage="Swift" entry. Change it to sourceLanguage="Objective-C" and the error goes away.
To find the "contents" file, right click on the .xcdatamodeld in Xcode and do "Show in Finder". Right-click on the actual (Finder) file and do "Show Package Contents"
Also: Changing the model's language will stop Xcode from generating managed object subclass files in Swift.
This can happen when you added Core Data to an existing project.
Check the:
<Name>/<Name>.xcdatamodeld/<Name>.xcdatamodel/contents file.
This file contains an entry "sourceLanguage" that (by default) might have been set to "Swift". Change it to "Objective-C".
I just click on latest swift convert button and set App target build setting-> Swift language version: swift 4.0,
Hope this will help.
This Solution works when nothing else works:
I spent more than a week to convert the whole project and came to a solution below:
First, de-integrate the cocopods dependency from the project and then start converting the project to the latest swift version.
Go to Project Directory in the Terminal and Type:
pod deintegrate
This will de-integrate cocopods from the project and No traces of CocoaPods will be left in the project. But at the same time, it won't delete the xcworkspace and podfiles. It's ok if they are present.
Now you have to open xcodeproj(not xcworkspace) and you will get lots of errors because you have called cocoapods dependency methods in your main projects.
So to remove those errors you have two options:
Comment down all the code you have used from cocoapods library.
Create a wrapper class which has dummy methods similar to cocopods library, and then call it.
Once all the errors get removed you can convert the code to the latest swift version.
Sometimes if you are getting weird errors then try cleaning derived data and try again.
maybe you need to download toolchain.
This error occurs when you don't have right version of swift compiler.
In my case, all warn disappeared after I directly changed swift version from 2.x to 4.0 in build settings except two warn.
These warning related to myprojectnameTests and myprojectnameUITests folder. I didn't notice and I thought its relate to direct immigration from Xcode 7 to Xcode 9 and I thought I couldn't solve this problem and I should install missed Xcode 8 version.
In my case, I deleted these folders and all warns disappeared, but you can recreate this folder and contains using this:
file > new > target > (uitest or unittest extensions)
and use this article for create test cases:
https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/04-writing_tests.html

Xcode can't read swift files

This project came to me to be updated to the new iOS 10.It uses frameworks downloaded with cocoa pods. Some of these frameworks are written in swift.Now that I made few changes on the project code, when I try to build the project, I get errors on the frameworks I downloaded as if the project can't read swift!
Is there somewhere where I can set my project to accept swift classes?
Updated Xcode to Xcode 8 and it updated the code and fixes theses issues. Thanks Folks.

Xcode 8 beta 4: Build fails with "The following binaries use incompatible versions of Swift:" error

With new Xcode 8 beta 4 we started experiencing the following error during CopySwiftLibs build phase:
Effective srcDirs: {(
<DVTFilePath:0x7f865961e970:'/Volumes/Data/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator'>,
<DVTFilePath:0x7f8657d02b20:'/Volumes/Data/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/lib/swift/iphonesimulator'>
)}
error: The following binaries use incompatible versions of Swift:
/Users/user/Projects/git/iphone-swift-1/DerivedData/myApp/Build/Products/Debug-iphonesimulator/myApp.app/myApp
/Users/user/Projects/git/iphone-swift-1/myApp/myAppApi.framework/myAppApi
myAppApi is a subproject in the workspace that contains some shared code (it uses Alamofire).
One thing to note: originally we converted project from Swift 2.2 to Swift 2.3, and then manually upgraded to 3.0.
Does anyone have any idea what might be causing this error?
Thanks!
I had the same problem, but managed to fix it by:
Clean the project.
Close project and quit Xcode.
Clean derived data.
Open the project again and it's there, all nice and working.
I did this on Xcode 8 using Swift 3.
You can also get this problem, if you have the scenario of your container app's code is Swift 2.3 and you're creating a new extension in Xcode 8.
To solve the above scenario...
Note: All code has to be in the same swift (compatible) version to compile without failure.
That being said, one way you could solve this problem is by sticking to Swift 2.3 and then setting your Extension Target's Use Legacy Swift Language Version to "Yes".
You can find that option while Xcode 8 is open as follows:
Select your app project root in the Project Navigator (on the left-hand side)
On the right-hand side, select your extension under the TARGETS
section
Once the extension is selected, click on the Build Settings tab
Scroll down and find Use Legacy Swift Language Version and set it
to Yes from its drop-down menu.
You can now build the project
Note: You might need to fix the overridden code in the extension templates since they were originally in Swift 3.
Before doing anything...
(If you can use Xcode 8.0-compatible with your project)
By default your project is set to Xcode 3.2-compatible
Select your app project in the Navigator (on the left-hand side)
Select Project Document in the Utilities Panel (on the
right-hand side)
Change Project Format to Xcode 8.0-compatible
Try to build your project.
If it doesn't work, try the other solutions proposed.
Note:You can even switch back to Xcode 3.2-compatible after fixing the error and it should work, but you "might" have other build problems later.
Recommendation:
Before debugging an existing project. Close your project and zip a copy of your project file if you did not create a Git repository when you created your project.
I just had the same problem after updating Xcode to 9.3. I fixed the problem simply by just cleaning the build folder. You can do this with Command-Option-Shift-K or in the option menu "Product" -> "Clean" (see screenshot)
I fixed this by deleting the embedded binaries in the project. To do this:
Open your workspace/ project in Xcode.
Navigate to the actual project file (with the General, Capabilities, etc. ribbon).
Go to General > Embedded Binaries, remove by selecting on the ones you don't want and then clicking the minus sign.
Note 1: You shouldn't have to delete them from the "Linked Frameworks and Libraries" section (they should automatically be removed when you remove them from the "Embedded Binaries").
Note 2: I have a lot of dependencies and am using CocoaPods. I have nothing in the "Embedded Binaries" and only the "Pods_[YourApplicationName].framework" in the "Linked Frameworks and Libraries" section.
I had various libraries integrated via carthage. However during the process I switched some of them to cocoapods and forgot to remove the old .frameworks file from the project target.
Removing them solved the build error.
I had the same problem.
My solution was to rename the 'myApp'-directory to 'myAppmyApp' and then I ran the app again. A new 'myApp'-directory was made a the app did run very well again on my iPhone.
A difference with your situation might be this: the name of my app, let's say 'myApp' in the directory 'DerivedData' was myApp concatenated with: '-'
Maybe this will help you.
You need to switch all the dependencies to swift 3.
In your case, Alamofire need to be switched to Swift 3 branch
I had the same error message after adding a Swift 3 version of a framework.
My target framework search path was still configured to find both swift 2 and swift 3 version of the same framework, so my project got stuck on swift 2.3 version.
For me, the solution has been to remove the old framework from my project directory and delete its folder reference from the framework search path.
So I just post the solution I found so far after an hour debugging.
Since Xcode 9, this can be tracked by the compiler log.
If you scroll down to the bottom of the compiler log, you will find this issue is caused by type checking crash.
Just had this pop up after upgrading to Xcode 10.2 ... one of my pods uses Swift.
Fix was to:
pod repo update
rm -rf Pods
pod install

Polidea ios-class-guard is DEAD in XCode 7, replace it or fix it?

Everything is great before XCode 7 and iOS 9. After we upgrade XCode to 7.0 and 7.0.1, the ios-class-guard keep annoying us.
You can't install ios-class-guard based on the official tutorial. The homebrew is failed to install formula.
The following build commands failed:
CompileC /Users/Digiflex/Library/Developer/Xcode/DerivedData/ios-class-guard-afpnixzupjudctebfxyqptpmbgpa/Build/Intermediates/ios-class-guard.build/Release/MachObjC.build/Objects-normal/x86_64/CDLCSegment.o Source/CDLCSegment.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Then, we download source code from Polidea/ios-class-guard. After we fixed couple bugs, and compiled it. We archived build and export to
/usr/bin/ios-class-guard
When we do the obfuscation, it looks OK. But when we run project in XCode 7, we got many errors like:
Unexpected '#' in program
or
Missing context for method declaration
After many hours research with no conclusion, our question are:
How to fix the ios-class-guard problem by myself, under XCode 7 environment?
Is there any other open source project provide a similar feature, which is can obfuscate Class, Method and String?
There is new version (0.8) of iOS Class Guard with Xcode 7 support.
I succeeded to fix errors like this by replacing
#import <Foundation/Foundation.h>
with:
#import UIKit;
In my project .pch file.
Then I also changed in my project build settings:
Enable modules (C and objective C) to YES
However I end up having the same problem for imports of classes in the .pch file:
#import "BDError.h"
The latest version of iOS Class Guard (0.8, as of this writing) still has issues with Xcode 7.3, and didn't fully fix support for prior versions of Xcode 7.
How to fix the ios-class-guard problem by myself, under XCode 7 environment?
Starting with Xcode 7, the iPhoneOS SDK that ships with Xcode does not include the ARM-based .dylib dynamic-library files anymore, and these have been replaced .tdb files. The .tbd files appear to be markup (text) files describing their corresponding .dylib files, specifically including at least some of the symbols. The errors you see are because of this change.
The consequence of this is that in order to obfuscate an ARM-based build, the symbols to exclude can only be found by examining the iPhone simulator libraries. Currently, this implies that an x86/x86_64 build must be created for the analyze phase of building.
According to "apple staff":
"For those who are curious, the .tbd files are new 'text-based stub libraries', that provide a much more compact version of the stub libraries for use in the SDK, and help to significantly reduce its download size."
These .tbd files do not contain all the necessary symbols, for automatically finding excludes, though.
iOS Class Guard 0.8 fixed the error messages, but in such a way that it wasn't finding all the symbols that should be excluded.
Is there any other open source project provide a similar feature, which is can obfuscate Class, Method and String?
Yes, PPiOS-Rename is a fork of ios-class-guard that fixes this issue, by always searching for symbols in the iPhoneSimulator SDK, even if the build was compiled for a device. It has also been updated to work with Xcode 7.3. (Full disclosure: I work for PreEmptive Solutions who created this fork, but it is open source and free.)

Problems trying to add the libz.1.2.3.dylib to my ipad project

First of all, i'm now on this site so really sorry if i'm commiting some error posting this question.I'm trying to use the zipArchive class to manage zip files in an ipad project.
What steps will reproduce the problem?
Create a project.
Add the ZipArchive folder with their files.
Add the libz.1.2.3.dylib
What is the expected output? What do you see instead?
I have all the code (about ziparchive) commented, so i only have the #import #import "ZipArchive/ZipArchive.h" in my viewcontroller, and i expect to build the project without errors.
I see the following error in the compiler:
ld: warning: ignoring file /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2/Symbols/usr/lib/libSystem.dylib, missing required architecture i386 in file
ld: in /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2/Symbols/usr/lib/libobjc.A.dylib, missing required architecture i386 in file for architecture i386
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
What version of the product are you using? On what operating system?
I'm using xcode 4 a project for the ipad with the 4.2 ipad simulator on a Mac os X version 10.6.7
Please provide any additional information below.
I think the problem is with the libz.1.2.3.dylib library, and I have some guest of where might be the problem:
The libz.1.2.3.dylib path error is on iPhoneSimulator.platform, it is valid for ipad too?? If is not, which lib could i use for the same purpose with the ipad??
I'm not sure i'm adding the libz.1.2.3.dylib lib correctly. What I have done is: right-click on Resources folder -> add files to "myproject" -> search for the libz.1.2.3.dylib and add the 4.2 version of it from the path u could see in the compiler errors. I also try to add to the frameworks folder with the same results.
I'm reading lots of posts about how to fix similar problems but no one could help me.
Any idea of what I have to do to fix my problem??
Really thanks!!
You need to do this:
Delete libz.1.2.3 from your local Frameworks folder. You don't need it.
Select your project at the top of the Project Navigator.
Select your application target.
Open "Link Binary With Libraries".
Click the "+"
Search for "libz".
Select "libz.dylib".
If you are using Xcode 4.5.2 the screenshots below may aide you in proceeding through steps 2 through 5. I'm not sure if other versions of Xcode are the same or not.
If you are using xcode 4 or upper version of it than it seems that libz.1.2.3.dylib is not included in iOS5 sdk. Here is simple method to fix this:
Open your project in XCode 4.2
Remove libz.1.2.3.dylib from framework
Add new framework libz.1.2.5
Run you app
It works fine.
libz.dylib is an alias to the latest version (currently libz.1.2.5) so you can also navigate to the file's location in Terminal and create a symlink called "libz.1.2.3.dylib".
cd /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib/
sudo ln -s libz.1.2.5.dylib libz.1.2.3.dylib
You could also link to libz.dylib, which I would expect to always point to the actual latest version, which is why Tricon recommends changing the project to just include libz.dylib. I'm not sure I'd delete anything, although it's not a whole lot different from adding a new symlink...you're still mucking around deep inside the guts of Xcode....

Resources