iOS - how do I include javascript files that can be referred by relative paths to project? - ios

Basically I want to use relative path in my html and js files that I imported to the project. It seems that xcode puts those bundle files all at the same level if I import files as group reference. So if I then get rid of all relative paths in my code it would work. But if I import them as folder reference as following links suggested none of those files will appear in Copy Bundle Resources (neither in compiled sources).
Load resources from relative path using local html in uiwebview
UIWebView doesn't load external Javascript file
Any help will be appreciated.

I managed to resolve my issue. What I did wrong was import the entire folder as folder reference that would expose the folder appearing in the root directory as the result. I could refer every files with that directory (e.g. root/js/abc.js) but that'd be bad.
I don't know if it's the best way to resolve but here is what I have done. I created one group and put everything else in that group except importing all sub folders as folder references. In that way all files in the root group can use relative paths without errors.
Note: all the files in the folder reference still don't appear in bundle resources and I still don't know how other people (in the links I posted) got it done.

You could put your front-end files into a real folder, then add the folder to your XCode project(don't forget to check "copy if needed", not as reference).

Related

Changing file path in .dpr file in delphi

We are using Delphi 6. Currently, we have kept all the different application folders under one main folder.
We have below folder path for one of the applications:
C:\dev_GIT\MyApplications\Delphi\Sales_Applications\Member_Joining
For some reason, we would like to move this folder to below folder path:
C:\dev_GIT\Member_Joining
Issue we are getting is that we have some common files which are kept in separate folders and which are used in so many other applications as well.
Since we are moving this folder outside of the current folder path, we are getting compile error, which is expected.
The real issue is, as there are so many files which are in common folder path, we need to change their path in .DPR file one by one. Is there any better way by which we need not to change path for all the files in the .DPR file?

swift ios and geing final grip on copy bundle resources

I am currenly converting an iOS project built in another tool to xcode/swift.
I currently have an xcode swift ios project with multiple targets defined (one for each customer)
For each customer I have a folder "customerxyzassets" that I have added to "target > build phases > copy bundle resources" using the process described here Include a resource directory hierarchy into app bundle
This folder "customerxyzassets" contains subfolders with images and data files which the app is born with.
I would like to grab a path to this folder upon startup, so I can access load datafiles, images etc. from it.
However, the code I have found, e.g. NSBundle.mainBundle, seems to require speciel access to the files through the above. I would rather have raw file access to it. Am i missing something obvious?
It's not clear what you mean here by "special access" or "raw access." NSBundle just returns you paths or URLs so you can directly access the files using normal file APIs.
If you've created a directory structure, then you would generally use pathForResource(_:ofType:inDirectory:) to fetch the path to your specific file. Alternately, you can build a path using NSBundle.resourcePath and append your relative path using stringByAppendingPathComponent. The advantage of the pathForResource methods is that they handle localization for you, and this is preferred unless the resource should never be localized (which is rare).

Xcode .gitignore files within directories

I am looking to .gitignore my plist file found within a subdirectory within my project. When I ignore individual files at the root level where .gitignore is located I have no problems with the exclusion, but when I try to exclude files within the a subdirectory I can't seem set up the proper way to exclude this and my file still appears. I think what is throwing me off the most is the way that my Xcode projects appear in my finder compared to my Xcode program. In Xcode, my .plist appears within a Supporting Files folder. Once would assume that this would mean my gitignore request would be /app-name/Supporting Files/Info.plist, but in the finder, there is no Supporting Files folder, just Info.plist.
Any advice as to what I should do?
Should my .gitignore look like:
facebook-login-template/Info.plist
or
/facebook-login-template/Supporting Files/Info.plist
or should it be something else?
I think you are looking for this:
*Info.plist
If you only want to avoid the one inside "facebook-login-template", it should work with
facebook-login-template/Info.plist
but remember you have to reset the file on git if you've already tracked it.

Moving files around in XCode and IOS 7

I move some files into a subdirectory but now I get linking errors saying files can't be found. Where do I go (like a projects file) to tell XCODE where to look for the new files?
I tried removing everything and adding them back in but I still get missing files even though they are one directory in and added to the project.
Select a file in left panel, open inspector panel on the right and choose a path to file there.
Note: it's more efficient to do that if your files are organized into folders; that way, you only need to change the path to folder and the elements are relative to it.

Xamarin studio folder structure issue in iOS project

I am having trouble with xamarin folders. Currently I'm writing xamarin iOS project. In Xcode I used directories for grouping images, there could be several levels of nested folders, but when I was building project for device or iOS simulator, these resources where simply being copied to main bundle, without any folder structure. I can't reach the same behaviour in xamarin studio. Whenever I create folders in my project and put pictures or other resources in them, this folder structure is recreated on the actual device, and thus, I struggle against different paths, when loading images. How can I make xamarin studio simply copy the files in the folders to main bundle, instead of recreating folder structure?
Thanks for help.
My first suggestion is to change the BuildAction property of your images to BundleResource.
Once you do that, there are multiple ways of achieving your goal:
The first option is to specify a LogicalName to be whatever you want the name to be inside of the compiled app bundle. Currently there's no way to set the Resource ID (UI name for the LogicalName property) for anything other than EmbeddedResource files (I'll work on fixing that momentarily), but you can edit the *.csproj like so:
<BundleResource Include="Icons\icon.png">
<LogicalName>icon.png</LogicalName>
</BundleResource>
Normally, that Icons\icon.png file would be copied into the iOS app bundle as Icons/icon.png, however, the LogicalName property overrides the relative path name. In this case it would be copied over as simply icon.png.
As another example, you can also do this:
<BundleResource Include="Icons\iOS\icon.png">
<LogicalName>AppIcon.png</LogicalName>
</BundleResource>
This will copy the Icons\iOS\icon.png file into the root of the iOS app bundle and also rename it to AppIcon.png.
A second option is to simply move your image file(s) into the Resources folder. The Resources folder is special directory that get stripped out of the default path names when copied over to the iOS app bundle. In other words, Resources\icon.png would be copied over into the root of the iOS app bundle as icon.png rather than Resources\icon.png as is the case with normal project directories.
A third option is to simply register other "Resource" directories of your own (and they can exist within other directories, including the default Resources directory).
For example, you could have the structure in your project:
Resources/
Icons/
icon.png
icon#2x.png
And in your *.csproj file, edit the following tag:
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
and replace it with:
<IPhoneResourcePrefix>Resources;Resources\Icons</IPhoneResourcePrefix>
This will ensure that the icon.png and icon#2x.png files are installed in the root of the iOS app bundle.
Xamarin has two ways to setup files you want present in the iOS bundle:
Put them in any folder, and mark the "Build Action" as "Content". Whatever directory structure you have in your project will be present in the main bundle.
Put them in the "Resources" folder, with a "Build Action" as "BundleResource", this does the same as #1, but removes the "Resources" folder from the path present in the bundle. This is a nice place to put all images you want in the root of your bundle but would clutter up your project.

Resources