Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

[WIP] Fix Cycle dependencies build error on macOS #4149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndrewVebster
Copy link
Contributor

@AndrewVebster AndrewVebster commented Jun 5, 2020

πŸ“’ Description

We would see this build error only on incremental builds.
From the documentation:

To allow fast and correct incremental builds, every build after the initial build uses information discovered during the prior builds to learn about additional dependencies in your source code, such as included headers or imported modules. This may lead to dependency cycles which are only discovered after the first successful build.

Did some experiments and this combination fixed the issue:

  1. In TogglDesktop target remove from the Build Phases Run Script (Fix dynamic library paths in Frameworks)
  2. Go to TogglDesktopLibrary target -> Build Phases
  3. Move "Copy File" section up so it is now above "Compile Sources"

πŸ•ΆοΈ Types of changes

Breaking change (fix or feature that would cause existing functionality to change)

πŸ‘« Relationships

Closes #4067

πŸ”Ž Review hints

To reproduce the compile error you would do next:

  1. Clean project
  2. Build
  3. Change something in the library (e.g. add whitespace line to toggl_api.cc)
  4. Build
  5. Build again

At step 5 you'll get compile error: Cycle in dependencies between targets 'TogglDesktop' and 'TogglDesktopLibrary'.

After applying changes from PR this error should go away.

TODO

  • Test if GitHub Actions still work
  • Tested with release builds
  • Test and apply if needed to TogglDesktop-AppStore target

@skel35 skel35 requested a review from NghiaTranUIT June 5, 2020 16:29
Copy link
Contributor

@NghiaTranUIT NghiaTranUIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though your solution works well during the debugging session, but the absence of the Run Script (Fix dynamic library paths in Frameworks) would cause more serious problems on the production build.

If you try to archive the build and open it. The app will get crashed immediately.

Crash logs

❯ /Users/nghiatran/Desktop/TogglDesktop\ 2020-06-08\ 13-59-51/TogglDesktop.app/Contents/MacOS/TogglDesktop ; exit;
dyld: Library not loaded: /usr/local/lib/libPocoXML.60.dylib
  Referenced from: /Users/nghiatran/Desktop/TogglDesktop 2020-06-08 13-59-51/TogglDesktop.app/Contents/Frameworks/TogglDesktopLibrary.dylib
  Reason: image not found
[1]    14708 abort      

[Process completed]

Problem

  1. Linked paths of the Poco Libs and OpenSSL are invalid
$  otool -L /Users/nghiatran/Desktop/TogglDesktop/TogglDesktop.app/Contents/Frameworks/TogglDesktopLibrary.dylib
/Users/nghiatran/Desktop/TogglDesktop/TogglDesktop.app/Contents/Frameworks/TogglDesktopLibrary.dylib:
	@executable_path/../../Contents/Frameworks/TogglDesktopLibrary.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/local/lib/libPocoXML.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/lib/libPocoFoundation.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 162.0.0)
	/usr/local/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/local/lib/libPocoData.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 609.1.20)
	/usr/local/lib/libPocoDataSQLite.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/lib/libPocoJSON.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/lib/libPocoNetSSL.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/lib/libPocoCrypto.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/local/lib/libPocoUtil.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/lib/libPocoNet.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1675.129.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

=> Poco libraries locates at usr/local/lib, which is incorrect.
=> It should be point to the libraryes in the Framework folder.
Such as

otool -L /Applications/TogglDesktop.app/Contents/Frameworks/TogglDesktopLibrary.dylib
/Applications/TogglDesktop.app/Contents/Frameworks/TogglDesktopLibrary.dylib:
	@loader_path/TogglDesktopLibrary.dylib (compatibility version 1.0.0, current version 1.0.0)
	@loader_path/libPocoXML.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	@loader_path/libPocoFoundation.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 162.0.0)
	@loader_path/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	@loader_path/libPocoData.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 609.1.20)
	@loader_path/libPocoDataSQLite.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	@loader_path/libPocoJSON.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	@loader_path/libPocoNetSSL.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	@loader_path/libPocoCrypto.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	@loader_path/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	@loader_path/libPocoUtil.60.dylib (compatibility version 0.0.0, current version 0.0.0)
	@loader_path/libPocoNet.60.dylib (compatibility version 0.0.0, current version 0.0.0)

Thus, removing the script is not a good idea. I suggest keeping the file and maybe find alternative solution

@NghiaTranUIT
Copy link
Contributor

On the other hand, we should apply the fix on "TogglDesktop-AppStore" target too πŸ‘

@NghiaTranUIT
Copy link
Contributor

@AndrewVebster Maybe, the migration to Framework could fix this problem. Ticket: https://github.com/toggl-open-source/toggldesktop/issues/4152

@AndrewVebster AndrewVebster changed the title Fix Cycle dependencies build error on macOS [WIP] Fix Cycle dependencies build error on macOS Oct 23, 2020
@MartinBriza MartinBriza self-requested a review October 23, 2020 08:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants