From 7c168740d959a4ad3f4e89e1c2d1a273c6b9759a Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Sat, 5 Jan 2019 16:34:34 +0400
Subject: [PATCH] Update instructions for Xcode 10.1.

---
 README.md                                  |  2 +-
 Telegram/Patches/breakpad.diff             | 64 +++++++++++++++-------
 Telegram/Patches/macold/mini_chromium.diff |  8 ++-
 Telegram/gyp/generate.py                   |  2 +
 Telegram/gyp/lib_base.gyp                  |  4 +-
 Telegram/gyp/lib_export.gyp                |  2 -
 Telegram/gyp/lib_storage.gyp               |  2 -
 Telegram/gyp/telegram_mac.gypi             |  1 +
 docs/building-xcode-mas.md                 | 28 ++++++++++
 docs/building-xcode-old.md                 | 44 +++------------
 docs/building-xcode.md                     |  4 +-
 11 files changed, 90 insertions(+), 71 deletions(-)
 create mode 100644 docs/building-xcode-mas.md

diff --git a/README.md b/README.md
index e95679246..f6a97a5aa 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ The source code is published under GPLv3 with OpenSSL exception, the license is
 ## Build instructions
 
 * [Visual Studio 2017][msvc]
-* [Xcode 9][xcode]
+* [Xcode 10][xcode]
 * [GYP/CMake on GNU/Linux][cmake]
 
 [//]: # (LINKS)
diff --git a/Telegram/Patches/breakpad.diff b/Telegram/Patches/breakpad.diff
index b3c6c165a..ddcddbc61 100644
--- a/Telegram/Patches/breakpad.diff
+++ b/Telegram/Patches/breakpad.diff
@@ -1,5 +1,5 @@
 diff --git a/src/build/common.gypi b/src/build/common.gypi
-index 29990c6..53e99d4 100644
+index 29990c65..53e99d44 100644
 --- a/src/build/common.gypi
 +++ b/src/build/common.gypi
 @@ -330,6 +330,7 @@
@@ -11,7 +11,7 @@ index 29990c6..53e99d4 100644
          },
        }],
 diff --git a/src/client/mac/Breakpad.xcodeproj/project.pbxproj b/src/client/mac/Breakpad.xcodeproj/project.pbxproj
-index 1a93ce6..1c1d643 100644
+index 1a93ce6d..b5986e33 100644
 --- a/src/client/mac/Breakpad.xcodeproj/project.pbxproj
 +++ b/src/client/mac/Breakpad.xcodeproj/project.pbxproj
 @@ -35,6 +35,19 @@
@@ -34,7 +34,15 @@ index 1a93ce6..1c1d643 100644
  		162F64F2161C577500CD68D5 /* arch_utilities.cc in Sources */ = {isa = PBXBuildFile; fileRef = 162F64F0161C577500CD68D5 /* arch_utilities.cc */; };
  		162F64F3161C577500CD68D5 /* arch_utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 162F64F1161C577500CD68D5 /* arch_utilities.h */; };
  		162F64F4161C579B00CD68D5 /* arch_utilities.cc in Sources */ = {isa = PBXBuildFile; fileRef = 162F64F0161C577500CD68D5 /* arch_utilities.cc */; };
-@@ -170,11 +183,8 @@
+@@ -67,6 +80,7 @@
+ 		4DBE49A7134A4F280072546A /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBE4769134A4F080072546A /* CoreServices.framework */; };
+ 		4DBE49A8134A4F380072546A /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBE4769134A4F080072546A /* CoreServices.framework */; };
+ 		4DBE49A9134A4F460072546A /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBE4769134A4F080072546A /* CoreServices.framework */; };
++		5A8B220921E0C5740045F83C /* breakpad_nlist_64.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53690ECCE3FD009BE4BA /* breakpad_nlist_64.cc */; };
+ 		8B3101C611F0CD9F00FCF3E4 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
+ 		8B3101C711F0CD9F00FCF3E4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
+ 		8B3101CA11F0CDB000FCF3E4 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
+@@ -170,11 +184,8 @@
  		F92C564A0ECD10CA009BE4BA /* string_conversion.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53850ECCE6AD009BE4BA /* string_conversion.cc */; };
  		F92C564C0ECD10DD009BE4BA /* breakpadUtilities.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F92C563C0ECD10B3009BE4BA /* breakpadUtilities.dylib */; };
  		F92C56570ECD113E009BE4BA /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F92C554A0ECCF530009BE4BA /* Carbon.framework */; };
@@ -46,7 +54,7 @@ index 1a93ce6..1c1d643 100644
  		F92C56A90ECE04C5009BE4BA /* crash_report_sender.m in Sources */ = {isa = PBXBuildFile; fileRef = F92C56A80ECE04C5009BE4BA /* crash_report_sender.m */; };
  		F93803CD0F8083B7004D428B /* dynamic_images.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C536B0ECCE3FD009BE4BA /* dynamic_images.cc */; };
  		F93803CE0F8083B7004D428B /* exception_handler.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C536D0ECCE3FD009BE4BA /* exception_handler.cc */; };
-@@ -213,7 +223,6 @@
+@@ -213,7 +224,6 @@
  		F9C44DBD0EF072A0003AEBAA /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9C44DBA0EF072A0003AEBAA /* MainMenu.xib */; };
  		F9C44E000EF077CD003AEBAA /* Breakpad.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Breakpad.framework */; };
  		F9C44E3C0EF08B12003AEBAA /* Breakpad.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Breakpad.framework */; };
@@ -54,7 +62,7 @@ index 1a93ce6..1c1d643 100644
  		F9C44EA20EF09F93003AEBAA /* HTTPMultipartUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = F92C53770ECCE635009BE4BA /* HTTPMultipartUpload.m */; };
  		F9C44EE50EF0A006003AEBAA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9C44EE40EF0A006003AEBAA /* SystemConfiguration.framework */; };
  		F9C44EE90EF0A3C1003AEBAA /* GTMLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = F9C44EE80EF0A3C1003AEBAA /* GTMLogger.m */; };
-@@ -410,20 +419,6 @@
+@@ -410,20 +420,6 @@
  			remoteGlobalIDString = F92C563B0ECD10B3009BE4BA;
  			remoteInfo = breakpadUtilities;
  		};
@@ -75,7 +83,7 @@ index 1a93ce6..1c1d643 100644
  		F93DE2FB0F82C3C600608B94 /* PBXContainerItemProxy */ = {
  			isa = PBXContainerItemProxy;
  			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
-@@ -536,13 +531,6 @@
+@@ -536,13 +532,6 @@
  			remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
  			remoteInfo = Breakpad;
  		};
@@ -89,7 +97,7 @@ index 1a93ce6..1c1d643 100644
  /* End PBXContainerItemProxy section */
  
  /* Begin PBXCopyFilesBuildPhase section */
-@@ -714,7 +702,6 @@
+@@ -714,7 +703,6 @@
  			isa = PBXFrameworksBuildPhase;
  			buildActionMask = 2147483647;
  			files = (
@@ -97,7 +105,7 @@ index 1a93ce6..1c1d643 100644
  				8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */,
  			);
  			runOnlyForDeploymentPostprocessing = 0;
-@@ -1181,18 +1168,13 @@
+@@ -1181,18 +1169,13 @@
  			isa = PBXNativeTarget;
  			buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "Breakpad" */;
  			buildPhases = (
@@ -116,7 +124,7 @@ index 1a93ce6..1c1d643 100644
  			);
  			name = Breakpad;
  			productInstallPath = "$(HOME)/Library/Frameworks";
-@@ -1399,6 +1381,8 @@
+@@ -1399,6 +1382,8 @@
  /* Begin PBXProject section */
  		0867D690FE84028FC02AAC07 /* Project object */ = {
  			isa = PBXProject;
@@ -125,7 +133,7 @@ index 1a93ce6..1c1d643 100644
  			buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Breakpad" */;
  			compatibilityVersion = "Xcode 3.1";
  			developmentRegion = English;
-@@ -1583,16 +1567,6 @@
+@@ -1583,16 +1568,6 @@
  /* End PBXReferenceProxy section */
  
  /* Begin PBXResourcesBuildPhase section */
@@ -142,7 +150,7 @@ index 1a93ce6..1c1d643 100644
  		F92C569C0ECE04A7009BE4BA /* Resources */ = {
  			isa = PBXResourcesBuildPhase;
  			buildActionMask = 2147483647;
-@@ -1640,20 +1614,6 @@
+@@ -1640,20 +1615,6 @@
  			shellPath = /bin/sh;
  			shellScript = "install_name_tool -id \"@executable_path/../Resources/breakpadUtilities.dylib\" \"${BUILT_PRODUCTS_DIR}/breakpadUtilities.dylib\"\n";
  		};
@@ -163,10 +171,11 @@ index 1a93ce6..1c1d643 100644
  		F9C77DD80F7DD5CF0045F7DB /* ShellScript */ = {
  			isa = PBXShellScriptBuildPhase;
  			buildActionMask = 2147483647;
-@@ -1674,6 +1634,19 @@
+@@ -1674,6 +1635,20 @@
  			isa = PBXSourcesBuildPhase;
  			buildActionMask = 2147483647;
  			files = (
++				5A8B220921E0C5740045F83C /* breakpad_nlist_64.cc in Sources */,
 +				0748C0501C63C52D004489BF /* bootstrap_compat.cc in Sources */,
 +				0748C04F1C63C523004489BF /* macho_walker.cc in Sources */,
 +				0748C04E1C63C51C004489BF /* md5.cc in Sources */,
@@ -183,7 +192,7 @@ index 1a93ce6..1c1d643 100644
  				F92C565F0ECD116B009BE4BA /* protected_memory_allocator.cc in Sources */,
  				F92C56630ECD1179009BE4BA /* exception_handler.cc in Sources */,
  				F92C55D10ECD0064009BE4BA /* Breakpad.mm in Sources */,
-@@ -1955,16 +1928,6 @@
+@@ -1955,16 +1930,6 @@
  			target = F92C563B0ECD10B3009BE4BA /* breakpadUtilities */;
  			targetProxy = F92C564D0ECD10E5009BE4BA /* PBXContainerItemProxy */;
  		};
@@ -200,7 +209,7 @@ index 1a93ce6..1c1d643 100644
  		F93DE2FC0F82C3C600608B94 /* PBXTargetDependency */ = {
  			isa = PBXTargetDependency;
  			target = F93803BD0F80820F004D428B /* generator_test */;
-@@ -2025,11 +1988,6 @@
+@@ -2025,11 +1990,6 @@
  			target = 8DC2EF4F0486A6940098B216 /* Breakpad */;
  			targetProxy = F9C44E190EF0790F003AEBAA /* PBXContainerItemProxy */;
  		};
@@ -212,7 +221,7 @@ index 1a93ce6..1c1d643 100644
  /* End PBXTargetDependency section */
  
  /* Begin PBXVariantGroup section */
-@@ -2126,8 +2084,12 @@
+@@ -2126,8 +2086,12 @@
  			isa = XCBuildConfiguration;
  			baseConfigurationReference = 8B31027711F0D3AF00FCF3E4 /* BreakpadDebug.xcconfig */;
  			buildSettings = {
@@ -226,7 +235,7 @@ index 1a93ce6..1c1d643 100644
  			};
  			name = Debug;
  		};
-@@ -2135,7 +2097,12 @@
+@@ -2135,7 +2099,12 @@
  			isa = XCBuildConfiguration;
  			baseConfigurationReference = 8B31027811F0D3AF00FCF3E4 /* BreakpadRelease.xcconfig */;
  			buildSettings = {
@@ -239,7 +248,7 @@ index 1a93ce6..1c1d643 100644
  			};
  			name = Release;
  		};
-@@ -2454,7 +2421,12 @@
+@@ -2454,7 +2423,12 @@
  			isa = XCBuildConfiguration;
  			baseConfigurationReference = 8B31027711F0D3AF00FCF3E4 /* BreakpadDebug.xcconfig */;
  			buildSettings = {
@@ -253,7 +262,7 @@ index 1a93ce6..1c1d643 100644
  			name = "Debug With Code Coverage";
  		};
 diff --git a/src/client/mac/Framework/Breakpad.mm b/src/client/mac/Framework/Breakpad.mm
-index 1d2e519..943310f 100644
+index 1d2e519b..943310fa 100644
 --- a/src/client/mac/Framework/Breakpad.mm
 +++ b/src/client/mac/Framework/Breakpad.mm
 @@ -355,10 +355,10 @@ bool Breakpad::Initialize(NSDictionary *parameters) {
@@ -480,7 +489,7 @@ index 1d2e519..943310f 100644
  }
  
 diff --git a/src/common/language.cc b/src/common/language.cc
-index 978fb85..a95ae5f 100644
+index 978fb855..a95ae5f7 100644
 --- a/src/common/language.cc
 +++ b/src/common/language.cc
 @@ -46,8 +46,27 @@
@@ -552,7 +561,7 @@ index 978fb85..a95ae5f 100644
  #endif
    }
 diff --git a/src/common/linux/elf_symbols_to_module.cc b/src/common/linux/elf_symbols_to_module.cc
-index 562875e..4367851 100644
+index 562875e1..43678510 100644
 --- a/src/common/linux/elf_symbols_to_module.cc
 +++ b/src/common/linux/elf_symbols_to_module.cc
 @@ -39,6 +39,29 @@
@@ -615,7 +624,7 @@ index 562875e..4367851 100644
        module->AddExtern(ext);
      }
 diff --git a/src/tools/linux/tools_linux.gypi b/src/tools/linux/tools_linux.gypi
-index 1c15992..020e4c1 100644
+index 1c15992e..020e4c1c 100644
 --- a/src/tools/linux/tools_linux.gypi
 +++ b/src/tools/linux/tools_linux.gypi
 @@ -58,7 +58,7 @@
@@ -627,3 +636,16 @@ index 1c15992..020e4c1 100644
        ],
        'dependencies': [
          '../common/common.gyp:common',
+diff --git a/src/tools/mac/dump_syms/macho_dump.cc b/src/tools/mac/dump_syms/macho_dump.cc
+index d882bbe8..3432bb45 100644
+--- a/src/tools/mac/dump_syms/macho_dump.cc
++++ b/src/tools/mac/dump_syms/macho_dump.cc
+@@ -140,7 +140,7 @@ void DumpFile(const char *filename) {
+   size_t object_files_size;
+   const SuperFatArch* super_fat_object_files =
+       fat_reader.object_files(&object_files_size);
+-  struct fat_arch *object_files;
++  struct fat_arch *object_files = 0;
+   if (!super_fat_object_files->ConvertToFatArch(object_files)) {
+     exit(1);
+   }
diff --git a/Telegram/Patches/macold/mini_chromium.diff b/Telegram/Patches/macold/mini_chromium.diff
index 50aa1dc3e..208f0d789 100644
--- a/Telegram/Patches/macold/mini_chromium.diff
+++ b/Telegram/Patches/macold/mini_chromium.diff
@@ -1,8 +1,8 @@
 diff --git a/build/common.gypi b/build/common.gypi
-index 1affc70..c0d2f6a 100644
+index 1affc70..0677e4b 100644
 --- a/build/common.gypi
 +++ b/build/common.gypi
-@@ -66,6 +66,11 @@
+@@ -66,6 +66,13 @@
            'conditions': [
              ['clang!=0', {
                'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',  # -std=c++11
@@ -10,11 +10,13 @@ index 1affc70..c0d2f6a 100644
 +              'OTHER_LDFLAGS': [
 +                '/usr/local/macold/lib/libc++.a',
 +                '/usr/local/macold/lib/libc++abi.a',
++                '-isysroot/',
++                '-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/',
 +              ],
  
                # Don't link in libarclite_macosx.a, see http://crbug.com/156530.
                'CLANG_LINK_OBJC_RUNTIME': 'NO',      # -fno-objc-link-runtime
-@@ -116,6 +121,9 @@
+@@ -116,6 +123,9 @@
            ],
  
          },
diff --git a/Telegram/gyp/generate.py b/Telegram/gyp/generate.py
index 52afc8db5..2326fa6c4 100644
--- a/Telegram/gyp/generate.py
+++ b/Telegram/gyp/generate.py
@@ -106,6 +106,8 @@ else:
     cmakeConfigurations.append('Release')
 
 os.chdir(scriptPath)
+if sys.platform == 'darwin':
+    subprocess.call('mkdir -p ../../out', shell=True)
 for format in gypFormats:
     command = gypArguments[:]
     command.insert(0, gypScript)
diff --git a/Telegram/gyp/lib_base.gyp b/Telegram/gyp/lib_base.gyp
index d70fe8fad..12dee1cf9 100644
--- a/Telegram/gyp/lib_base.gyp
+++ b/Telegram/gyp/lib_base.gyp
@@ -13,10 +13,8 @@
     'type': 'static_library',
     'includes': [
       'common.gypi',
-	  'openssl.gypi',
+      'openssl.gypi',
       'qt.gypi',
-      'telegram_win.gypi',
-      'telegram_mac.gypi',
       'telegram_linux.gypi',
       'pch.gypi',
     ],
diff --git a/Telegram/gyp/lib_export.gyp b/Telegram/gyp/lib_export.gyp
index 2d1ac6c56..f73aabdb1 100644
--- a/Telegram/gyp/lib_export.gyp
+++ b/Telegram/gyp/lib_export.gyp
@@ -14,8 +14,6 @@
     'includes': [
       'common.gypi',
       'qt.gypi',
-      'telegram_win.gypi',
-      'telegram_mac.gypi',
       'telegram_linux.gypi',
       'pch.gypi',
     ],
diff --git a/Telegram/gyp/lib_storage.gyp b/Telegram/gyp/lib_storage.gyp
index 527713546..d72f4b5a7 100644
--- a/Telegram/gyp/lib_storage.gyp
+++ b/Telegram/gyp/lib_storage.gyp
@@ -15,8 +15,6 @@
       'common.gypi',
       'openssl.gypi',
       'qt.gypi',
-      'telegram_win.gypi',
-      'telegram_mac.gypi',
       'telegram_linux.gypi',
       'pch.gypi',
     ],
diff --git a/Telegram/gyp/telegram_mac.gypi b/Telegram/gyp/telegram_mac.gypi
index 68591c439..f6a575f08 100644
--- a/Telegram/gyp/telegram_mac.gypi
+++ b/Telegram/gyp/telegram_mac.gypi
@@ -44,6 +44,7 @@
       'OTHER_CPLUSPLUSFLAGS': [ '-nostdinc++' ],
       'OTHER_LDFLAGS': [
         '-isysroot', '/',
+        '-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/',
         '-lbase',
         '-lcrashpad_client',
         '-lcrashpad_util',
diff --git a/docs/building-xcode-mas.md b/docs/building-xcode-mas.md
new file mode 100644
index 000000000..57602c4ba
--- /dev/null
+++ b/docs/building-xcode-mas.md
@@ -0,0 +1,28 @@
+## Build instructions for Xcode 10.1
+
+**NB** These are used for Mac App Store build, after the [Building using Xcode][xcode] instructions.
+
+### Prepare breakpad
+
+Go to ***BuildPath*** and run
+
+    MACOSX_DEPLOYMENT_TARGET=10.8
+
+    cd Libraries
+
+    git clone https://chromium.googlesource.com/breakpad/breakpad
+    cd breakpad
+    git checkout bc8fb886
+    git clone https://chromium.googlesource.com/linux-syscall-support src/third_party/lss
+    cd src/third_party/lss
+    git checkout a91633d1
+    cd ../../..
+    git apply ../../tdesktop/Telegram/Patches/breakpad.diff
+    cd src/client/mac
+    xcodebuild -project Breakpad.xcodeproj -target Breakpad -configuration Debug build
+    xcodebuild -project Breakpad.xcodeproj -target Breakpad -configuration Release build
+    cd ../../tools/mac/dump_syms
+    xcodebuild -project dump_syms.xcodeproj -target dump_syms -configuration Release build
+    cd ../../../../..
+
+[xcode]: building-xcode.md
diff --git a/docs/building-xcode-old.md b/docs/building-xcode-old.md
index 7916e693e..853fc7b54 100644
--- a/docs/building-xcode-old.md
+++ b/docs/building-xcode-old.md
@@ -1,43 +1,20 @@
-## Build instructions for Xcode 9.0
+## Build instructions for Xcode 10.1
 
-**NB** These are outdated, please refer to [Building using Xcode][xcode] instructions.
-
-### Prepare folder
-
-Choose a folder for the future build, for example **/Users/user/TBuild**. It will be named ***BuildPath*** in the rest of this document. All commands will be launched from Terminal.
+**NB** These are used for OS X 10.6/10.7 build, after the [Building using Xcode][xcode] instructions.
 
 ### Download libraries
 
-Download [**xz-5.0.5**](http://tukaani.org/xz/xz-5.0.5.tar.gz) and unpack to ***BuildPath*/Libraries/xz-5.0.5**
-
 Download [**libiconv-1.15**](http://www.gnu.org/software/libiconv/#downloading) and unpack to ***BuildPath*/Libraries/macold/libiconv-1.15**
 
 ### Clone source code and prepare libraries
 
-**Copy crt1.10.6.o from Xcode SDK path to /usr/local/lib**
-
 Go to ***BuildPath*** and run
 
     MACOSX_DEPLOYMENT_TARGET=10.6
 
     git clone --recursive https://github.com/telegramdesktop/tdesktop.git
 
-    cd Libraries
-
-    cd xz-5.0.5
-    ./configure
-    make
-    sudo make install
-    cd ..
-
-    git clone https://github.com/Kitware/CMake
-    cd CMake
-    ./bootstrap
-    make -j4
-    sudo make install
-    cd ..
-
-    cd macold
+    cd Libraries/macold
 
     svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
     cd llvm/projects
@@ -48,7 +25,7 @@ Go to ***BuildPath*** and run
     mkdir libcxxabi
     cd libcxxabi
 
-    cmake -G "Unix Makefiles" -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 -DCMAKE_BUILD_TYPE:STRING=Release -DLIBCXX_ENABLE_SHARED:BOOL=NO -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/macold -DLLVM_PATH=../llvm -DLIBCXXABI_LIBCXX_PATH=../llvm/projects/libcxx ../llvm/projects/libcxxabi/
+    LDFLAGS="-isysroot / -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/" cmake -G "Unix Makefiles" -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 -DCMAKE_BUILD_TYPE:STRING=Release -DLIBCXX_ENABLE_SHARED:BOOL=NO -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/macold -DLLVM_PATH=../llvm -DLIBCXXABI_LIBCXX_PATH=../llvm/projects/libcxx ../llvm/projects/libcxxabi/
     make -j4
     sudo make install
     cd ../
@@ -56,7 +33,7 @@ Go to ***BuildPath*** and run
     mkdir libcxx
     cd libcxx
 
-    cmake -G "Unix Makefiles" -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/macold -DLIBCXX_ENABLE_SHARED:BOOL=NO -DLIBCXX_CXX_ABI:STRING=libstdc++ -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/" -DLLVM_PATH=../llvm/ ../llvm/projects/libcxx/
+    LDFLAGS="-isysroot / -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/" cmake -G "Unix Makefiles" -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/macold -DLIBCXX_ENABLE_SHARED:BOOL=NO -DLIBCXX_CXX_ABI:STRING=libstdc++ -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/" -DLLVM_PATH=../llvm/ ../llvm/projects/libcxx/
     make -j4
     sudo make install
     cd ../
@@ -107,7 +84,7 @@ Go to ***BuildPath*** and run
     cd openal-soft
     git checkout openal-soft-1.19.1
     cd build
-    LDFLAGS='/usr/local/macold/lib/libc++.a /usr/local/macold/lib/libc++abi.a -isysroot /' cmake -D ALSOFT_EXAMPLES=OFF -D LIBTYPE:STRING=STATIC -D CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 -D CMAKE_INSTALL_PREFIX:STRING=/usr/local/macold ..
+    LDFLAGS="/usr/local/macold/lib/libc++.a /usr/local/macold/lib/libc++abi.a -isysroot / -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/" cmake -D ALSOFT_EXAMPLES=OFF -D LIBTYPE:STRING=STATIC -D CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 -D CMAKE_INSTALL_PREFIX:STRING=/usr/local/macold ..
     make -j4
     sudo make install
     cd ../..
@@ -117,6 +94,7 @@ Go to ***BuildPath*** and run
     CFLAGS="-mmacosx-version-min=10.6" CPPFLAGS="-mmacosx-version-min=10.6 -nostdinc++" LDFLAGS="-mmacosx-version-min=10.6" ./configure --prefix=/usr/local/macold
     make -j4
     sudo make install
+    cd ..
 
     git clone https://chromium.googlesource.com/crashpad/crashpad.git
     cd crashpad
@@ -153,12 +131,4 @@ Go to ***BuildPath*** and run
     sudo make install
     cd ..
 
-### Building the project
-
-Go to ***BuildPath*/tdesktop/Telegram** and run
-
-    gyp/refresh.sh
-
-Then launch Xcode, open ***BuildPath*/tdesktop/Telegram/Telegram.xcodeproj** and build for Debug / Release.
-
 [xcode]: building-xcode.md
diff --git a/docs/building-xcode.md b/docs/building-xcode.md
index e6270b3d4..c05ce07db 100644
--- a/docs/building-xcode.md
+++ b/docs/building-xcode.md
@@ -1,4 +1,4 @@
-## Build instructions for Xcode 9.0
+## Build instructions for Xcode 10.1
 
 ### Prepare folder
 
@@ -21,7 +21,7 @@ Go to ***BuildPath*** and run
     MACOSX_DEPLOYMENT_TARGET=10.8
 
     ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-    brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 xvid yasm
+    brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 xvid yasm pkg-config
 
     sudo xcode-select -s /Applications/Xcode.app/Contents/Developer