Install Fragaria framework - xcode

I was looking for a way to implement syntax highlighting on my cocoa app and I found the great Fragaria framework https://github.com/mugginsoft/Fragaria. Unfortunately I seem to be unable to install the framework in my app.
Here are the steps I follow:
Compile the framework from the source code target
Add the framework to the "Link Binary with Libraries" build phase of XCode 4
Drag the framework into "Copy Bundle Resources"of build phase
Unfortunately when I try to build my app I get this error:
dyld: Library not loaded:
#executable_path/../Frameworks/MGSFragaria.framework/Versions/A/MGSFragaria
Referenced from:
/Users/dedalus/Developer/DEGS/trunk/build/Debug/DEGS.app/Contents/MacOS/DEGS
Reason: image not found
Which step am I missing?

Don't add the framework product to the Copy Bundle Resources build phase. Instead, create a new Copy Files build phase, set its destination to the Frameworks directory and add the framework build product to this phase. The Copy Bundle Resources build phase copies the framework to the resources subdirectory (Contents/Resources on OS X), but the dynamic linker expects it to be in the frameworks subdirectory (Contents/Frameworks on OS X). The newly added Copy Files build phase will put it there.
BTW, the error you're seeing is a run-time error, not a compile-time error. So strictly speaking you get this error when running the app, not when building it.

Related

How to Link a framework required by a macOS bundle when building an xcode project requiring this bundle

I have a macOSX bundle project B, which requires the GameKit framework. I can compile it into a bundle, creating B.bundle.
I put this B.bundle inside project A which requires this bundle to work. When I try to build project A, I got a linkage error:
"__OBJC_CLASS_$_GKAccessPoint", referenced from:
obj-class-ref in ....
"__OBJC_CLASS_$_GKLocalPlayer", referenced from:
obj-class-ref in ....
ld: symbol(s) not found for architecture arm64
GKAccessPoint and GKLocalPlayer are the two classes used by my bundle project. It looks like it doesn't find the classes at all (I have tried building for other architecture and it also fails but the architecture name changes).
I don't really know how to make the linkage work. Here are the settings inside my project B:
And here the settings in my project A:
Thanks!
Alright, so after struggling for a day, I found out what was the problem.
I was generating the main project using unity, and the native GameKitNativebundle.bundle, as well as the GameKitNativebundle.mm files are inside the project, under the Assets folder.
The problem was I had ticked the .mm files as to be included in the standalone version. So xcode was trying to compile this .mm file directly and was trying to link it, which failed.
Unticking the standalone checkbox in the .mm files and rebuilding the xcode project from unity made the project link again.

Getting "Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib" error

The problem occurred when I adding Nimble as a git submodule. I've fired an issue on Quick/Nimble, but the problem appears to be not likely a Nimble issue, it maybe rather an Xcode issue, thus I'm asking here.
I set up a simple project according to Nimble installation guid and it's on github now. Basically I created an xcworkspace and an xcodeproj (added to the workspace). Nimble is added as git submodule and subproject to the workspace. Then I added Nimble.framework to my test targets Build Phases and wrote some simple test code to see if Nimble was running.
And when I run the test, Xcode gave this error message:
2017-02-20 23:41:29.482 xctest[52165:616190] The bundle “MainProjTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2017-02-20 23:41:29.483 xctest[52165:616190] (dlopen_preflight(/Users/nandiin/Library/Developer/Xcode/DerivedData/NimbleIssue-fkhppktoktwpjodtarmzrjobszwv/Build/Products/Debug-iphonesimulator/MainProjTests.xctest/MainProjTests): Library not loaded: #rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: /Users/nandiin/Library/Developer/Xcode/DerivedData/NimbleIssue-fkhppktoktwpjodtarmzrjobszwv/Build/Products/Debug-iphonesimulator/Nimble.framework/Nimble
Reason: image not found)
Program ended with exit code: 82
I've tried some solution I found for similar problems and they didn't work:
setting Embed Asset Packs In Product Bundle to YES (tried for both main target and test target)
setting Always Embed Swift Standard Libraries to YES (tried for both main target and test target)
The issue is the run path for the dynamic library:
libswiftSwiftOnoneSupport.dylib
If this is not included in the app bundle after building your app you'll want to add it by including it in the Copy Files Build Phase. Another possible problem could be that it's run path is not correctly set ( which you'll need to set if not already ), or fix the rpath with install_name_tool.
↳ Run-Path Dependent Libraries

OSX App crashing on load when ParseOSX framework with Dyld Error

I have an OSX app and I have added the ParseOSX sdk. I have followed all the instructions on the quick start page (https://www.parse.com/apps/quickstart#parse_data/desktop/osx/existing)
The app is running fine in Xcode (Version 5.1.1 (5B1008)) but when I archive and create a package and install this. I get the following Dyld error;
Dyld Error Message:
Library not loaded: #executable_path/../Frameworks/ParseOSX.framework/ParseOSX
Referenced from: /Applications/MyApp.app/Contents/MacOS/MyApp
Reason: image not found
It goes on and lists the Binary Images loaded.
Searching the web I found reference to adding a copy files build phase and adding the parse framework to that with the destination set to Products directory.
So it appears there is a dynamic lib not being installed somewhere.
UPDATE:
I just cleaned the build folder and now the app will not even run under Xcode. I get:
dyld: Library not loaded: #executable_path/../Frameworks/ParseOSX.framework/ParseOSX
Referenced from: /Users/Ants/Library/Developer/Xcode/DerivedData/MyApp-hjrbgyhzpwnxhiaskxpojqyqxnvh/Build/Products/Debug/Actual.app/Contents/MacOS/MyApp
Reason: image not found
UPDATE 2:
It turns out when you are in the quick start page. If you chose the new app option you get a Xcode project. This compiles. Going through it I can see that there is is a Copy Files step that copies the ParseOSX.framework into the Frameworks destination. Tried this is my app and I now get a signing error
/Users/Ants/Library/Developer/Xcode/DerivedData/MyApp-hjrbgyhzpwnxhiaskxpojqyqxnvh/Build/Products/Debug/MyApp.app: code object is not signed at all
In subcomponent: /Users/Ants/Library/Developer/Xcode/DerivedData/MyApp-hjrbgyhzpwnxhiaskxpojqyqxnvh/Build/Products/Debug/MyApp.app/Contents/Frameworks/ParseOSX.framework
I ran into the same problem with xcode 6.1. Fixed it by adding ParseOSX.framework to "Embedded Binaries" on the general tab of the Targets page.
Two things fixed this for me.
First I needed to add a copy files section to the build phases and copy the ParseOSX.framework into the Frameworks destination.
And second, I needed to add --deep to the "Other Code Signing Flags" in the Code Signing section of Build Settings. It now signs the frameworks being copied it seems.
I was updating an existing parse project to the newest SDK (1.12.0) using Xcode 7.2 and ran into the same problem.
The solution for me was to set Runpath Search Paths to #executable_path/../Frameworks.
I found this by comparing the Starter project from Parse to my project.

TeamCity not building Cordova project when building PhoneGap project

I'm trying to build a PhoneGap application using TeamCity and am receiving an error stating that:
AppDelegate.h:30:9: fatal error: 'Cordova/CDVViewController.h' file not found
My xcodeproj actually has the Cordova.xcodeproj file inside the project rather than referencing it from anywhere else. I can tell it is in fact building the project as when I deliberately put in a syntax error into one of its files the build fails on that file, however it doesn't seem like the compiled output is being picked up by the main project.
I can build the project fine through xcode.
Thanks,
Matt

Setting dylib paths as a XCode build step

I have a Cocoa application as XCode project that has several supplementary bits of functionality as dylib targets.
When XCode builds the project, it places all the build outputs in a single folder: The .app bundle and the dylib files. And when executed from the XCode debugger, the .app launches.
I can't however launch the application from finder.
How do I setup XCode to 'deploy' the app in a standalone state? I have found that I can use ld on the actual app binary to contain a relative path to the dylibs: #executable_path/../../mylib.dylib
Running a script after each build seems wrong: there must be some way (that Im totally missing) to do this easily from inside XCode - it must be a common issue surely?
It looks like that XCode supports having #executable_path, #loader_path and #rpath used in the Target Info > Build > Linking > Dynamic Library Install Name setting (LD_DYLIB_INSTALL_NAME) setting.
The help text says: "Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library. Any clients linked against the library will record that path as the way dyld should locate this library"
This seems very promising, but usability is a problem if I need to link dylibs in multiple paths against a common library - the relative path is going to be different each time.
Running my testapp from finder, I get the following (relevant) error text
Dyld Error Message:
Library not loaded: #executable_path/../../util.dylib
Referenced from: /Volumes/data/Code/TestApp/build/Debug/TestApp.app/Contents/MacOS/TestApp
Reason: image not found
util.dylib is in /Volumes/data/Code/TestApp/build/Debug/ so I am confused :/
You should use a Copy Files build phase to copy the dylib to the app's bundle when building the app. You'll want to copy it to Frameworks. You can then set the install path to #executable_path/../Frameworks/mylib.dylib.

Resources