KISS

Keep It Simple Stupid

Note about building CocoaPods-powered iOS projects

| comments

TL;DR: If a CocoaPods-injected project won’t build with some weird errors, check that the symlinks are correct. Explanation follows.

Here is the situation. A guy from the client’s side zipped the sources of the iOS project on windows to copy them onto a Mac to build the app for AppStore. But the following errors would stop the build:

1
2
3
4
5
6
7
8
9
10
11
12
13
ProcessPCH /Users/user/Library/Developer/Xcode/DerivedData/app-crnirrohurquhvboorfniwcympij/Build/Intermediates/PrecompiledHeaders/app-Prefix-gywwereqpuslribpfrncsiseshvd/app-Prefix.pch.pth app/app-Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
In file included from /Users/user/Desktop/source_b/src/app/app-Prefix.pch:15:
/Users/user/Desktop/source_b/src/Pods/Headers/CocoaLumberjack/DDLog.h:1:1: error: expected identifier or '('
../../CocoaLumberjack/Lumberjack/DDLog.h
^
1 error generated.

In file included from /Users/user/Desktop/source_b/src/app/app-Prefix.pch:15:
/Users/user/Desktop/source_b/src/Pods/Headers/CocoaLumberjack/DDLog.h:1:1: error: expected unqualified-id
../../CocoaLumberjack/Lumberjack/DDLog.h
^
1 error generated.

The only very similar issue I found was this: http://stackoverflow.com/questions/12607203/unqualified-id-in-file-included-from-zxbinarizer-mm, but it had no proper solution.

So I got the zipped sources and used DiffMerge to compare the two directory hierarchies to figure out the difference. Here’s the catch: CocoaPods creates softlinks (a.k.a. symlinks) for the used headers (like Pods/Headers/CocoaLumberjack/DDLog.h pointing to Pods/CocoaLumberjack/Lumberjack/DDLog.h), and when the project was checked out on windows, it created the softlinks as regular text files with the path to the original file. Look:

1
2
3
➜  ~/Desktop  ll -P ./source_{b,my}/src/Pods/Headers/CocoaLumberjack/DDLog.h
-rwxr-xr-x@ 1 user  staff  40 Jan  1 13:39 ./source_b/src/Pods/Headers/CocoaLumberjack/DDLog.h
lrwxr-xr-x  1 user  staff  40 Jan  1 15:22 ./source_my/src/Pods/Headers/CocoaLumberjack/DDLog.h -> ../../CocoaLumberjack/Lumberjack/DDLog.h

That is, both files are 40 bytes long, but the wrong one is just a usual file with this text:

1
../../CocoaLumberjack/Lumberjack/DDLog.h

which obviously fails to compile with the errors you can see above. It hadn’t been so easy to figure out on my mac, because OS X properly displays the contents of the files beyond the softlink. Zipping the sources on OS X solved the issue.

Leave a comment ⬇ if you have something to say.

Comments