After importing Objective C Framework into my Swift project, my project does not recognise my header file in my Bridging file - ios

I've got to import a Framework into my Swift project that is written in Objective C. So I've created a Bridging file and after I've added the Header files to it and compiled, my project says it cannot find them. The image below shows my Framework and you can clearly see AWController.h but it throws an error in my Bridging file when building.
The Bridging file shows in my Settings so what am I doing wrong or what have I missed? I've set my Defines Module to Yes in Build Settings and my Module Name has no spaces.

I would review the setup for AWS at their website. They even have a section that details using with Swift iOS9.
Among other things, if you are using the Frameworks manual integration, verify that step 4 is complete.
Under the Build Phases tab in your Target, click the + button on the
top left and then select New Run Script Phase. Then setup the build
phase as follows. Make sure this phase is below the Embed Frameworks
phase.:
Shell /bin/sh
bash
"${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCore.framework/strip-frameworks.sh"
Show environment variables in build log: Checked Run script only when
installing: Not checked
Input Files: Empty Output Files: Empty
You might want to install and use Carthage to make this easier. Head over to the Homebrew website then after installing homebrew you'd run brew install carthage from the command line. After that go back to the link above and follow the Carthage instructions.
Secondly, I would take another walkthrough of the Apple Documentation on Working with the bridging header files to see if any of the edge cases apply and just as a sanity check.
Third, if that doesn't work, I'd just try creating an empty Swift project and walk through the steps again using one of the techniques above. There might be something wrong with one or more settings in your project files or the file itself might be corrupt.
BTW - The product bundle identifier should probably be following the convention of com.yourdomain.YourProductName.

You should not use bridge header. Just use import AWSDK in the swift file where you use it.

Related

Firebase Crashlytics | Swift Package Manager (SPM) Run Script?

I want to add Crashlytics to my app using the Swift package manager.
Now, since the usual way to install Firebase is through CocoaPods, the tutorial on how to set up Crashlytics properly is also adjusted for CocoaPods.
In other words - the run script we should copy from the tutorial is not compatible with SPM, as you can see here:
${PODS_ROOT}/FirebaseCrashlytics/run
So how can I find the file location of Crashlytics using SPM to get the correct run script?
Thanks!
Turns out its inside the DerivedData folder:
~/Library/Developer/Xcode/DerivedData/YOURAPP-.../SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
For your convenience, you can use a build variable to generalize the folder path:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
Finally, your run script should look something like that:
And another quite important thing if a non-default name for the firebase configuration file is used.
This flag is needed to denote it:
-gsp ${PROJECT_DIR}/PATH-TO-CONFIG/GoogleService-Info-Dev.plist
Thus final script should look like
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run -gsp ${PROJECT_DIR}/PATH-TO-CONFIG/GoogleService-Info-Dev.plist
Where PATH-TO-CONFIG is the path to the firebase configuration file in the project.
Thanks for the suggestions. I'm unable to make this work. I get a crash and the following error message:
/Users/[path-to-my-project]/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
I don't understand why it tries to find the crashlytics script in my Xcode project folder and not in the derived data folder at runtime.
This worked for me, but I had to change Project Settings.
"${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
Add a package by selecting File → Add Packages… in Xcode’s menu bar.
Search for the Firebase Apple SDK using the repo's URL:
https://github.com/firebase/firebase-ios-sdk.git
Next, set the Dependency Rule to be Up to Next Major Version and specify 8.10.0 as the lower bound.
Then, select Add Package.
Choose the Firebase products that you want installed in your app.
If you've installed FirebaseAnalytics, add the -ObjC option to Other Linker Flags in the Build Settings tab.

Remove fabric framework from ios app

I have been landed an iOS project from a client. The main task is to explore and see the user interface so that multiplatform app will be made from scratch with Xamarin.
I notice that the project uses third party framework called fabric. From what i see it is used from crash analytics. I don't need that and i don't have registration so i want to remove all dependencies from the project.
So far I did:
Deleted define ENABLE_FABRIC ( which removed some code from
AptDelegate, replaced logging messages with plain NSLog etc)
Removed some fabric script invocation from build phases
Removed reference from fabric framework in project
So i still have errors building my app:
/bin/sh:
/Users/macmini/Library/Developer/Xcode/DerivedData/../Build/Intermediates/../Script-FDC6FCE81A4488D000F2613D.sh:
(null): bad interpreter: No such file or directory
Does anyone know a quick way to get rid of this?
I know it's an old question but I want to help. When you install Fabric, previously Crashlytics, it asks you to put a script in project->Build Phases-> Run Script
it will look like this
./Fabric.framework/run 123456fd7ec....6e2170Q
I think you should remove that script and other Linked Frameworks and Libraries and then it possibly could run
Try deleting the files DerivedData path and clean build folder
cmd+opt+shift+k
then re run the application.
Also check once again the Framework search path in xcode settings.

How do I use SwiftyJSON in my iOS App?

I recently added SwiftyJSON into my xCode project using Carthage.
Cartfile
$ cat Cartfile
github "SwiftyJSON/SwiftyJSON" >= 2.1.2
I ran this command to install SwiftyJSON
$ carthage update
I added the built Framework to my xCode project
I imported the Framework at the top of my project
But I still get this error:
Use of unresolved identifier 'JSON'
Seriously, what am I doing wrong? I'm new to iOS development.
UPDATE: I tried removing the Frameworks and re-dragging the frameworks to the Linked Frameworks and Libraries and Adding the "Run Script" section to "Build Phases" as the instructions in Carthage asked.
I'm convinced that something went awry during the Carthage Update process because I received this error on my initial attempt:
$ carthage update
*** Fetching SwiftyJSON
*** Fetching Alamofire
*** Checking out SwiftyJSON at "2.1.3"
*** Checking out Alamofire at "1.1.4"
*** xcodebuild output can be found in /var/folders/0x/swzt630n3_575tglljpwhn4h0000gn/T/carthage-xcodebuild.Pc6rLg.log
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace
*** Building scheme "SwiftyJSON" in SwiftyJSON.xcworkspace
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
After looking up the problem, I was told that you could run
carthage update --configuration Debug
Which installed it fine, but something is still amiss...
It seems like you missed a step during the addition of SwiftyJSON and Alamofire frameworks from Carthage. Check out these steps from the Carthage readme page :
Steps :
Create a Cartfile that lists the frameworks you’d like to use in your project.
Run carthage update. This will fetch dependencies into a Carthage/Checkouts folder, then build each one.
On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.
On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:
/usr/local/bin/carthage copy-frameworks
and add the paths to the frameworks you want to use under “Input Files”, e.g.:
$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework
$(SRCROOT)/Carthage/Build/iOS/SwiftyJSON.framework
Looks like you missed step 4. I tried these steps myself in a demo Swift project and they are working great. Try these steps out, and if you still have problems, leave a comment. Thanks!
I switched over to Cocoapods and it just worked. Again, I'm a total noob when it comes to iOS development. When looking for a dependency manger I looked at Cocoapods and Carthage for what they had to offer. I was intrigued by Carthage's claim of keeping things simple:
"Carthage because we wanted the simplest tool possible—a dependency manager that gets the job done without taking over the responsibility of Xcode"
While I always will choose the simpler tool when given a choice, I think I don't know enough of the iOS ecosystem (read: Xcode) to use Carthage.
TL,DR: Can't use it inside of Emulator, Use iPhone.
I also followed your way, and I found out that --configuration debug will code-sign "iOS Developer" identity as SwiftyJSON's project property.
AFAIK, Code-signed "iOS Developer" identity wasn't run with Emulator.
My issue was resolved when I run it at my iPhone 6.
I do not know why you can not add this resource with help of Carthage but if you need use SwiftyJSON you only need:
Enter this URL: SwiftyJSON
Clic the button "Clone or download" and then in "Download ZIP" like the next image shows:
Clic the button "Clone or download" and then in "Download ZIP" IMG
You will get a ZIP file with name "SwiftyJSON-master"
Extract the files
Enter the path:
SwiftyJSON-master/Source/
You will see a file with name:
SwiftyJSON.swift
Copy that file into the files of your project.
Add that file into your project directory.
That file will be like other class into your project that you may use.

Validation Error: The bundle contains disallowed file 'Frameworks'

I'm having the same issue as this guy, this guy, and this guy (nota bene, I'm actually not sure if they're all guys, per se).
They all ended up finding their own solutions, but none of them apply to my issue. I'm using Xcode 6.1 in my iOS 8 app with an included extension. The app and the extension both rely on an included framework. When I try to submit the app to the Store, the validation warning I get is "ERROR ITMS-9000: Invalid bundle. The bundle at 'xxxxx.appex' contains disallowed file 'Frameworks'".
I can't even find a file called Frameworks. The shared framework is supposed to be saved at /Library/Frameworks, which is Apple's recommended save location. The project also uses Cocoapods, which strikes me as the only other possible culprit, since it has references in its configuration files to $FRAMEWORK_PATH (though the build folder doesn't include a file or folder with that name).
OK for future viewers here's the fix:
When you create your own iOS framework (I'm using Xcode 6.1) when you build it the final product contains a 'Frameworks' folder in the framework bundle itself. i.e. MyFramework.framework/Frameworks. This happens even if you don't specify a copy files/embed frameworks build phase.
What you have to do is to go into you framework bundle, find the empty frameworks folder and delete it. This should not affect your app's functionality in any way. Then build your app and check that the embedded framework doesn't have a Frameworks folder as planned.
Your archive should now not contain the offending folder and the error should be gone!
I changed build settings > Packaging > Define modules set to YES in my extension and watch app target. Works fine for me.
In my case the solution was the following :
Try to create the script there 'problematic target' -> Build Phases' then click on + and select New Run Script Phase, the run script should go after all others. Insert there :
cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then
rm -fr Frameworks
fi
Then clean the project and try to create an archive once again. These answer was provided in the following issue :
https://github.com/CocoaPods/CocoaPods/issues/4203
I hope this help you.
Continuing to work with this, I noted that my Share Extension had an "Embed Frameworks" Build Phase, with the Destination set to the "Frameworks" directory. I changed it to "Shared Frameworks" and the error has gone away.
However, another error remains: "... contains disallowed nested bundles". I thought this was a sort of umbrella error warning as a result of the original. I'll open another question for that one.

Facebook iOS SDK 3.1 from Github missing FacebookSDK.framework

I want to use Facebook SDK on XCode 4.5 for integration with iOS6.
I read this tutorial. I was using this .dmg package to install the library but I need to track and read the implementation of some methods, so I noticed that there is a repo on Github with the current source code.
My problem is that I don't know how to install this properly as with the package .dmg. Any ideas on how to do it? I tried to just import the src folder and reference the whole project but I'm having a lot of issues, warnings and errors.
Update
I had to do this again, so now I made it work. Here is what I did:
I tried both ways, building the source code (1) and importing the files directly(2). On the first scenario it was easy, on the root folder of Github repo just run:
sudo scripts/build_framework.sh
You will get the files needed, the same that you get when installing with .pkg. But I needed to track the functions, so I tried to importing the files.
First I added the src folders from the Github repo on my project. I had an issue with duplicated definitions on every file. The problem was on my Build Settings (BS), I was still referencing to the .pkg install directory of Facebook so I had the files duplicated. I removed every reference to that folder on BS and then added the files.
After that, on the files that imported the Facebook files I got:
Undefined symbols for architecture i386
When I copied the files to XCode, the .m files where not automatically added to the Build Phases / Compile Sources. I added them manually and imported FBConnect.h on my files.
Hope it helps some one with the same issue.
If you include the FacebookSDK via git, you will need to build the framework. Run the following command from within the FacebookSDK directory:
scripts/build_framework.sh
Then, FacebookSDK.framework will appear in FacebookSDK/build
Add the entire src folder to your project. Import FBConnect.h in any class where you want to use Facebook. The connect class imports the rest of the necessary classes.
#import "FBConnect.h"

Resources